akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

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

            var input = cin.SplitRead();
            int N = input[0];
            int M = input[1];
            var A = cin.SplitReadL();

            long ans = 0;
            var map = new Dictionary<long, long>();
            var d = new long[N + 1];
            d[0] = 0;
            map[0] = 1;
            for(var i = 0; i < N; i++)
            {
                d[i + 1] = d[i] + A[i];
                long r = d[i + 1] % M;
                if (!map.ContainsKey(r))
                {
                    map[r] = 0;
                }
                ans += map[r];
                map[r]++;
            }


            Console.WriteLine(ans);


            
            //Console.Out.Flush();
        }

    }

   

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 23904
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <iomanip>

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> str(N);
  string result;
  for (auto&& v : str) {
    cin >> v;
  }
  sort(str.begin(), str.end());
  cout << accumulate(str.begin(), str.end(), ""s) << endl;
 return  0;
}

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

//a^b % modを求める
int64_t MODpow(int64_t a, int64_t b, int64_t mod) {
    int64_t result = 1;
    while (b) {
        if (b % 2 == 1) {
            result *= a;
            result %= mod;
        }

        b /= 2;
        a *= a;
        a %= mod;
    }

    return result;
}

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N), B(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    constexpr int64_t MOD = 1e9 + 7;

    int64_t zero_zero_num = 0, A_zero_num = 0, B_zero_num = 0;
    map<pair<int64_t, int64_t>, int64_t> plus_mp, minus_mp;
    for (int64_t i = 0; i < N; i++) {
        if (A[i] == 0 && B[i] == 0) {
            zero_zero_num++;
        } else if (A[i] == 0) {
            A_zero_num++;
        } else if (B[i] == 0) {
            B_zero_num++;
        } else {
            int64_t gcd_AB = gcd(A[i], B[i]);
            int64_t a = abs(A[i] / gcd_AB);
            int64_t b = abs(B[i] / gcd_AB);
            int64_t sign_A = (signbit(A[i]) ? -1 : 1);
            int64_t sign_B = (signbit(B[i]) ? -1 : 1);
            if (sign_A * sign_B == 1) {
                plus_mp[make_pair(a, b)]++;
            } else {
                minus_mp[make_pair(a, b)]++;
            }
        }
    }

    //ダメなペアの数を列挙
    vector<pair<int64_t, int64_t>> disable;
    if (A_zero_num > 0 && B_zero_num > 0) {
        disable.emplace_back(A_zero_num, B_zero_num);
    }
    for (auto&[key, value] : plus_mp) {
        int64_t n = value;
        int64_t m = minus_mp[make_pair(key.second, key.first)];
        if (m == 0) {
            continue;
        }
        disable.emplace_back(n, m);
    }

    //ペアがあるものの個数について総和を取得
    int64_t pair_num = 0;
    for (auto&[n, m] : disable) {
        pair_num += n + m;
    }

    //ペアがないものでの答え
    int64_t size = N - pair_num - zero_zero_num;
    int64_t ans = (MODpow(2, size, MOD) + MOD - 1) % MOD;

    //ダメなペアを考えていく
    for (auto&[n, m] : disable) {
        int64_t n_pow = (MODpow(2, n, MOD) + MOD - 1) % MOD;
        int64_t m_pow = (MODpow(2, m, MOD) + MOD - 1) % MOD;
        int64_t nm_pow = (MODpow(2, n + m, MOD) + MOD - 1) % MOD;
        int64_t sub = n_pow * m_pow % MOD * (ans + 1) % MOD;

        (ans += nm_pow * (ans + 1) % MOD) %= MOD;
        (ans += MOD - sub) %= MOD;

        size += n + m;
    }

    //(0, 0)を足す
    if (zero_zero_num) {
        size += zero_zero_num;
        ans += zero_zero_num;
    }

    assert(size == N);

    cout << ans << endl;
}

