akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <list>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

V solve(int n, V& ts, int m, V& ps, V& xs){
    V res(m);
    int s = accumulate(ts.begin(), ts.end(), 0);
    for(int i = 0; i < m; i++){
        res[i] = s - ts[ps[i] - 1] + xs[i];
    }
    return res;
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    V ts(n);
    for(int i = 0; i < n; i++){
        cin >> ts[i];
    }
    int m;
    cin >> m;
    V ps(m), xs(m);
    for(int i = 0; i < m; i++){
        cin >> ps[i] >> xs[i];
    }

    const V& us = solve(n, ts, m, ps, xs);
    for(int u : us){
        cout << u << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    string n;
    cin >> n;
    int K;
    cin >> K;
    int N = n.size();
    ll dp[105][2][105] = {0};

    dp[0][0][0] = 1;

    // i桁目まで走査した時、smallerで場合分けして、０以外の数が桁にj個含まれている個数。
    rep(i, N) {
        rep(j, N) {
            // 1から１への遷移
            dp[i + 1][1][j + 1] += dp[i][1][j] * 9; // i+1桁目が0以外
            dp[i + 1][1][j] += dp[i][1][j];         // i+1桁目が0

            // 0から1への遷移
            int ni = n[i] - '0';
            if (ni > 0) {
                dp[i + 1][1][j + 1] +=
                    dp[i][0][j] * (ni - 1); // i+1桁目がni以下かつ0でない
                dp[i + 1][1][j] += dp[i][0][j]; // i+1桁目が0
            }

            // 0から0への遷移
            if (ni > 0) {
                dp[i + 1][0][j + 1] += dp[i][0][j];
            } else if (ni == 0) {
                dp[i + 1][0][j] += dp[i][0][j];
            }
        }
    }

    cout << dp[N][0][K] + dp[N][1][K] << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String a = sc.next();
		String b = sc.next();
		
		if (a.length() == b.length()) {
			if (a.compareTo(b) == 0) {
				System.out.println("EQUAL");
			} else if (a.compareTo(b) > 0) {
				System.out.println("GREATER");
			} else {
				System.out.println("LESS");
			}
		} else {
			if (a.length() > b.length()) {
				System.out.println("GREATER");
			} else {
				System.out.println("LESS");
			}
		}
		
	}

    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 23124
X=int(input())

#まとめ　100で割った末尾
#01~05：100より大きければOK
#06~10：100代のみ不可
#11~15：100・200代のみ不可
#…

x=int(X//100)
P=int(((X%100)-1)//5)
if X%100==0:
	print(1)
elif x>P:
	print(1)
else:
	print(0)

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

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	String s=read();
	        		  	if(s.charAt(0)>='a'&&s.charAt(0)<='z'){
	        		  		out.write("a");
	        		  	}
	        		  	else{
	        		  		out.write("A");
	        		  	}

	        		  	
	        		  	//out.write(res+"");
                      out.flush();
	        		 
	}
}
	       

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

int main(){
	int N, i, now = 0, ans = 0;
	scanf("%d", &N);
	string S;
	cin >> S;
	for(i = 0; i < N; i++){
		if(S[i] == 'I'){
			now++;
		}
		else{
			now--;
		}
		ans = max(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION


void solve() {
    ll n, k, q;
    cin >> n >> k >> q;
    vll a; read(a, n, 0);
    ll ans = INF/2;

    for (auto x : a) {
        vvll split;
        int i = 0;
        while (i < n) {
            while (i < n && a[i] < x)
                i++;
            if (i >= n)
                break;

            split.push_back({});
            while (i < n && a[i] >= x) {
                split[split.size() - 1].push_back(a[i]);
                i++;
            }
        }

        vll all;

        for (auto v : split) {
            sort(v.begin(), v.end());
            int j = 0;
            while (j < (int)v.size() - k + 1) { // v.size() is unsigned integer
                all.push_back(v[j]);
                j++;
            }
        }

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

        if ((ll)all.size() >= q && all[0] == x)
            ans = min(ans, all[q - 1] - all[0]);
    }

    cout << ans << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

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

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


Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var result = false;
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    if (i * j == N)
                    {
                        result = true;
                        break;
                    }
                }
            }
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define reps(i, s, n) for (i64 i = s; i < (i64)(n); ++i)

void solve() {
    int n, k;
    cin >> n >> k;
    int ans = (k != 1 ? n - k : 0);
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3620
#include <stdio.h>
    #include <stdlib.h>
     
    int main() {
     
        int N,Y;
        int a,b,c,x,y,z;

        a = -1;
        b = -1;
        c = -1;

        scanf("%d %d",&N,&Y);
        for(x=0;x<=N;x++){
            for(y=0;y<=N;y++){
                z = N - x - y;
                if( (10000*x)+(5000*y)+(1000*z) == Y && z >= 0){
                    a = x;
                    b = y;
                    c = z;
                    break;
                }
            }
        }
        printf("%d %d %d",a,b,c);

        return 0;     
    }

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

#define el '\n'

int dp[3005][3005];

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

  string s, t;
  cin >> s >> t;
  
  for(int i = 0; i <= s.length(); i++){
    for(int j = 0; j <= t.length(); j++){
      dp[i][j] = 0;
    }
  }

  for(int i = 0; i < s.length(); i++){
    for(int j = 0; j < t.length(); j++){
      if(s[i]==t[j]){
        dp[i+1][j+1] = 1+dp[i][j];
      }else{
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }

  string ans = "";
  int i = s.length(), j = t.length();
  while(i>0 && j > 0){
    if(s[i-1]==t[j-1]){
      ans += s[i-1];
      i--;
      j--;
    }else{
      if(dp[i][j-1] > dp[i-1][j]){
        j--;
      }else{
        i--;
      }
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << el;

  return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    map<string,int> m;
    while(t--)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    for(string s:{"AC","WA","TLE","RE"}) cout << s << " x " << m[s] << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
//0101和1010匹配 
int main()
{
  string a;
  int ans1=0,ans2=0;
  cin>>a;
  string c="",d="";
  for(int i=0;i<a.size();i++)
  {
  	if(i%2==0)
  	{
  		c+="0";
	  }
  	else
  	{
  		c+="1";
	  }
  }
  for(int i=0;i<a.size();i++)
  {
  	if(i%2==1)
  	{
  		d+="0";
	  }
  	else
  	{
  		d+="1";
	  }
  }
  for(int i=0;i<a.size();i++)
  {
  	if(a[i]!=c[i])
  	{
  		ans1++;
	  }
  }
for(int i=0;i<a.size();i++)
  {
  	if(a[i]!=d[i])
  	{
  		ans2++;
	  }
  }
cout<<min(ans1,ans2); 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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



int main()
{

    int N;
    cin >> N;
    map<int, int>mp;

    for (int i = 2; i <= N; i++) {
        int x = i, a = 2;
        while (a*a<=x) {
            if (x%a == 0) {
                mp[a]++;
                x /= a;
            }
            else a++;
        }
        mp[x]++;
    }

    long long ans = 1;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans = (ans*(itr->second + 1)) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  vector<char> v;
  cin >> s;
  for(int i=0;i<26;i++){
    v.push_back('a'+i);
  }
  for(int i=0;i<s.length();i++){
    v[s[i]-'a'] = '0';
  }
  for(int i=0;i<26;i++){
    if(v[i] != '0'){
      cout << v[i];
      return 0;
    }
  }
  cout << "None";
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define gt first
#define gc second.first
#define gr second.second
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i,j,k;
	ll a[334][334],b[334][334],ans=0ll;
	bool flag = true,d[334][334];
	fill(d[0],d[334],true);
	cin >> n;
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			cin >> a[i][j];
			b[i][j] = a[i][j];
		}
	}
	for(k=0; k<n; ++k){
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				b[i][j] = min(b[i][j],b[i][k] + b[k][j]);
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			if(a[i][j] != b[i][j]){
				flag = false;
				break;
			}
		}
		if(!flag){
			break;
		}
	}
	if(!flag){
		cout << -1 << endl;
		return 0;
	}
	for(k=0; k<n; ++k){
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				if(i == k || k == j){
					continue;
				}
				if(a[i][j] == a[i][k] + a[k][j]){
					d[i][j] = false;
				}
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=i; j<n; ++j){
			if(d[i][j]){
				ans += a[i][j];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int>arr(n);
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	sort(arr.begin(),arr.end());
	while(k-- && arr.size()) arr.pop_back();
	long long total = 0;
	for(int i=0; i<arr.size(); i++) total+=arr[i];
	cout<<total;
}

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

int main()
{

	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		int n,h;
		cin>>n>>h;

		ll sum=0;
		int a[n];
		for (int i = 0; i < n; ++i)
		{
			cin>>a[i];
		}
		sort(a,a+n);

		if(n-h<0)
			cout<<0;
		else
		{
			for(int i=0;i<n-h;i++)
			{
				sum+=a[i];
			}
			cout<<sum;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
if __name__ == '__main__':
    n = int(input())
    count = 0
    if n < 10:
        print(n)
    elif n < 100:
        print(9)
    elif n < 1000:
        print(9 + n - 99)
    elif n < 10000:
        print(909)
    elif n < 100000:
        print(909 + n - 9999)
    elif n == 100000:
        print(90909)


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

void merge(int,int,int);
void mergeSort(int,int);

int *A,count=0;
int main()
{
  
  int n,i,left=0,mid,right;

  scanf("%d",&n);
  A=(int *)malloc(sizeof(int)*n);
  right=n;
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  mergeSort(left,right);

  for(i=0;i<n-1;i++) printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  printf("%d\n",count);

  return 0;
}

void mergeSort(int left,int right)
{
  int mid;
  
  if(left+1<right)
    {
      mid=(left+right)/2;
      mergeSort(left,mid);
      mergeSort(mid,right);
      merge(left,mid,right);
    }
}

void merge(int left,int mid,int right)
{
  int n1,n2,i,j,k;
  int *L,*R;

  n1=mid-left;
  n2=right-mid;

  L=(int *)malloc(sizeof(int)*n1+1);
  R=(int *)malloc(sizeof(int)*n2+1);
  
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1]=(int)INFINITY;
  R[n2]=(int)INFINITY;
  i=0;
  j=0;

  for(k=left;k<right;k++)
    {
      if(L[i]<=R[j])
	{
	  A[k]=L[i];
	  i=i+1;
    count++;
	}
      else
	{
	  A[k]=R[j];
	  j=j+1;
    count++;
	}
    }
}


Measured memory_bytes: 64432
from heapq import heappop, heappush

def getlist():
	return list(map(int, input().split()))

N, K = getlist()
V = getlist()
VV = [V[-1 - i] for i in range(N)]

ans = 0
for i in range(K + 1):
	if i == 0:
		pass
	elif i >= N:
		Q = []
		for j in V:
			heappush(Q, j)
		for j in range(K - N):
			if Q:
				if Q[0] < 0:
					heappop(Q)
				else:
					break
		val = sum(Q)
		if val > ans:
			ans = val

	else:
		for a in range(i + 1):
			Q = []
			b = i - a
			
			for x in range(a):
				heappush(Q, V[x])
			for x in range(b):
				heappush(Q, VV[x])
			for j in range(K - i):
				if Q:
					if Q[0] < 0:
						heappop(Q)
					else:
						break
			val = sum(Q)
			if val > ans:
				ans = val

print(ans)

Measured memory_bytes: 3188
def read_tokens():
    return input().strip().split(' ')

def read_ints():
    return [int(token) for token in read_tokens()]

n, = read_ints()
a = read_ints()


s = sum(a)
p = a[0]
ans = float('inf')

for i in range(1, len(a)):
    r = s - p
    ans = min(ans, abs(p - r))
    p += a[i]

print(ans)

Measured memory_bytes: 86492
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(int i=1;i<=n;i++)
#define   FOR(i,a,b)      for(int i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
#define   ret             return 
#define   sz(x)           (LL)x.size()
LL n,i,j,ans = 0;
string s ; 
LL dp[1000][1000] ; 
LL f[1000] ; 
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    cin>>n ; 
    string s ; 
    cin>>s ; 
    for(auto i:s) f[i-'a']++ ;
    ans = 1 ;  
    LL M = (LL)1E9+7 ; 
    for(int i=0;i<26;i++) 
    {  if(f[i]) ans = (ans * (f[i]+1))%M ; 

    }
    cout<<ans-1 ; 
}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        String O = sc.next();
        String E = sc.next();
        StringBuilder builder = new StringBuilder();
        for(int i=0; i<O.length(); i++){
            builder.append(O.charAt(i));
            if(O.length() > E.length() && i == O.length() - 1) break;
            builder.append(E.charAt(i));
        }
        System.out.println(builder.toString());
    }

    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 static 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: 22996
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}

int n;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }

  int b[3]={};
  int ans=1;
  rep(i,n){
    int s=0;
    rep(j,3){
      s+=(a[i]==b[j]);
    }
    ans=Mmul(ans,s);
    rep(j,3){
      if(a[i]==b[j]){
        b[j]++;
        break;
      }
    }
  }

  cout<<ans<<endl;



}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

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

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int a = max(n - k,0);

	sort(h.begin(), h.end());
	ll ans = 0;
	rep(i, a) ans += h[i];

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


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

long long n, i, x, ans;

int main()
{
    scanf("%lld", &n);
    long long a[n];
    for (i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        ans ^= a[i];
    }
    for (i = 0; i < n; i++) {
        if (i == 0) printf("%lld", ans^a[i]);
        else printf(" %lld", ans^a[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 5308
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main(void)
{
    int N, K;
    int i, j;
    int n;
    int MIN;
    vector<int> h(100010);
    vector<int> dp(100010, MOD);

    cin >> N;
    cin >> K;
    for (i = 1; i <= N; i++)
    {
        cin >> h[i];
    }

    dp[0] = dp[1] = 0;

    for (i = 2; i <= N; i++)
    {
        for (j = 1, MIN = MOD; j <= K; j++)
        {
            n = max(i - j, 1);
            int tmp = abs(h[i] - h[n]) + dp[n];
            if (MIN > tmp)
            {
                MIN = tmp;
            }
        }
        dp[i] = MIN;
    }

    cout << dp[N] << endl;
}

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

int main() {
	  int A,B,C,X;
	  while(cin>>A>>B>>C>>X){
	  	int count = 0;
 
	for (int a = 0; a <= A ; a++){
		for (int b = 0; b <= B ; b++){
			for (int c = 0; c <= C ; c++)
			{
				if(X == a*500 + b*100 + c*50)
					count += 1;
			}
		}
	}
	  	    printf("%d\n",count);
	  }
	
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
D,X = gets.split.map(&:to_i)
As = N.times.map{gets.to_i}
ans = X
As.each do |a|
    D.times do |day|
        eat = (a * day) + 1 
        ans += 1 if eat <= D
    end
end
puts ans


Measured memory_bytes: 1788
#include <stdio.h>

int main() {

    long long int N;
    scanf("%lld", &N);

    long long int s=N*(N+1)/2;

    long long int l1=N-N%3;
    long long int l2=N-N%5;
    long long int l3=N-N%15;

    long long int s1 = l1*(l1+3)/6;
    long long int s2 = l2*(l2+5)/10;
    long long int s3 = l3*(l3+15)/30;

    printf("%lld\n", s+s3-s1-s2);

    return 0;
}

Measured memory_bytes: 1684
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

MOD = 10 ** 9 + 7
n, k = map(int, raw_input().split())

m_comb = {}
m_pow = {}
m_inv = {}

def comb(N, K):
    if (N, K) in m_comb:
        return m_comb[(N, K)]
    if N == K or K == 0:
        m_comb[(N, K)] = 1
        return 1
    m_comb[(N, K)] = (comb(N - 1, K) + comb(N - 1, K - 1)) % MOD
    return m_comb[(N, K)]

def pow(N):
    if N in m_pow:
        return m_pow[N]
    ret = 1
    for i in range(n):
        ret *= N
        ret %= MOD
    m_pow[N] = ret
    return ret

def inv(N):
    if N in m_inv:
        return m_inv[N]
    pow_num = MOD - 2
    pow_cur = N
    ret = 1
    while pow_num > 0:
        if pow_num % 2 == 1:
            ret *= pow_cur
            ret %= MOD
        pow_cur *= pow_cur
        pow_cur %= MOD
        pow_num /= 2
    m_inv[N] = ret
    return ret

ans = pow(k)
sig = -1

for i in range(k - 1, 0, -1):
    ans += (comb(k, i) * pow(i) % MOD) * sig
    sig *= -1

for i in range(1, k + 1):
    ans *= inv(i)
    ans %= MOD

print ans



Measured memory_bytes: 96428
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	v := make([]int, n)
	for i := range v {
		v[i] = nextInt()
	}
	//fmt.Printf("v: %v\n", v)

	minK := min(n, k)

	ans := 0
	for r := 0; r <= minK; r++ {
		for l := 0; l <= minK-r; l++ {
			t := make([]int, 0, r+l)
			t = append(t, v[:l]...)
			t = append(t, v[n-r:]...)
			sort.Ints(t)
			//fmt.Printf("t: %v\n", t)

			remainingK := k - r - l
			sum := 0
			for _, v := range t {
				if v < 0 && remainingK > 0 {
					remainingK--
					continue
				}
				sum += v
			}
			ans = max(ans, sum)
		}
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
//a^n modをO(logN)で計算
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a-bをMODで割ったあまり、負にならない工夫
long long sub(long long a,long long b,int mod){
    long long ans = ((a%mod)-(b%mod))%mod;
    if(ans>=0){
        return ans;
    }
    else{
        return ans+mod;
    }
}
int main(){
    int n;
    cin>>n;//n桁の整数x
    string x;
    cin>>x;
    bitset<200001> bi(x);
    int dpop=bi.count();//最初の1の数
    int64_t NUMp=0,NUMm=0;
    //方針: popcは大した数じゃない(最大2*10^5)から、一回計算すれば整数型としてふつうに計算できる大きさになる
    //考えないといけないこと:1が1個しかない->そこを反転するとbit=0になって、操作0回で終わる
    //バカでかい数の余りを計算する abc164dを参考
    rep(j,n){
        NUMp += modpow(2,j,(dpop+1))*(bi.test(j))%(dpop+1);
        NUMp %= (dpop+1);
        if(dpop>1){
            NUMm += modpow(2,j,(dpop-1))*(bi.test(j))%(dpop-1);
            NUMm %= (dpop-1);   
        }
    }
    for(int i=n-1;i>=0;i--){
        int cnt=0;
        int popc;
        int64_t num;
        if(dpop==1 && bi.test(i)){
            cout<<0<<endl;
            continue;
        }
        if(bi.test(i)){//1を反転する->popc = dpop-1 -> NUMmを使う
            popc = dpop-1;
            num =  sub(NUMm,modpow(2,i,popc),popc);
            num %= popc; 
        }
        else{
            popc = dpop+1;
            num =NUMp + modpow(2,i,popc);
            num %= popc;
        }
        bi.flip(i);
        auto tmp = bi;
        //cout<<num<<endl;
        cnt=1;
        while(num!=0){
            bitset<18>  tbdiv(num);
            popc = tbdiv.count();
            num %= popc;
            cnt++;
        }
        cout<<cnt<<endl;
        bi.flip(i);
    }
}

Measured memory_bytes: 3680
from operator import itemgetter

N = int(input())
tasks = []
for i in range(N):
  A, B = list(map(int, input().split()))
  tasks += [[A, B]]
tasks = sorted(tasks, key=itemgetter(1))

minutes = 0
flag = True
for i in range(N):
  minutes += tasks[i][0]
  if minutes > tasks[i][1]:
    flag = False
    break
    
print('Yes' if flag else 'No')

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

using namespace std;

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

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

  if ((b - a - 1) % 2) {
    cout << "Alice\n";
  } else {
    cout << "Borys\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
#define pi pair<char,int>
signed main(){
  string s;
  cin>>s;
  map<char,int> m;
  for(auto c:s)++m[c];
  vector<pi> v;
  for(auto p:m)v.push_back(p);
  if(m.size()==1)return cout<<0,0;
  int res=s.size();
  for(int i=0;i<v.size();++i){
    int ml=0;
    for(int j=s.size()-1,cnt=0;j>=0;--j){
      if(s[j]==v[i].first)cerr<<"["<<v[i].first<<"]:"<<cnt<<"\n",cnt=0;
      else ++cnt;
      ml=max(ml,cnt);
    }
    res=min(res,ml);
  }
  cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,l,r) for (register int i=l; i<=r; i++)
using namespace std;
typedef unsigned long long LL;
typedef signed long long ll;
template <typename T>
inline void read(T &x) {
	char c = getchar(); int w = 1; x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}

int n, cnt = 0, ans = 0;
string s, a[200010];
map<string, int> M;
// inline bool cmp(string a, string b) {
//     return (strcmp(a, b) < 0);
// }
int main() {
    read(n);
    for (register int i=1; i<=n; ++i) {
        cin >> s; M[s] ++;
        if (M[s] > ans) {
            ans = M[s]; cnt = 0;
        }
        if (M[s] == ans) a[ ++ cnt ] = s;
    }
    std :: sort(a + 1, a + cnt + 1);
    for (register int i=1; i<=cnt; ++i)
        cout << a[i] << endl;
	getchar();
	return 0;
}

Measured memory_bytes: 26752
A, B, C, X, Y = map(int, input().split())
ans1 = max(X, Y)*2*C
ans2 = Y*2*C + (X-Y)*A if X>Y else X*2*C + (Y-X)*B
ans3 = A*X + B*Y
print(min(ans1, ans2, ans3))

Measured memory_bytes: 9068
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int res = A * X + B * Y;
	C *= 2;
	for (int i = 0; i <= max(X, Y); i++) {
		int total = C * i + A * max(0, X - i) + B * max(0, Y - i);
		res = min(res, total);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll _pow(ll a, ll n) {
	if(n==0) return 1;
	else {
		ll res = 1;
		ll buf = a;
		while(n>0) {
			if(n%2==1) {
				res *= buf;
				res %= MOD;
			}
			buf *= buf;
			buf %= MOD;
			n/=2;
		}
		return res;
	}
}

vector<ll> mod_fact(202020);
vector<ll> mod_inv(202020);
void init() {
	mod_fact[0] = 1;
	FOR(i, 1, 202020) {
		mod_fact[i] = mod_fact[i - 1] * i;
		mod_fact[i] %= MOD;
	}
	REP(i, 202020) mod_inv[i] = _pow(mod_fact[i], MOD - 2);
}

ll comb(ll n, ll k) {
	ll ret = mod_fact[n] * mod_inv[n - k]; ret %= MOD;
	ret *= mod_inv[k]; ret %= MOD;
	return ret;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	init();
	ll h, w, n;
	cin >> h >> w >> n;
	vector<pll> p(n);
	REP(i, n) {
		cin >> p[i].first >> p[i].second;
	}
	ll ans = comb(h - 1 + w - 1, h - 1);
	sort(ALL(p));
	vector<vector<ll>> dp(n, vector<ll>(2, 0));
	dp[0][0] = 0;
	dp[0][1] = comb(p[0].first - 1 + p[0].second - 1, p[0].first - 1); dp[0][1] %= MOD;
	FOR(i, 1, n) REP(j, 2) {
		for(ll k = 0; k < i; k++) {
			if(p[i].first < p[k].first || p[i].second < p[k].second) continue;
			ll coe = comb(p[i].first - p[k].first + p[i].second - p[k].second, p[i].first - p[k].first);
			coe %= MOD;
			dp[i][j] += dp[k][!j] * coe; dp[i][j] %= MOD;
		}
		if(j) dp[i][j] += comb(p[i].first - 1 + p[i].second - 1, p[i].first - 1); dp[i][j] %= MOD;
	}
	REP(i, n) REP(j, 2) {
		if(j) ans -= (dp[i][j] * comb(h - p[i].first + w - p[i].second, h - p[i].first)) % MOD;
		else ans += (dp[i][j] * comb(h - p[i].first + w - p[i].second, h - p[i].first)) % MOD;
		ans %= MOD;
	}
	cout << (ans % MOD + MOD) % MOD << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        string[] input = Read().Split(' ');
        int N = int.Parse(input[0]);
        int A = int.Parse(input[1]);
        int B = int.Parse(input[2]);
        int C = int.Parse(input[3]);
        int[] l = new int[N];
        for (int i = 0; i < N; i++)
        {
            l[i] = ReadInt();
        }
        int mp = -30;
        int al = 0, bl = 0, cl = 0;
        int minMp = int.MaxValue;
        for (int i = 0; i < Math.Pow(4, N); i++)
        {
            mp = -30;
            al = 0; bl = 0; cl = 0;
            int j = 0;
            int tmp = i;
            while (tmp != 0)
            {
                int k = tmp % 4;
                switch (k)
                {
                    case 1:
                        al += l[j];
                        mp += 10;
                        break;
                    case 2:
                        bl += l[j];
                        mp += 10;
                        break;
                    case 3:
                        cl += l[j];
                        mp += 10;
                        break;
                }
                j++;
                tmp /= 4;                    
            }
            if (al == 0 || bl == 0 || cl == 0) continue;
            mp += Math.Abs(A - al);
            mp += Math.Abs(B - bl);
            mp += Math.Abs(C - cl);
            if(mp < minMp)
            {
                minMp = mp;
            }
        }
        return minMp.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

ll a, b, c;
ll N;

void solve() {
    cin >> N;
    ll a[N];
    rep(i,N) cin >> a[i];
    ll s = 0;
    ll p = -1;
    ll ans = 0;
    rep(i,N) {
        if (p == a[i]) {
            s++;
        } else {
            ans += s/2;
            s = 1;
            p = a[i];
        }
    }
    ans += s/2;
    cout << ans << endl;
}

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：https://kimiyuki.net/writeup/algo/atcoder/arc-085-d/
・ミニマックス法
・メモ化再帰
・先手と後手にそれぞれのメモを作る
"""

import sys
from collections import defaultdict

# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)
 
N, Z, W = map(int, input().split())
aN = list(map(int, input().split()))

# 先手番用メモ[残り山札数][相手のスコア] = このルートでのmax
# 後手番用メモ[残り山札数][相手のスコア] = このルートでのmin
memo1 = [defaultdict(int) for _ in range(N+1)]
memo2 = [defaultdict(int) for _ in range(N+1)]

def dfs(turn, rest, x, y):
    if rest == 0:
        return abs(x - y)
    # 先手番
    if turn % 2 == 0:
        # 既に見た局面ならメモの内容を返す
        if memo1[rest][y]: 
            return memo1[rest][y]
        mx = -1
        for i in range(N-rest, N):
            x = aN[i]
            idx = i+1
            mx = max(dfs(turn+1, N-idx, x, y), mx)
        # ここより深い所を探し終わったので結果をメモする
        memo1[rest][y] = mx
        return mx
    # 後手番
    else:
        if memo2[rest][x]: 
            return memo2[rest][x]
        mn = float('inf')
        for i in range(N-rest, N):
            y = aN[i]
            idx = i+1
            mn = min(dfs(turn+1, N-idx, x, y), mn)
        memo2[rest][x] = mn
        return mn

print(dfs(0, N, Z, W))


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

int main() {
  int N,A;
  cin >> N;
  A = 0;
  vector<int> d(N);
  for(int i=0;i<N;i++){
  cin >> d.at(i);
   A++;
    for(int j=i-1;j>=0;j--){
     if(d.at(i) == d.at(j)){
       A--;
     break;
     }
    }
  }
  cout << A << endl;
  
}

Measured memory_bytes: 256
import numpy as np
nkq = list(map(int, (input().split())))
ans = [int(input()) for i in range(nkq[2])]
total = nkq[1] - nkq[2]
hold_point = np.array([total]*nkq[0])
for i in ans:
    hold_point[i - 1] += 1
for i in hold_point:
    if i <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 17876
// https://atcoder.jp/contests/abc077/tasks/abc077_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  ll n;

  cin >> n;

  cout << (ll)pow(floor(sqrt(n)), 2) << '\n';

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int ans = 700;
    string s;
    cin >> s;
    rep(i,s.size())
    {
        if(s[i]=='o')ans+=100;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <string.h>
#include <algorithm>
#include<cstdlib>
typedef long long ll;
using namespace std;

int main()
{
    ll n,a[200000],x = 0,y  = 0,lim= 9223372036854775807,ans=0;
    memset(a,0,sizeof(a));
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        ans += a[i];
    }

    for(int i = 0; i < n-1; i++)
    {
       x += a[i];
       if(abs(ans-2*x) <= lim)
       {
           lim = abs(ans-2*x);
       }
    }

    cout << lim << endl;
}

Measured memory_bytes: 1792
def parent(i)
  return i/2-1
end

def left(i)
  return i*2-1
end

def right(i)
  return i*2
end

def max_heapify(heap,i)
  l=left(i)
  r=right(i)

  if l < heap.length and heap[l] > heap[i-1]
    largest = l
  else
    largest = i-1
  end
  if r < heap.length and heap[r] > heap[largest]
    largest = r
  end

  if largest != i-1
    heap[i-1], heap[largest] = heap[largest], heap[i-1]
    max_heapify(heap, largest+1)
  end
end

def insert(heap, key)
  heap.push(key)
  i=heap.length
  while i > 1 and heap[parent(i)] < heap[i-1]
    heap[parent(i)], heap[i-1] = heap[i-1], heap[parent(i)]
    i = parent(i)+1
  end
end

def extract(heap)
  ret = heap[0]
  heap[0] = heap.pop
  max_heapify(heap, 1)
  return ret
end

heap=[]
line = STDIN.gets().split(" ")

until line[0]=="end"
  #p heap
  case line[0]
  when 'insert' then
    insert(heap, line[1].to_i)
  when 'extract' then
    print "#{extract(heap)}\n"
  end
  line = STDIN.gets().split(" ")
end

Measured memory_bytes: 16684
from fractions import gcd
from functools import reduce
import copy

n = int(input())
a = list(map(int,input().split()))

fValueList = []
lValueList = []
maxList = []

if n == 2:
  print(max(a[0], a[1]))
else:
  fValueList.append(a[0])
  lValueList.append(a[n-1])
  for i in range(1,n-1):
    g = fValueList[i-1]
    fValueList.append(gcd(g, a[i]))

  for i in range(1,n-1):
    g = lValueList[i-1]
    lValueList.append(gcd(g, a[n-1-i]))
  
  maxList.append(fValueList[n-2])
  maxList.append(lValueList[n-2])
  for k in range(n-2):
    g = gcd(fValueList[k], lValueList[n-3-k])
    maxList.append(g)
    
  print(max(maxList))


Measured memory_bytes: 16152
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a,b;
	while(cin>>a){
		cin >> b;
		int c = a+b;
		int n=0;
		while(c){
			n++;
			c/=10;
		}
		out(n);
	}
	return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
int main(void){
    int OH[5][4][11]={0},b,f,r,v=0,i,j,k,n;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        OH[b][f][r]+=v;
    }
    for(i=1;i<5;i++){
        for(j=1;j<4;j++){
            for(k=1;k<11;k++){
                printf(" %d",OH[i][j][k]);

            }
            printf("\n");
        }
        if(i<4)printf("####################\n");
    }
    return 0;
}

Measured memory_bytes: 1852
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
BC = [0 for _ in range(40)]
for a in A:
    for i, b in enumerate(bin(a)[2:].zfill(40)):
        if b == '0':
            BC[i] += 1
# print(BC)

ans = 0
for i in range(40):
    if BC[i] > N//2 and K >= 2**(39-i):
        K -= 2**(39-i)
        ans += 2**(39-i)*BC[i]
    else:
        ans += 2**(39-i)*(N-BC[i])
print(ans)


Measured memory_bytes: 69264
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int i,k,x;
  x = 0;
  for(i=1;i<=9;i++)
    for(k=1;k<=9;k++)
      if(i * k == N) x = 1;
  if(x == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

vector<pair<ll, int> > primeFactorize(ll x) {
  vector<pair<ll, int> > res;
  for (ll i = 2; i * i <= x; ++i) {
	if (x % i != 0) continue;
	res.emplace_back(i, 0);
	while (x % i == 0) {
	  x /= i;
	  res.back().second++;
	}
  }
  if (x != 1) res.emplace_back(x, 1);

  return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll a, b;
	cin >> a >> b;
	auto v = primeFactorize(gcd(a, b));
	cout << v.size() + 1 << endl;
	
    return 0;
}



Measured memory_bytes: 3664