akhauriyash/Code-Regression huggingface dataset:
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

   // Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int count = cin.nextInt();

    HashMap<Integer, Integer> even = new HashMap<Integer, Integer>();
    HashMap<Integer, Integer> odd = new HashMap<Integer, Integer>();
    for (int i = 0; i<count; i++) {
      int num = cin.nextInt();
      if (i%2==0) {
        if (even.containsKey(num)) {
          int temp = even.get(num);
          even.put(num, temp + 1);
        } else {
          even.put(num, 1);
        }
      }
      else {
        if (odd.containsKey(num)) {
          int temp = odd.get(num);
          odd.put(num, temp + 1);
        } else {
          odd.put(num, 1);
        }
      }
    }

    int firstEven = 0;
    int secondEven = 0;
    int firstEvenT = 0;
    int secondEvenT = 0;
    int firstOdd = 0;
    int secondOdd = 0;
    int firstOddT = 0;
    int secondOddT = 0;

    for (Map.Entry<Integer, Integer> entry : even.entrySet()) {
      int item = entry.getKey();
      int index = entry.getValue();
      if (index > firstEvenT) {
        secondEven = firstEven;
        secondEvenT = firstEvenT;
        firstEven = item;
        firstEvenT = index;
      }
      else if (index > secondEvenT) {
        secondEven = item;
        secondEvenT = index;
      }
    }

    for (Map.Entry<Integer, Integer> entry : odd.entrySet()) {
      int item = entry.getKey();
      int index = entry.getValue();
      if (index > firstOddT) {
        secondOdd = firstOdd;
        secondOddT = firstOddT;
        firstOdd = item;
        firstOddT = index;
      }
      else if (index > secondOddT) {
        secondOdd = item;
        secondOddT = index;
      }
    }

    //System.out.println(firstEven+" "+firstEvenT+" "+firstOdd+" "+firstOddT);
    //System.out.println(secondEven+" "+secondEvenT+" "+secondOdd+" "+secondOddT);

    if (firstEven != firstOdd) {
      System.out.println(count - firstEvenT - firstOddT);
    }
    else {
      if (firstEvenT > firstOddT) {
        System.out.println(count - firstEvenT - secondOddT);
      }
      else if (firstEvenT < firstOddT) {
        System.out.println(count - firstOddT - secondEvenT);
      }
      else if (firstEvenT == firstOddT) {
        int res = Math.min(count - firstEvenT - secondOddT, count - firstOddT - secondEvenT);
        System.out.println(res);
      }
    }

  }

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

const ll MX = 1e18;
ll dfs(map<ll,ll> &mp,ll n,ll a,ll b,ll c,ll d){
  if(mp.count(n) != 0)return mp[n];
  if(n == 1)return d;
  if(n <= 0)return 0;
  ll res = MX;
  if(MX/n >= d)res = d*n;
  res = min(res,dfs(mp,n/2,a,b,c,d)+(n & 1)*d+a);
  res = min(res,dfs(mp,n/3,a,b,c,d)+(n%3)*d+b);
  res = min(res,dfs(mp,n/5,a,b,c,d)+(n%5)*d+c);
  if(n & 1)res = min(res,dfs(mp,n/2+1,a,b,c,d)+(2-n%2)*d+a);
  res = min(res,dfs(mp,n/3+1,a,b,c,d)+(3-n%3)*d+b);
  res = min(res,dfs(mp,n/5+1,a,b,c,d)+(5-n%5)*d+c);
  return mp[n] = res;
}

int main(){
  
  int t;
  cin >> t;
  while(t--){
    ll n,a,b,c,d;cin >> n >> a >> b >> c >> d;
    map<ll,ll> mp;
    cout << dfs(mp,n,a,b,c,d) << endl;
  }

  


  
  


  return 0;
}

Measured memory_bytes: 4436
#include <stdio.h> 
#include <ctype.h> 
 
 
 int main(){ 
     int count[26]={0}; 
     char ch; 
     int i, num; 
 
 
     while(scanf("%c", &ch)!=EOF){ 
         if(islower(ch)){ 
             num=ch-'a'; 
         }else if(isupper(ch)){              num=ch-'A'; 
         }else{ 

             continue; 
         } 
         count[num]++; 
     } 
     for(i=0;i<26;i++){ 
         printf("%c : %d\n", 'a'+i, count[i]); 
     } 
 
 
     return 0; 
 } 



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	ll max_val = max(a, max(b, c));
	cout << 10 * max_val + a + b + c - max_val << endl;
}


Measured memory_bytes: 256
a, b, c, d = map(int,input().split())

if a == b:
    if b == c:
        print('Yes')
    elif abs(b - c) <= d:
        print('Yes')
    else:
        print('No')
elif abs(a - b) <= d:
    if b == c:
        print('Yes')
    elif abs(b - c) <=d:
        print('Yes')
    else:
        print('No')