Measured memory_bytes: 25080
def resolve():
    '''
    code here
    '''
    import collections
    N, M = [int(item) for item in input().split()]
    edges = [[int(item) for item in input().split()] for _ in range(M)]
    
    togo = [[] for _ in range(N+1)]
    for f, t in edges:
        togo[f] += [t]
    
    is_found = False

    que = collections.deque()
    for goto in togo[1]:
        que.append(goto)

    is_found = False
    while que:
        node = que.popleft()
        for next_node in togo[node]:
            if next_node == N:
                is_found = True
            # print(next_node, is_found)
            
    print('POSSIBLE') if is_found else print('IMPOSSIBLE')

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 60500
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <set>
#include <deque>
#include <vector>
#define MAX 100100
#define rep(i,p) for(int i=0;i<p;i++)
#define rep1(i,p) for(int i=1;i<=p;i++)
#define pb push_back
using namespace std;
int n,q,x,y,com;
int v[10010];
int root (int child) {
  int a = child;
  while (v[a] != a) {
    a = v[a];
  }
  return a;
}
int main(){
  cin >> n >> q;
  // v array
  // 0..n-1 : i
  // n...   : 0
  rep(i,n) v[i] = i;
  rep(i,q) {
    cin >> com >> x >> y;
    // com = 0 : unite
    // com = 1 : same
    if (com == 0) {
      // com(x,y) : merge S_x with S_y
      v[root(x)] = root(y);
    } else {
      if (root(x) == root(y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
import math

n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]

dis = [[0]*n for _ in range(n)]

for i in range(n):
    for j in range(n):
        dis[i][j] = math.sqrt((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)

ans = 0

for i in range(n):
    for j in range(i+1,n):
        ans += dis[i][j] * math.factorial(n-1) * 2

print(ans/math.factorial(n))


Measured memory_bytes: 3064
import sys, fractions
input = sys.stdin.readline

N, A = map(int, input().split())
X = [int(i) for i in input().split()]
X.append(A)
X.sort()

dX = [0]*(N)

for i in range(N):
  dX[i] = X[i+1] - X[i]
Xgcd = [0]*(N)
Xgcd[0] = dX[0]
  
for i in range(N-1):
  Xgcd[i+1] = fractions.gcd(Xgcd[i], dX[i+1])
print(Xgcd[-1])

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n>>l>>m;
    	ll x=(n/(l+m))*l;
    	n=n%(l+m);
    	x+=min(l,n);
    	cout<<x;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s>>t;
	string res="{";
	if(s.size()<t.size()){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	for(int i=0;i<=s.size()-t.size();i++){
		string tmp=s;
		for(int j=0;j<t.size();j++)
			if(tmp[i+j]=='?')
				tmp[i+j]=t[j];
		bool ok=true;
		for(int j=0;j<t.size();j++)
			if(tmp[i+j]!=t[j]){
				ok=false;
				break;
			}
		if(ok){
			for(int j=0;j<tmp.size();j++)
				if(tmp[j]=='?')
					tmp[j]='a';
			res=min(res,tmp);
		}
	}
	if(res=="{"){
		cout<<"UNRESTORABLE"<<endl;
		return 0;
	}
	else
		cout<<res<<endl;
	return 0;
}


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

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

    vector<int> x(m);
    rep (i, m)
        cin >> x[i];

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

    vector<int> dist(m - 1);
    rep (i, m - 1)
        dist[i] = x[i + 1] - x[i];

    sort(dist.begin(), dist.end(), greater<int>());

    ll ans = accumulate(dist.begin(), dist.end(), 0);
    int cnt = min(n - 1, m - 1);
    rep (i, cnt)
        ans -= dist[i];

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

Measured memory_bytes: 3944
def showlist(A):
    for i in range(len(A)):
        if i==len(A)-1:
            print(A[i])
        else:
            print(A[i], end=' ')

N = eval(input())
A = list(map(int, input().split()))
showlist(A)
for i in range(1,N):
    v = A[i]
    j = i - 1;
    while j>=0 and A[j] > v:
        A[j+1] = A[j]
        j = j - 1
    A[j+1] = v
    showlist(A)


Measured memory_bytes: 5980
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

long calc(long x, long y) {
    return abs(x/2 - (x-x/2))*y;
}

void main() {
    long a, b, c;
    readf("%d %d %d", &a, &b, &c);
    min(calc(a, b*c), calc(b, c*a), calc(c, a*b)).writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e2+20;
const int inf=1e5;
int n,A,B;
int dp[45][N][N];//dp[i][a][b] Ç°i¼þ ²ÄÁÏÎª[a,b]Ê±µÄ×îÐ¡¼ÛÇ® 
struct node{
	int a,b,c;
}p[N];
bool cmp(node a,node b)
{
	if(a.a==b.a)
	{
		if(a.b==b.b)
		return a.c<b.c;
		else
		return a.b<b.b;
	}
	return a.a<b.a;
}
int gcd(int a,int b)
{
	if(b==0)
	return a;
	else
	return gcd(b,a%b);
}
int main()
{
	while(cin>>n>>A>>B)
	{
		int ans=1e5;
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=400;j++)
			{
				for(int k=0;k<=400;k++)
				dp[i][j][k]=inf;
			}
		}
		dp[0][0][0]=0;
		for(int i=1;i<=n;i++)
		{
			cin>>p[i].a>>p[i].b>>p[i].c;
		}
	//	sort(p+1,p+1+n,cmp);
		for(int i=1;i<=n;i++)
		{
			dp[i][0][0]=0;
			for(int j=1;j<=400;j++)
			{
				for(int k=1;k<=400;k++)
				{
					if(j>=p[i].a&&k>=p[i].b)
						dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-p[i].a][k-p[i].b]+p[i].c);
					else
						dp[i][j][k]=dp[i-1][j][k];	
					
					int d=gcd(j,k);
					if(j/d==A&&k/d==B)
					{
						ans=min(ans,dp[i][j][k]);
					}
				}	
			}	
		}
		if(ans==1e5)
		ans=-1;
		
		cout<<ans<<endl;
	}
	return 0;	
}

Measured memory_bytes: 28800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
using ll=long long int;
using ppi=pair<ll,ll>;
using pql =priority_queue<ll, vector<ll>, greater<ll>>;
using pq=priority_queue<ll>;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int>a(n);
    int c=0;
    rep(i,n){
        cin>>a[i];
        c+=a[i];
    }

    int ans=0;
    rep(i,n){
        if(a[i]*4*m>=c){
            ans++;
        }
    }
    if(ans>=m){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = 0;
		int [] in = new int [b];
        int [] str = new int [b];
        int [] ans = new int [a];
        for(int i=0;i<b;i++){str[i] = sc.nextInt();
                             in[i] = sc.nextInt();
                            }
        for(int i=0;i<a;i++){ans[i] = -1;
                            }
        for(int i=0;i<b;i++){if(ans[str[i]-1]==in[i]||ans[str[i]-1]==-1)
                              {ans[str[i]-1] = in[i];}
                              else{c = -1;}
                             if(a>1 && ans[0]==0){c=-1;}
                             }
		if(c==0){if(a==1) {c=Math.max(0,ans[0]);}
        else{for(int i=0;i<a;i++){if(ans[i]==-1){if(i==0){ans[i]=1;}else{ans[i]=0;}}
                                                                                                        
                                 }
               if(a==2){c=10*ans[0]+ans[1];} else{c=100*ans[0]+10*ans[1]+ans[2];}
            }
                }
        
		System.out.println(c);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

vector< pair<int,int> > doll;
int dp[200];
int n,m,tmp1,tmp2;

int main(){
  while(cin>>n && n){
    for(int i=0;i<n;i++){
      cin>>tmp1>>tmp2;
      doll.push_back(make_pair(tmp1,tmp2));
    }
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>tmp1>>tmp2;
      doll.push_back(make_pair(tmp1,tmp2));
    }

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

    int ans=0;

    for(int i=0;i<n+m;i++){
      dp[i]=1;
      for(int j=0;j<n+m;j++){
        if(doll[i].first>doll[j].first && doll[i].second>doll[j].second){
          dp[i]=max(dp[i],dp[j]+1);
        }
      }
      ans=max(ans,dp[i]);
    }

    cout<<ans<<endl;

    while(doll.size()) doll.pop_back();
    memset(dp,0,sizeof(dp));
  }
  return 0;
}

Measured memory_bytes: 3068
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        int min = 1000;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
            if (s[i] % 10 != 0 && min > s[i]) {
                min = s[i];
            }
            ans += s[i];
        }
        Arrays.sort(s);
        if (min == 1000 && ans % 10 == 0) {
            System.out.println(0);
        } else if (min == 1000) {
            System.out.println(ans);
        } else if (ans % 10 == 0) {
            System.out.println(ans - min);
        } else {
            System.out.println(ans);
        }

    }
}

Measured memory_bytes: 24020
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

//最大公約数
//O(log max(a,b))
template<class T>
T GCD(T a, T b) {
	if (b == 0)return a;
	return GCD(b, (T)(a % b));
}

ll N, X;
vector<ll> towns;

int main() {
	cin >> N >> X;
	towns.resize(N + 1);
	towns[0] = X;
	for (ll n = 1; n <= N; n++)cin >> towns[n];
	sort(towns.begin(), towns.end(), [](ll a, ll b) {
		return a < b;
	});
	ll d = towns[1] - towns[0];
	for (ll n = 1; n < N; n++) {
		d = GCD(d, towns[n + 1] - towns[n]);
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++)a[i] = fs.nextInt();

        int val = 1;
        for(int i=0;i<n;i++){
            if(a[i] == val)val++;
        }

        if(val==1){
            System.out.println(-1);
        }else{
            System.out.println(n-val+1);
        }
    }
    static class FastScanner{
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte(){
            if(ptr < buflen){
                return true;
            }else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen <= 0){
                    return false;
                }
            }
            return true;
        }

        private int readByte(){
            if(hasNextByte())return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c){
            return 33<=c && c<=126;
        }

        public boolean hasNext(){
            while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
            return hasNextByte();
        }

        public String next(){
            if(!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)){
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong(){
            if(!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if(b == '-'){
                minus = true;
                b = readByte();
            }
            if(b < '0' || '9' < b){
                throw new NumberFormatException();
            }
            while(true){
                if('0' <= b && b<='9'){
                    n*=10;
                    n+=b-'0';
                }else if(b==-1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt(){
            long nl = nextLong();
            if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
            return (int)nl;
        }
        public double nextDouble(){return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 22360
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]


n, m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(m)]

uf = Uf(n)
for i in range(m):
    uf.unite(A[i][0]-1, A[i][1]-1)

# print(uf.p, uf.size)
print(max(uf.size))



Measured memory_bytes: 111652
#include <bits/stdc++.h>
     
    using namespace std;
    
    const int inf = 1e9; 

    int main(){
        char s[3];
    	scanf("%s",s);
    	(s[0]==s[1]&&s[0]==s[2])?printf("No"):printf("Yes");;
        return 0;
    }

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	ll t=0,res=0;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		res+=max(0LL,t-x);
		t=max(t,x);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3584
using System;
 
class Program
{
  const int marbleNum = 1;
  
  static void Main(){
    //出力結果格納用変数
            int ret = 0;
 
            // 整数の取得
            int s = int.Parse(Console.ReadLine());
 
            // 1の数をカウント
            while (s > 0)
            {
                if(s % 10 == marbleNum)
                {
                    ret = ret + 1;
                }
                s = s / 10;
            }
            
            Console.WriteLine(ret.ToString());
  }
}

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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef unsigned long long int ll;
typedef long double ld;

int main() {
	Boost();

	int n, a, b;
	cin >> n >> a >> b;

	int dif = b - a - 1;

	if(dif % 2) {
		cout << "Alice";
	} else {
		cout << "Borys";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    long n;
    cin>>n;
    long l[n+1];
    l[0]=0;
    for(int i=1;i<=n;i++)
    cin>>l[i];
    long s=0;
    for(int i=0;i<=n;i++)
    s+=l[i];
    long long ans=0,infin=pow(10,9)+7;
    for(int i=n;i>=2;i--)
    {
        s=s-l[i];
        ans=(ans+(l[i]%infin)*(s%infin))%infin;
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 4972
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int a,b, x;cin>>x>>a>>b;
    int c = b-a;

    if(c<=0){
      cout<<"delicious"<<endl;
    }
    if(x>=c && c>0){
      cout<<"safe"<<endl;
    }
    if(x<c && c>0){
      cout<<"dangerous"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
// Problem: C - Step
// Contest: AtCoder - AtCoder Beginner Contest 176
// URL: https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

//=========================================================

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//=========================================================
#ifdef DEBUG
#define xtp xtp1
#else
#define xtp(x)
#endif
//=========================================================

#include <bits/stdc++.h>

using namespace std;

#define int long long

typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = 1e18;

signed main() {
	TEZ;

	int n;
	cin >> n;

	vi a(n);
	for (int &i : a)
		cin >> i;

	int jv = 0;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] > a[i]) {
			jv += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}

	cout << jv << endl;

	return 0;
}


Measured memory_bytes: 4712
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>

#define N_MAX	10
#define MP make_pair

using namespace std;

int main()
{
	string str_in;
	int n;

	while (cin >> n && n != 0)
	{
		//プレイヤー
		string str[N_MAX];
		string ba;
		
		cin >> str_in;

		for (int i = 0; i < str_in.size(); i++)
		{
			str[i % n] += str_in[i];

			/*if (str_in[i] == 'M')
			{
				str[i % n] += str_in[i];
			}*/
			if (str_in[i] == 'S')
			{
				ba += str[i % n];
				str[i % n].clear();
			}	
			else if (str_in[i] == 'L')
			{
				str[i % n] += ba;
				ba.clear();
			}
		}

		int num[N_MAX];
		for (int i = 0; i < n; i++)
		{
			num[i] = str[i].size();
		}
		sort(num , num + n);

		for (int i = 0; i < n; i++)
		{
			cout << num[i] << " ";
		}
		cout << ba.size() << endl;
	}

	return 0;
}

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

int main() {

    ll n; string s; cin >> n >> s;
    ll r_num = 0;
    ll g_num = 0;
    ll b_num = 0;
    for (ll i = 0; i < n; i++) {
        if (s[i] == 'R') r_num++;
        if (s[i] == 'G') g_num++;
        if (s[i] == 'B') b_num++;
    }
    ll tmp = r_num * g_num * b_num;
    ll t = 0;
    for (ll i = 0; i < n; i++) {
        for (ll j = i + 1; j < n; j++) {
            ll k = 2 * j - i;
            if (k < 0 || n <= k) continue;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
                t++;
            }
        }
    }
    cout << tmp - t << endl;
    return 0;
}

Measured memory_bytes: 3608
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
n=int(input())
ans=0
for i in range(n):
    x,u=input().split()
    if u=="BTC":
        x=float(x)
        ans+=380000*x
    else:
        x=int(x)
        ans+=x
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<bitset>
#define ll long long 
#define ull unsigned long long 
#define mem(a) memset(a,0,sizeof(a))
#define rint register int 
#define rll register long long 
#define rull register unsigned long long 
#define rchar register char
#define rstring register string 
#define rfloat register float
#define rdouble register double 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define cFor(i,a,b) for(int i=a;i>b;i--)
#define cFOR(i,a,b) for(int i=a;i>=b;i--)
#define lFor(i,a,b) for(ll i=a;i<b;i++)
#define lFOR(i,a,b) for(ll i=a;i<=b;i++)
#define lcFor(i,a,b) for(ll i=a;i>b;i--)
#define lcFOR(i,a,b) for(ll i=a;i>=b;i--)
#define watch(a) cout<<#a<<"="<<a<<endl
using namespace std;
ll qpow(int a,ll n){
	ll res=1,tmp=a;
	while(n){
		if(n&1)
			res=res*tmp;
		tmp=tmp*tmp;
		n>>=1;	
	}
	return res;
}
int main(){
	ll h;
	cin>>h;
	cout<<qpow(2,1+log2(h))-1<<endl;		
} 

Measured memory_bytes: 256
using System;

namespace Tenka1_Biginner_A
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string s = Console.ReadLine();

			if (s.Length == 2)
			{
				Console.WriteLine(s);
			}
			else
			{
				string s1 = s.Substring(0, 1);
				string s2 = s.Substring(1, 1);
				string s3 = s.Substring(2, 1);
				
				Console.WriteLine(s3 + s2 + s1);
			}
		}
	}
}

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

using namespace std;

int p[100000];

int main()
{
    p[0] = p[1] = 1;
    
    for (int i = 4; i < 100000; i += 2) p[i] = 1;
    
    for (int i = 3; i * i < 100000; i += 2){
        if (!p[i]){
            for (int j = 3 * i; j < 100000; j += 2 * i) p[j] = 1;
        }
    }
    
    int cnt = 0;
    int pr[100000];
    for (int i = 2; i < 100000; i++){
        if (!p[i]) pr[cnt++] = i;
    }
    
    int m, a, b;
    while (scanf("%d %d %d", &m, &a, &b) && m){
        int r1 = -1, r2 = -1;
        for (int i = 2; i * i <= m; i++){
            if (!p[i]){
                int p2 = *(upper_bound(pr, pr + cnt, min(m / i, i * b / a)) - 1);
                int mini = min(p2, i), maxi = max(p2, i);
                
                if (r1 * r2 < mini * maxi){
                    r1 = mini; r2 = maxi;
                }
            }
        }
        
        printf("%d %d\n", r1, r2);
    }
    
    return (0);
}

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long 

using namespace std ;

const int MAXN = 5055  , MOD = 98765431LL * 13 * 17 * 23  ; 

int a[MAXN] ;

int dp[MAXN] , dp2[MAXN] ; 

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n , k ; 
	cin >> n >> k ; 
    for(int i = 0 ; i < n ; i ++ ) 
		cin >> a[i]  ; 	
	int ans = 0 ; 
	dp[0] = 1; 
	for(int i = 0 ; i < n ; i ++ ) 
	{
		for(int j = k ; j >= a[i] ; j -- )
			dp[j] = (dp[j]+dp[j-a[i]]) %MOD ;
	}
	for(int i = 0 ; i < n ; i ++ ) 
	{
		if(a[i]>=k)
		{
			ans ++ ; 
			continue ; 
		}
		

		dp2[0] = 1 ;

		for(int j = 1 ; j <= k ; j ++ ) 
		{
			dp2[j] = dp[j] ; 
			if(j>=a[i])
				dp2[j] = (dp2[j] - dp2[j-a[i]]+ MOD ) % MOD ; 
		}

		bool f = 0 ; 
		for(int j = k - a[i] ; j < k ; j ++ ) f |= (dp2[j]) ;// , cout << j << ' ' << dp[j]<< ' ' << dp2[j] << endl ;
	//    cout << endl << endl ;	
		ans += f; 	
	}
	cout << n -ans << '\n' ; 
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

ll seg[1 << 18];
constexpr ll SIZE = 1 << 17;

void update(int x, int val) {
    int p = SIZE - 1 + x;
    chmax(seg[p], val);
    while(p > 0) {
        p = (p - 1) / 2;
        chmax(seg[p], val);
    }
}

int solve(int a, int b, int l=0, int r=SIZE, int k=0) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return seg[k];
    int mid = (l+r) / 2;
    int vl = solve(a, b, l, mid, 2*k+1);
    int vr = solve(a, b, mid, r, 2*k+2);
    return max(vl, vr);
}

int N, x;

signed main() {
    cin >> N;
    int sum = 0;
    rep(i,0,N) {
        cin >> x; sum += x;
        int val = solve(0, x) + x;
        update(x, val);
    }
    cout << sum - solve(0, N+1) << endl;
    return 0;
}

Measured memory_bytes: 4704
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

static const int MAX = 100;
static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

int n, M[MAX][MAX],color[MAX];

int prim() {
	int d[MAX], p[MAX];
	int i, sum = 0;
	rep(i, n) {
		d[i] = INF;
		p[i] = -1;
		color[i] = White;
	}
	d[0] = 0;
	while (true) {
		int u = -1;
		int minv = INF;
		rep(i, n) {
			if (color[i] != Black && d[i] < minv) {
				minv = d[i];
				u = i;
			}
		}
		if (u == -1)
			break;
		color[u] = Black;
		int v;
		rep(v, n) {
			if (color[v] != Black && M[u][v] != INF) {
				if (M[u][v] < d[v]) {
					color[v] = Gray;
					d[v] = M[u][v];
					p[v] = u;
				}
			}
		}
	}
	rep(i, n) {
		if (p[i] != -1) {
			sum += M[i][p[i]];
		}
	}
	return sum;
}

signed main() {
	ios::sync_with_stdio(false);
	cin >> n;
	int i,j;
	rep(i, n) {
		rep(j, n) {
			int a;
			cin >> a;
			M[i][j] = (a == -1) ? INF : a;
		}
	}
	cout << prim() << '\n';
	return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string s;
  cin>>s;
  Int q;
  cin>>q;
  vector<Int> x(q);
  for(Int i=0;i<q;i++) cin>>x[i],x[i]--;

  for(Int l:x){
    Int ans=0,res=0,add=0;
    queue<Int> q;    
    for(Int i=0;i<n;i++){
      if(s[i]=='D') q.emplace(add);
      if(s[i]=='M') res+=q.size(),add++;
      if(s[i]=='C') ans+=res;
      if(i>=l){
        Int k=i-l;
        if(s[k]=='D'){
          res-=(add-q.front());
          q.pop();
        }
      }
    }
    cout<<ans<<endl;
  }  
  
  return 0;
}


Measured memory_bytes: 9372
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
Ans=[0]*(n+1)
nn=int(n**0.5)+1
for i in range(1,nn+1):
  for j in range(1,nn+1):
    for k in range(1,nn+1):
      cur=i**2+j**2+k**2+i*j+j*k+k*i
      if cur<=n:
        Ans[cur]+=1
for i in range(1,n+1):
  print(Ans[i])
      

Measured memory_bytes: 9388
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

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

    long a[105]={0};
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }
    sort(a+0, a+n, greater<long>());

    ll sum=0;
    for(i=0; i<n; i++) {
        if(i%2==0) sum += a[i];
        else       sum -= a[i];
    }
    printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