elif a == c:
    print('Yes')
elif abs(a-c) <= d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61692
# -*- coding: utf-8 -*-
"""
E - Knapsack 2
https://atcoder.jp/contests/dp/tasks/dp_e

"""
import sys


def solve(N, W, items):
    limit = 0
    for w, v in items:
        limit += v
    dp = [float('inf')] * (limit+1)
    dp[0] = 0
    for w, v in items:
        for i in range(limit, -1, -1):
            if dp[i] != float('inf') and dp[i]+w <= W:
                dp[i+v] = min(dp[i+v], dp[i]+w)

    ans = [i for i, d in enumerate(dp) if d != float('inf')]
    return max(ans)


def main(args):
    N, W = map(int, input().split())
    items = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, W, items)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 79292
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL n, a, b;
	cin >> n >> a >> b;
	LL low = n * a + (b - a);
	LL high = n * b + (a - b);
	LL ans = max(0LL, high - low + 1);
	if (n <= 1 && a != b) {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
*p,=map(int,input().split())
*q,=map(int,input().split())
if p==q:
    print(0)
else:
    import itertools
    l2=[]
    for i in itertools.permutations([i+1 for i in range(n)]):
        l2.append(list(i))
    print(abs(l2.index(p)-l2.index(q)))

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int n,a,b,c,ans;
vector<int> l;
int dfs(int cnt, int x, int y, int z)
{
    if(cnt==n)
    {
        if(x==0||y==0||z==0) return 1e9+7;
        else
        {
            int ret = abs(a-x)+abs(b-y)+abs(c-z);
            return ret;
        }        
    }
    else
    {
        int ret0 = dfs(cnt+1,x,y,z);
        int ret1 = dfs(cnt+1,x+l[cnt],y,z)+10;
        int ret2 = dfs(cnt+1,x,y+l[cnt],z)+10;
        int ret3 = dfs(cnt+1,x,y,z+l[cnt])+10;
        int ret = min(min(ret0,ret1),min(ret2,ret3));
        return ret;
    }
    
}

int main(){
    ans=1e9+7;
    cin>>n>>a>>b>>c;
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin>>tmp;
        l.push_back(tmp);
    }
    ans = dfs(0,0,0,0);
    
    cout<<ans-30<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=200002;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 
 
ll int power(ll int a,ll int b)
{
	ll int ans=1,f=a;
	while(b)
	{
		 if(b&1)
		 ans=(ans*f)%mod;
		 b=b>>1;
		 f=(f*f)%mod;
	}
	return ans%mod;
}

int main()
{
   ll int a;
   cin>>a;
   veci v;
   v.pb(1);
   fo(i,1,30)
   v.pb(v.back()+i+1);
   int ans=0;
   ll int cr=a;
   for(ll int i=2;i*i<=a;i++)
   {
       int cnt=0;
       while(cr%i==0)
       {
           cr=cr/i;
           cnt++;
       }
       int y=ub(all(v),cnt)-v.bg;
       ans+=y;
   }
   if(cr!=1)
   {
       ans+=1;
   }

   
   cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back

#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int N=((1e9)+7);

signed main()
{
    int n;cin>>n;
    int fact=1;
    for(int i=2;i<=n;++i){fact*=i;fact%=N;}
    string str;cin>>str;
    int forw=0;
    int ans=1;
    int prev=1;
    for (int i = 0; i < 2*n; ++i)
    {
    	/* code */
    	if(forw==0)
    	{
    		if(str[i]=='B'){++forw;prev=1;}
    		else
    		{
    			cout<<0;return 0;
    		}
    	}
    	else
    	{
    		prev=((str[i]!=str[i-1]?1:-1)*prev);
    		if(prev==1)
   			{
   				++forw;
   			}
   			else
   			{
   				if(forw==0){cout<<0;return 0;}
    			ans*=forw;ans%=N;
    			--forw;
    		}
    	}
    }
    if(forw==0)
    {
    	cout<<((ans*fact)%N);return 0;
    }
    else
    {
    	cout<<0;return 0;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 200100;
int n, a, b, c, d;
char s[maxn];
bool can(int x, int y)
{
	if(s[x] == '#' || s[y] == '#')
		return 0;
	for(int i = x + 1; i <= y; i ++)
		if(s[i] == '#' && s[i - 1] == '#')
			return 0;
	return 1;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n >> a >> b >> c >> d;
	cin >> (s + 1);
	if(c < d)
	{
		if(can(b, d) && can(a, c))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
		return 0;
	}
	if(!can(a, c))
	{
		cout << "No" << endl;
		return 0;
	}
	for(int i = b; i <= d; i ++)
		if(s[i - 1] != '#' && s[i + 1] != '#' && s[i] != '#')
		{
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<set>
#define RI  int
#define CI const int&
using namespace std;
int n,x,ans; multiset <int> s; vector <int> tp;
int main()
{
	RI i; for (scanf("%d",&n),i=1;i<=n;++i) scanf("%d",&x),s.insert(x);
	for (i=(1<<30);i>1;i>>=1)
	{
		tp.clear(); while (s.size()>=2)
		{
			multiset <int>:: iterator it=s.end(); x=*(--it);
			if (x>=i) { s.erase(it); continue; } s.erase(it);
			if (s.count(i-x)) ++ans,s.erase(s.find(i-x)); else tp.push_back(x);
		}
		for (vector <int>:: iterator it=tp.begin();it!=tp.end();++it) s.insert(*it);
	}
	return printf("%d",ans),0;
}

Measured memory_bytes: 13252
def main():
    card_num = int(input())
    cards = list(map(int, input().split()))
    count = {}
    for card in cards:
        if card in count:
            count[card] += 1
        else:
            count[card] = 1
    answer = 0
    for c in list(count.values()):
        if c > 1:
            answer += c - 1
    if answer % 2:
        answer += 1
    print(card_num - answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 18272
<?php
$n = fgets(STDIN);
for ($i = 0; $i < $n; $i++) {
    list($a, $b, $c) = explode(" ", fgets(STDIN));
    $a *= $a;
    $b *= $b;
    $c *= $c;
    echo ($a + $b === $c | $a + $c === $b| $b + $c === $a) ? "YES\n" : "NO\n";
}


Measured memory_bytes: 9232
import sys

input = sys.stdin.readline

def calc(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n //= 10
    return sum

def main():
    ans = 0
    N, A, B = map(int, input().split())
    for i in range(1, N+1):
        temp = calc(i)
        if A <= temp <= B:
            ans += i

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif
int K, L;
std::vector<int> ans;

void Prev() {
	if (ans.back() == 1) {
		ans.pop_back();
		return;
	}
	--ans.back();
	while (ans.size() < L) {
		ans.push_back(K);
	}
}

int main() {
	cin >> K >> L;
	if (K % 2 == 0) {
		ans.push_back(K / 2 + 1);
		Prev();
	} else {
		REP(z, 0, L) {
			ans.push_back((K + 1) / 2);
		}
		REP(z, 0, L / 2) {
			Prev();
		}
	}
	REP(i, 0, ans.size()) {
		cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
	}
	return 0;
}

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

int main(){
  int n; cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  const int M = 1000005;
  vector<int> cnt(M);
  for(int x : a){
    if(cnt[x]!=0){
      cnt[x] = 2;
      continue;
    }
    for(int i = x; i<M; i+=x) cnt[i]++;
  }
  int ans = 0;
  for(int x : a){
    if(cnt[x]==1) ans++;
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 7996
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,k,cnt=0;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
        if(h[i]>=k)
            cnt++;
    }
    cout<<cnt;
    
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

template <typename M>
class SegmentTree {
   public:
    using value_type = typename M::type;

    explicit SegmentTree(int64_t n)
            : n(n), cap(pow(2, ceil(log2(n)))), values(2 * cap - 1, +M::id) {}

    void set(int64_t pos, value_type v) {
        int64_t idx = cap - 1 + pos;
        values[idx] = v;
        while (idx > 0) {
            idx = (idx - 1) / 2;
            fix_value(idx);
        }
    }

    value_type query(int64_t a, int64_t b) { return query(a, b, 0, 0, cap); }

    value_type query(int64_t a, int64_t b, int64_t idx, int64_t l, int64_t r) {
        if (a >= r || b <= l) {
            // no overlap
            return M::id;
        }

        if (a <= l && r <= b) {
            return get_node_value(idx);
        }

        auto left_idx = 2 * (idx + 1) - 1;
        auto right_idx = 2 * (idx + 1);

        fix_value(idx);

        auto left_v = query(a, b, left_idx, l, (l + r) / 2);
        auto right_v = query(a, b, right_idx, (l + r) / 2, r);

        return M::op(left_v, right_v);
    }

   private:
    value_type get_node_value(int64_t idx) { return values[idx]; }

    void fix_value(int64_t idx) {
        auto left_idx = 2 * (idx + 1) - 1;
        auto right_idx = 2 * (idx + 1);
        values[idx] =
                M::op(get_node_value(left_idx), get_node_value(right_idx));
    }

    int64_t n;
    int64_t cap;
    vector<value_type> values;
};

struct Sum {
    using type = int64_t;
    static constexpr auto id = 0L;

    static type op(type v1, type v2) { return v1 + v2; }
};

using ST = SegmentTree<Sum>;

int main() {
    int64_t n;
    cin >> n;

    string s;
    cin >> s;

    vector<ST> st(26, ST(n));

    for (auto i : irange(0L, n)) {
        st[s[i] - 'a'].set(i, 1);
    }

    int64_t q;
    cin >> q;

    for (auto _ : irange(0L, q)) {
        int64_t t;
        cin >> t;
        if (t == 1) {
            int64_t i;
            char c;
            cin >> i >> c;
            --i;

            st[s[i] - 'a'].set(i, 0L);
            s[i] = c;
            st[s[i] - 'a'].set(i, 1L);
        } else {
            int64_t l, r;
            cin >> l >> r;
            --l;
            --r;

            int64_t ans = 0;
            for (auto i : irange(0L, 26L)) {
                if (st[i].query(l, r + 1) > 0) {
                    ++ans;
                }
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 222212
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x


using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int n;cin>>n;
    string s;cin>>s;
    
    int c[128];
    rep(i,128){
        c[i]=1;
    }
    
    for(char j:s){
        c[j]++;
    }
    
    ll out = 1;
    
    for(auto j = 'a'; j<='z';j++){
        out *= c[j];
        out%=MOD;
    }
    
    cout<<out-1<<endl;
    
    
    
    
    return 0;
    
    
}




Measured memory_bytes: 512
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

char cx[6];
int ketax;
inline void putx() {
	for (int i = ketax - 1; i >= 0; i--)* di++ = (*(cx + i));
	*di++ = '\n';
}

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


	int K, X, Y;
	scanf("%d", &K);
	scanf("%d", &X);
	scanf("%d", &Y);

	vector<pair<int, int>> kotae;
	int m = abs(X) + abs(Y);
	int xpn, ypn;

	if (K == 1) {
		putint(X + Y);
		rep1(i, X) {
			putint(i);
			*di++ = '0';
			*di++ = '\n';
		}
		if (X == 0) {
			*cx = '0';
			ketax = 1;
		}
		while (X) {
			*(cx + ketax) = '0' + X % 10;
			X /= 10;
			ketax++;
		}
		rep1(i, Y) {
			putx();
			putint(i);
		}
		fwrite(dn, 1, di - dn, stdout);
		Would you please return 0;

	}

	if (K % 2 == 0 && m % 2) {
		printf("-1");
		return 0;
	}


	while (m / K >= 2) {
		if (abs(X) < abs(Y)) {
			ypn = (Y >= 0) ? 1 : -1;
			kotae.pb(mp(0, ypn * K));
			Y -= ypn * K;
		}
		else {
			xpn = (X >= 0) ? 1 : -1;
			kotae.pb(mp(xpn * K, 0));
			X -= xpn * K;
		}
		m = abs(X) + abs(Y);
	}
	if (m == K) {
		kotae.pb(mp(X, Y));
	}
	else {
		if (m & 1) {
			if (abs(X) < abs(Y)) {
				ypn = (Y >= 0) ? 1 : -1;
				kotae.pb(mp(0, ypn * K));
				Y -= ypn * K;
			}
			else {
				xpn = (X >= 0) ? 1 : -1;
				kotae.pb(mp(xpn * K, 0));
				X -= xpn * K;
			}
		}

		int yorimiti = (2 * K - abs(X) - abs(Y)) / 2;
		if (abs(X) < abs(Y)) {
			xpn = (X >= 0) ? 1 : -1;
			ypn = (Y >= 0) ? 1 : -1;

			kotae.pb(mp(X + xpn * yorimiti, ypn * (K - abs(X + xpn * yorimiti))));
			Y -= ypn * (K - abs(X + xpn * yorimiti));
			X -= X + xpn * yorimiti;
			kotae.pb(mp(X, Y));
		}
		else {
			xpn = (X >= 0) ? 1 : -1;
			ypn = (Y >= 0) ? 1 : -1;
			kotae.pb(mp(xpn * (K - abs(Y + ypn * yorimiti)), Y + ypn * yorimiti));
			X -= xpn * (K - abs(Y + ypn * yorimiti));
			Y -= Y + ypn * yorimiti;
			kotae.pb(mp(X, Y));
		}
	}

	putint(kotae.size());
	int xp = 0, yp = 0;;
	rep(i, kotae.size()) {
		xp += kotae[i].first;
		yp += kotae[i].second;
		if (xp == 0) {
			*di++ = '0';
			*di++ = '\n';
		}
		else putint(xp);
		if (yp == 0) {
			*di++ = '0';
			*di++ = '\n';
		}
		else putint(yp);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
	int huyu;
	int japanese;
	int math;
	int st_jap;
	int st_math;
	int jap_ans = 0;
	int mat_ans = 0;
	scanf("%d%d%d%d%d", &huyu, &japanese, &math, &st_jap, &st_math);

	while (1){
		if (japanese <= 0) break;
		japanese -= st_jap;
		jap_ans++;
	}
	while (1){
		if (math <= 0) break;
		math -= st_math;
		mat_ans++;
	}
	printf("%d\n", huyu - max(jap_ans, mat_ans));
	return 0;
}

Measured memory_bytes: 2688
// Aizu Vol-2 0266: Aka-beko and 40 Thieves
// 2017.8.6

#include <stdio.h>
#include <ctype.h>

char *gets();
char buf[150], *p;

int e[6][2] = {
	{ 1, 2 }, { -1, 3 }, { 1, -3 }, { 4, 5 }, { 5, 2 }, { 2, 1 } };

int main()
{
	int s;

	while (1) {
		gets(p = buf); while (isspace(*p)) p++;
		if (*p == '#') break;
		s = 0;
		while (*p) {
			if (*p == '0') { if ((s = e[s][0]) < 0) goto NO; }
			else { if ((s = e[s][1]) < 0) goto NO; }
			p++;
		}
		if (s != 5) {
NO:			puts("No");
		} else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans;
  ans = 10000000;
  cin >> n;
  vector<int>a(n);
  vector<int>b(201);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<201;i++){
    for(int j=0;j<n;j++) b.at(i) += (a.at(j)-i+100)*(a.at(j)-i+100);
  }
  sort(b.begin(),b.end());
  cout << b.at(0) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
map<string, int> mol;
int mole(string s,int &idx) {
	int sum = 0;
	while (idx < s.length()) {
		if (s[idx] == '(') {
			idx++;
			int a = mole(s, idx);
			if (a == -1)
				return -1;
			int b = 0;
			while (isdigit(s[idx])) {
				b *= 10;
				b += s[idx] - '0';
				idx++;
			}
			sum += a*b;
		}
		if (s[idx] == ')') {
			idx++;
			return sum;
		}
		if ('A' <= s[idx] && s[idx] <= 'Z') {
			string s2 = "";
			s2 += s[idx];
			idx++;
			if (idx < s.length() && 'a' <= s[idx] && s[idx] <= 'z') {
				s2 += s[idx];
				idx++;
			}
			if (mol.find(s2) == mol.end())
				return -1;
			int b = 0;
			while (isdigit(s[idx])) {
				b *= 10;
				b += s[idx] - '0';
				idx++;
			}
			if (b == 0)
				b = 1;
			sum += mol[s2] * b;
		}
	}
	return sum;
}

int main() {
	string s;
	
	while (cin >> s, s != "END_OF_FIRST_PART") {
		int a;
		cin >> a;
		mol[s] = a;
	}
	while (cin >> s, s != "0")
	{
		int idx = 0;
		int ans = mole(s, idx);
		if (ans == -1)
			cout << "UNKNOWN" << endl;
		else
			cout <<ans << endl;
	}
}

Measured memory_bytes: 3172
/*
 * author: Tran Minh Khoa
 * Ho Chi Minh University of Science
 */

#include <bits/stdc++.h>

using namespace std;

const int inf = (int) 1e9 + 7;
const long long INF = (long long) 1e18 + 7;

const int N = 123456;
const int M = 1010;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sqrt(x) (x) * (x)

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(x) cerr << #x << " = " << x << '\n';
#define PR(x, a, b) { cerr << #x << " = "; REP(i, a, b) cerr << x[i] << ' '; cerr << '\n'; }
                 
int main() {
  #ifdef KM777
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr); cout.tie(nullptr);

  string s;
  cin >> s;
  int n = sz(s);
  int result = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (s[j] == 'A' || s[j] == 'T' || s[j] == 'G' || s[j] == 'C') {
        result = max(result, j - i + 1);
      } else {
        break;
      }
    }
  }
  cout << result << '\n'; 
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	int r=-1;
	int c=max(a,b);
	int d=min(a,b);
	while (1)
	{
		r=c%d;
		if(r==0){
			return d;
		}else{
			c=d;
			d=r;
		}
	}
}
int main() {
	int K;
	cin >>K;
	int sum=0;
	for (int i = 1; i < K+1; i++){
		for (int j = 1; j < K+1; j++){
			for (int k = 1; k < K+1; k++){
				sum+=gcd(gcd(i,j),k);
			}
		}
	}
	cout<<sum<<endl;;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(){

  int a, b, c;

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

   if(a<b && b<c){
      printf("Yes\n");
   } else if(a>b || b>c || a==b || b==c){
	    printf("No\n");
	    }

return 0;

}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
#define MK make_pair
#define PB push_back
using namespace std;

typedef long long LL;
typedef pair<int ,int> PII;
const int N=2e5+10;

int a[N],n,k, pre[N];
set<int> s;
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d%d", &n, &k);
	for (int i=1; i<=n; ++i){
		scanf("%d", a+i);
		if ( i>1) pre[i] =pre[i-1] + (a[i]<a[i-1]);
		#ifdef che
		debug("pre[%d]= %d\n",i, pre[i]);
		#endif
	}
	int ans=n-k+1,ords=(pre[k]==pre[1]);
	for (int i=1; i<=k; ++i) s.insert(a[i]);
	for (int i=k+1; i<=n; ++i){
		s.insert(a[i]);
		if ( (*s.begin())==a[i-k] && *(--s.end())==a[i])--ans;
			else ords += (pre[i]==pre[i-k+1]);
		s.erase(a[i-k]);
		#ifdef che
		debug("i=%d, ans=%d, ords=%d\n", i, ans, ords);
		#endif
	}
	#ifdef che
	for (int i=1; i+k-1<=n;++i){
		int b[100];
		for (int j=1; j<=n; ++j) b[j]=a[j];
		sort(b+i,b+i+k);
		for (int j=1; j<=n; ++j) debug("%d ", b[j]);
		debug("\n");
	}
	#endif
	printf("%d\n", ans-max(0,(ords-1)));
	return 0;
}

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

using namespace std;

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  int cntA = 0, cntB = 0, cntC = 0;
  for (int i = 0; i < N; i++)
  {
    int P;
    cin >> P;
    if (P <= A)
      cntA++;
    else if (P <= B)
      cntB++;
    else
      cntC++;
  }
  cout << min({cntA, cntB, cntC}) << endl;

  return 0;
}


Measured memory_bytes: 256
///
// File:  alds1_4_a.cpp
// Author: ymiyamoto
//
// Created on Sat Oct  7 19:00:24 2017
//

#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

static vector<uint64_t> S;

int32_t main()
{
  uint32_t n, q;
  cin >> n;

  for (uint32_t i = 0; i < n; i++) {
    uint64_t val;
    cin >> val;
    S.push_back(val);
  }

  uint64_t count = 0;
  cin >> q;
  for (uint32_t i = 0; i < q; i++) {
    uint64_t val;
    cin >> val;
    for (uint32_t j = 0; j < S.size(); j++) {
      if (val == S[j]) {
        count++;
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3188
# スペース区切りの整数の入力
S = str(input())

front = S[0]+S[1]
rear = S[2]+S[3]

front=int(front)
rear=int(rear)

if (front==0 and rear==0) or (front>12 and rear>12) or (front==0 and rear>12) or (rear==0 and front>12):
  print("NA")
elif front<=12 and front!=0 and rear<=12 and rear!=0 :
  print("AMBIGUOUS")
elif rear<=12 and rear!=0:
  print("YYMM")
else:
  print("MMYY")

  #YYMM MMは12以下 
  #MMYY MMは12以下
  #AMBIGUOUS 両方とも00を含まない、12以下
  #NA 00を含む、両方とも13以上

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


S = s_in()

if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print("No")


Measured memory_bytes: 38256
// ayy
// ' lamo
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld; //CARE
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
const ld eps=1e-8;
const int inf=1e9+99;
const ll linf=1e18+99;
const int P=1e9+7;













int32_t main() {
	int n; scanf("%d",&n);
	static int a[12];
	for(int i=0;i<n;i++) scanf("%d",a+i);
	int Z=1;
	int O=1;
	for(int i=0;i<n;i++) Z*=3;
	for(int i=0;i<n;i++) if(a[i]%2==0) O*=2;
	cout<<Z-O<<endl;
}













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

const int MAXN = 50000 + 10;
const double pi = acos(-1.0);
const double inf = 1e100;
const double eps = 1e-12;

struct vec { //点的基本数据结构
    double x, y;
    vec(double x, double y)
    {
        this->x = x;
        this->y = y;
    }
    vec() {}
    vec operator*(const vec& i_T) const
    {
        return vec(x * i_T.x, y * i_T.y);
    }
    vec operator*(double u) const
    {
        return vec(x * u, y * u);
    }
    bool operator==(const vec& i_T) const
    {
        return x == i_T.x && y == i_T.y;
    }
    vec operator/(double u) const
    {
        return vec(x / u, y / u);
    }
    vec operator+(const vec& i_T)
    {
        return vec(x + i_T.x, y + i_T.y);
    }
    vec operator-(const vec& i_T)
    {
        return vec(x - i_T.x, y - i_T.y);
    }
    friend bool operator<(vec a, vec b)
    {
        return a.y == b.y ? a.x < b.x : a.y < b.y;
    }
    friend ostream& operator<<(ostream& out, vec& a)
    {
        //cout << a.x << ' ' << a.y;
        printf("%.8f %.8f", a.x, a.y);
        return out;
    }
    friend istream& operator>>(istream& in, vec& a)
    {
        in >> a.x >> a.y;
        return in;
    }
};
struct cirles {
    vec o;
    double r;
    friend istream& operator>>(istream& in, cirles& a)
    {
        in >> a.o >> a.r;
        return in;
    }
    friend ostream& operator<<(ostream& out, cirles& a)
    {
        out << a.o << ' ' << a.r;
        return out;
    }
};
double changdu(vec a) //向量长度
{
    return sqrt(a.x * a.x + a.y * a.y);
}
pair<vec, vec> yuan_yuan_jiaodian(cirles a, cirles b)
{
    double l = changdu(a.o - b.o);
    double x = acos((a.r * a.r + l * l - b.r * b.r) / (2.0 * a.r * l));
    double t = atan2((b.o - a.o).y, (b.o - a.o).x);
    return make_pair(a.o + vec(cos(t - x) * a.r, sin(t - x) * a.r), a.o + vec(cos(x + t) * a.r, sin(t + x) * a.r));
}
int dayu_dengyu(double x, double y)
{
    if (fabs(x - y) < eps || x > y)
        return 1;
    return 0;
}
int main()
{
    //freopen("txt.txt", "w", stdout);
    cirles a, b;
    cin >> a >> b;
    pair<vec, vec> q = yuan_yuan_jiaodian(a, b);
    if (fabs(q.first.x - q.second.x) < eps) {
        if (dayu_dengyu(q.first.y, q.second.y))
            cout << q.second << ' ' << q.first << endl;
        else
            cout << q.first << ' ' << q.second << endl;
    } else if (dayu_dengyu(q.first.x, q.second.x))
        cout << q.second << ' ' << q.first << endl;
    else
        cout << q.first << ' ' << q.second << endl;

    return 0;
}


Measured memory_bytes: 3708
/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long K = Long.parseLong(st.nextToken());
         if((N+K)%2 == 1)
            System.out.println("IMPOSSIBLE");
         else
            System.out.println((N+K)/2);
      }
   }

Measured memory_bytes: 22484
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

string S;
int f(int x, int y, int z, int w) {
	dump(x, y, z);
	if (x == 4) {
		if (y == S.size()) {
			return 1;
		}
		else {
			return 0;
		}
	}
	else {
		if (y == S.size())
			return 0;
	}
	z *= 10;
	z += S[y] - '0';
	if (z > 255)
		return 0;
	
	int ret = 0;
	ret += f(x + 1, y + 1, 0, 0);
	if (z == 0 && w == 0)
		return ret;
	ret += f(x, y + 1, z, w + 1);
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> S;
	cout << f(0, 0, 0, 0) << endl;
	return 0;
}


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


int main(){
	
	int h,w;
	cin>>h>>w;

	char s[60][60];

	for (int i = 0; i < w+2; ++i)
	{
		s[0][i]='.';
		s[h+1][i]='.';
	}
	for (int i = 0; i < h+2; ++i)
	{
		s[i][0]='.';
		s[i][w+1]='.';
	}

	for (int i = 1; i < h+1; ++i)
	{
		for (int j = 1; j < w+1; ++j)
		{
			cin>>s[i][j];
		}
	}

	

	char ans[60][60];

	for (int i = 1; i < h+1; ++i)
	{
		for (int j = 1; j < w+1; ++j)
		{
			if(s[i][j]=='#'){
				ans[i][j]='#';
			}else{
				int sum=0;
				if(s[i-1][j-1]=='#') sum+=1;
				if(s[i-1][j]=='#') sum+=1;
				if(s[i-1][j+1]=='#') sum+=1;
				if(s[i][j-1]=='#') sum+=1;
				if(s[i][j+1]=='#') sum+=1;
				if(s[i+1][j-1]=='#') sum+=1;
				if(s[i+1][j]=='#') sum+=1;
				if(s[i+1][j+1]=='#') sum+=1;
				ans[i][j]='0'+sum;


			}
		}
	}

	for (int i = 1; i < h+1; ++i)
	{
		for (int j = 1; j < w+1; ++j)
		{
			cout<<ans[i][j];
		}
		if(i!=h+1)	cout<<endl;
	}


return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int N;
    cin >> N;
    long long ans = 0;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        ans += a;
    }
    ans -= N;
    cout << ans << endl;
}


Measured memory_bytes: 3112
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0)); 
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int N,A,B;
ll h[100010];

bool check(ll t){
    ll cnt=0;
    rep(i,N){
        ll rem = h[i]-B*t;
        if(rem > 0) cnt += (rem + (A-B) - 1) / (A-B);
    }
    return cnt <= t;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    cin >> N >> A >> B;
    rep(i,N) cin >> h[i];
    sort(h,h+N,greater<int>());

    ll l=0, r=1e9;
    while(l<r){
        int m = (l+r)/2;
        if(check(m)) r=m;
        else l=m+1;
    }
    cout << l << endl;

    return 0;
}


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

int findSumOfDigits(int n)
{
    int sum = 0;
    while (n > 0)
    { // n が 0 になるまで
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;

    for (int i = 1; i <= N; i++)
    {
        int s = findSumOfDigits(i);
        if (A <= s && s <= B)
            total += i;
    }

    cout << total << endl;
}


Measured memory_bytes: 3580
use proconio::{fastout, input};

// x 以下ではない最小のインデックスを返す
fn lower_bound(arr: &[isize], x: isize, first: usize, last:usize) -> usize {
    let mut first = first;
    let mut last = last;
    while first < last {
        let mid = first + (last - first) / 2;
        if x <= arr[mid] {
            last = mid;
        } else {
            first = mid + 1;
        }
    }
    // first -- x -- last
    first
}
// xより大きい最小のインデックスを返す
fn upper_bound(arr: &[isize], x: isize, first: usize, last:usize) -> usize {
    let mut first = first;
    let mut last = last;
    while first < last {
        let mid = first + (last - first) / 2;
        if x >= arr[mid] {
            first = mid + 1;
        } else {
            last = mid;
        }
    }
    // first -- x -- last
    first
}
#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [isize; n],
        mut b: [isize; n],
        mut c: [isize; n]
    }
    a.sort();
    c.sort();
    let mut sum = 0;
    for bb in b {
        let lower_a = lower_bound(&a, bb, 0, n);
        let upper_c = upper_bound(&c, bb, 0, n);
        sum += lower_a * (n-upper_c);
    }

    println!("{}", sum);
}


Measured memory_bytes: 7728
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }

        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let line = read_as_vec::<i32>();

    let (a, b) = (line[0], line[1]);

    if a - b*2 > 0{
        println!("{}", a - b*2);
    }else{
        println!("0");
    }
}


Measured memory_bytes: 4352
#include  <stdio.h>
//#include
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN+1];
int head, tail, n;


void enqueue(P x){
  Q[tail] = x;
  tail++;
  if (tail == LEN) tail = 0;
}

P dequeue(){
  int retdata = head;
  head++;
  if (head == LEN) head = 0;
  return (Q[retdata]);
}


int main()
{
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++)
  {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = i;
  //\BD\E8\CD\FD\B3\AB\BB\CF
  
  while(1)
  {
    u = dequeue();
    u.t -= q;
    if (u.t > 0)
    {
      enqueue(u);
      elaps += q;
    }else{
      elaps += u.t + q;
      printf("%s %d\n", u.name, elaps);
    }

    if (tail == head) break;
  }

  
  return 0;
}




Measured memory_bytes: 11956
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] array = new int[N];
    for(int i=0; i<N; i++){
      array[i] = sc.nextInt();
    }
    
    int m = array[0];
    for(int i=1; i<array.length; i++){
      int n = array[i];
      if(n > m){
        int l = m;
        m = n;
        n = l;
      }
      while(true){
        int r = m%n;
        if(r == 0){
          m = n;
          break;
        }
        m = n;
        n = r;
      }
    }
    System.out.print(m);
  }
}


Measured memory_bytes: 50620
#include <stdio.h>
int main(void)
{
	int b1,b2,b3;
	scanf("%d %d %d",&b1,&b2,&b3);
	if(b1==1 && b2==1){
		printf("Open\n");
	}
	else if(b3==1 && b1==0 && b2==0){
		printf("Open\n");
	}
	else{
		printf("Close\n");
	}
	return 0;
}


Measured memory_bytes: 2120
#include <stdio.h>
#include <math.h>

#define MAX_N 1000

int main() {
    while (true) {
        int n, s[MAX_N];
        scanf("%d", &n);
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            scanf("%d", s+i);
        }

        double m = 0;
        for (int i = 0; i < n; i++) {
            m += s[i];
        }
        m /= n; // mean
        
        double a2 = 0;
        for (int i = 0; i < n; i++) {
            a2 += pow(s[i]-m, 2);
        }
        a2 /= n; // variance

        double a = sqrt(a2); // standard deviation

        printf("%f\n", a);
    }
    return 0;
}


Measured memory_bytes: 2704
#include <stdio.h>

int search(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main(void){
    // Your code here!
    int i, n, A[10000+1], q, key, sum=0;
    
    scanf("%d", &n);
    for( i = 0; i < n; i++ ) scanf("%d", &A[i]);
    
    scanf("%d", &q);
    for ( i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(A, n, key)) sum++;
    }
    printf("%d\n", sum);
    
    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int A[n][n-1];
  REP(i,n)REP(j,n-1){
      cin >> A[i][j];
      A[i][j]--;
  }
  int ans = 0;
  int count[n];
  REP(i,n)count[i] = 0;
  while(1){
      bool game = false;
      int visited[n];
      REP(i,n)visited[i]=0;
      REP(i,n){
          if (count[i]==n-1)continue;
          if (visited[i]==1)continue;
          int next = A[i][count[i]];
          if (visited[next]==1)continue;
          if (A[next][count[next]]==i){
              visited[i]++;visited[next]++;
              count[i]++;count[next]++;
              game = true;
          }
      }
      if (!game){
          break;
      }else{
          ans++;
      }
      game = false;
  }
  REP(i,n){
      if (count[i]!=n-1){
          ans = -1;
      }
  }
  cout << ans << endl;

}

Measured memory_bytes: 4224