public class Main {
      
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
         
        int res[]=new int[26];
         
        while(cin.hasNext()) {
            String str=cin.nextLine();
            for(int i=0;i<str.length();i++) {
                char c=str.charAt(i);
                if(c>=65 && c<=90)res[c-65]++;
                else if(c>=97 && c<=122)res[c-97]++;
            }
        }
         
        for(int i=0;i<26;i++) {
            System.out.println((char)(i+97)+" : "+res[i]);
        }
         
    }
     
}


Measured memory_bytes: 26328
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     

def main():
    a, b, n = LI()
    print(a*min((b-1), n) // b)


main()



Measured memory_bytes: 10908
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007

#define N              100000

vll ans(N+1,-1);

vll vis(N+1,0);

vector<vector<ll>> a(N+1);

map<pll,ll> val;

void dfs(ll u)
{
    vis[u]=1;

    for(auto x:a[u])
    {
        if(!vis[x])
        {
            ans[x]=ans[u]+val[{u,x}];

            ans[x]%=2;

            dfs(x);
        }
    }
}

void solve()
{
    ll n,x,y,u;

    cin>>n;

    F(i,n-1)
    {
        cin>>x>>y>>u;

        a[x].pb(y);

        a[y].pb(x);

        val[{x,y}]=u;
        val[{y,x}]=u;
    }

    ans[1]=0;

    dfs(1);

    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<" ";
    }

}

 
signed main(){
 
    fast;
 
    ll t=1;
 
    //cin>>t;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vs s(3);
  rep(i,3) cin>>s[i];
  rep(i,3){
    cout<<s[i][i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>

using namespace std;
typedef long long ll;

vector<ll> leftKey = { 1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,1 };
vector<ll> ans;

int main() {
	while (1) {
		char S[40] = {};
		ll counter = 0;
		cin >> S;
		if (S[0] == '#')break;
		for (int i = 1; i <= 32; i++) {
			if (S[i] == 0)break;
			if (leftKey[S[i] - 'a'] != leftKey[S[i - 1] - 'a'])counter++;
		}
		ans.push_back(counter);
	}
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
	return 0;
}


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

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	int n;
	while (cin >> n && n) {
		n *= 2;
		V ls(n);
		rep(i, n) cin >> ls[i];
		sort(all(ls));
		int ans = 0;
		rep(i, n) {
			ans += ls[i];
			i++;
		}
		cout << ans << endl;
	}

	system("pause");
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

int main() {
    Int n, a, b;
    cin >> n >> a >> b;
    Int atk = a - b;
    vector<Int> h(n);
    for (Int i = 0; i < n; i++) {
        cin >> h[i];
    }
    Int ok = 1e9;
    Int ng = 0;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        vector<Int> p = h;
        Int cnt = 0;
        for (Int i = 0; i < n; i++) {
            p[i] -= mid * b;
            if (p[i] > 0) {
                cnt += p[i] / atk;
                if (p[i] % atk != 0) {
                    cnt++;
                }
            }
        }
        if (cnt <= mid) {
            ok = mid;
        }
        else {
            ng = mid;
        }
    }
    dump(ok);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
 using namespace std;
 int main()
 {
 	int x,a,b,c,i,j,k,sum=0;
 	cin>>a>>b>>c>>x;
 	
 	for(i=0;i<=a;i++)
 	  for(j=0;j<=b;j++)
 	    for(k=0;k<=c;k++)
 	    {
 	    	if(i*500+j*100+k*50==x)
 	    	sum++;
 	    }
 	cout<<sum<<endl;
 	
 	return 0;
 }

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

int main() {
  int n;
  cin >> n;
  int c;
  cin >> c;
  int ans = 1;
  for(int i=1; i<=n; i++){
    if(i == 1){
      ans *= c;
    }
    else{
      ans *= c-1;
    }
  }
  
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
bool i(string a){
string b=a;
reverse(b.begin(),b.end());
return (a==b);
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    long double d;
    cin>>d;
    long double ans=d*d*d;
    double x=27.00;
    ans/=x;
    cout<<fixed<<setprecision(10)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))
 
#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("WA.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
#define sz(v)			((LL)v.size())
#define pi 				(acos(-1.0));
using namespace std;

char s[10];
int main(){ 
	
	scanf(" %s", s);
	LL mx = 0 , len = 0;
	for(LL i = 0 ; s[i] ; i++){
		if(s[i]=='S'){
			mx = max(mx,len);
			len = 0;
		}
		else len++;
	}
	mx = max(mx,len);
	cout<<mx<<endl;
	
	
return 0;}



Measured memory_bytes: 3772
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
#define M -1
using namespace std;
int dp[102][10001];
int value[101],weight[101];
int main(void)
{
	int n,w,i,j;
	cin>>n>>w;
	for(i=0;i<n;i++) cin>>value[i]>>weight[i];
	for(i=0;i<n;i++) {
		for(j=0;j<=w;j++) dp[i][j]=M;
	}
	dp[0][0]=0;
	for(i=0;i<n;i++) {
		for(j=0;j<=w;j++) {
			if(dp[i][j]!=M) {
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				if(j+weight[i]<=w) {
					dp[i+1][j+weight[i]]=max(dp[i][j]+value[i],dp[i+1][j+weight[i]]);
				}
			}
		}
	}
	int mx=-1;
	for(i=0;i<=w;i++) if(mx<dp[n][i]) mx=dp[n][i];
	cout << mx << endl;
	exit(0);
}

Measured memory_bytes: 5108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			while (a[i] % 2 == 0) {
				a[i] /= 2;
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 36040