akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    int odd = 0, foul = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a & 1) odd++;
        if (a % 4 == 0) foul++;
    }
    
    bool ans = false;
    if (odd + foul == N) {
        if (foul >= odd - 1) ans = true;
    }
    else {
        if (foul >= odd) ans = true;
    }

    cout << (ans ? "Yes" : "No") << '\n';
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    solve();

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>



int main() {
    int N;
    cin >> N;
    string s = "No";
    for(int i = 9; i>0;i--){
        if(N%i == 0){
            if(N/i <= 9 && N/i >= 1){
                s = "Yes";
                break;
            }
        }
    }
    cout << s << endl;
    
} 

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

int main(){
    int m,d;
    cin>>m>>d;
    int count = 0;
    for(int i=22; i<=d; i++){
        int fi = i%10;
        int la = i/10;
        if((la*fi<=m) &&(la*fi>=4)&&(la>1)&&(fi>1)){
            count++;
        }
    }
    cout<<count<<endl;


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll w,a,b; cin >> w >> a >> b;
    if((a<=b && b<=a+w) || (b<=a && a<=b+w)) puts("0");
    else{
        if(b<a) cout << a-(b+w) << endl;
        else cout << b-(a+w) << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;
const LL MAXN = 200000+9;
LL n;
LL a[MAXN];
struct DATA{
	LL k,pd;
}num[MAXN];
LL dp[MAXN][2];
LL ans;

DATA cal(LL x){
	LL i;LL pos;
	for(i=1,pos=0;i<=x;i<<=1,pos++);
	i>>=1;
	if(i==x){
		return (DATA){pos-1,0};
	}
	else{
		return (DATA){pos,1};
	}
}

void solve(){
	LL i;
	for(i=1;i<=n;i++){
		num[i]=cal(a[i]);	
	}
	for(i=1;i<=n;i++)
		ans+=num[i].k;
	for(i=2;i<=n;i++){
		dp[i][0]=max(dp[i][0],dp[i-1][0]+min(num[i-1].k-num[i-1].pd,num[i].k));
		dp[i][0]=max(dp[i][0],dp[i-1][1]+min(num[i-1].k,num[i].k));
		dp[i][1]=max(dp[i][1],dp[i-1][0]+min(num[i-1].k-num[i-1].pd,num[i].k-num[i].pd));
		dp[i][1]=max(dp[i][1],dp[i-1][1]+min(num[i-1].k,num[i].k-num[i].pd));
	}
	printf("%lld\n",ans-max(dp[n][0],dp[n][1]));
}

int main(){
	scanf("%lld",&n);
	LL i;
	for(i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	solve();
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <ctime>

using namespace std;

#define int int64_t

signed main()
{
    //freopen("../input.txt", "r", stdin);
    int x,a,y,b,c;
    cin >> x >> y >> a >> b >> c;

    multiset<int> ps, qs, rs;

    for (int i = 0; i < a; ++i) {
        int v;
        cin >> v;

        ps.insert(v);
        if (ps.size() > x) {
            ps.erase(ps.begin());
        }
    }

    for (int i = 0; i < b; ++i) {
        int x;
        cin >> x;
        qs.insert(x);
        if (qs.size() > y) {
            qs.erase(qs.begin());
        }
    }

    for (int i = 0; i < c; ++i) {
        int x; cin >> x;
        rs.insert(x);
    }

    while (rs.size()) {
        int minRed = *ps.begin();
        int minGreen = *qs.begin();

        bool swapped = false;

        if (minRed > minGreen) {
            swapped = true;
            swap(minRed, minGreen);
        }


        auto it = rs.rbegin();

        if (*it <= minRed) {
            break;
        } else {
            if (!swapped) {
                ps.insert(*it);
                if (ps.size() > x) {
                    ps.erase(ps.begin());
                }
            } else {
                qs.insert(*it);
                if (qs.size() > y) {
                    qs.erase(qs.begin());
                }
            }

            rs.erase(rs.find(*it));
        }
    }

    int sum = 0;

    for (int el : ps) {
        sum += el;
    }

    for (int el : qs) {
        sum += el;
    }

    cout << sum;

    return 0;
}
 

Measured memory_bytes: 13440
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0;
  for(c = getchar();c < '0' || c > '9';c = getchar());
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res;
}
int n,m,num[35];
int main(){
	n = getint(), m = getint();
	for(int i = 1;i <= n;i++){
		int k = getint();
		for(int j = 1;j <= k;j++){
			int a = getint();
			num[a]++;
		}
	}
	for(int i = 1;i <= m;i++){
		if(num[i] == n) num[0]++;
	}
	printf("%d\n",num[0]);
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );
 
    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}
 
#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}
 
#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn main(){
    let (a,b) = parse_line!(usize, usize);
    if a % 2 != 0 && b % 2 != 0{
        println!("Yes");
    }
    else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	string str;
	int res;
	for(;n=in();){
		in();
		res=0;
		cin>>str;
		int i;
		int len=0;
		for(i=0;i<str.size();i++){
			if(len==0){
				if(str[i]=='I')len++;
			}else if(len%2){
				if(str[i]=='O')len++;
				else len=1;
			}else{
				if(str[i]=='I')len++;
				else len=0;
			}
			if(len%2&&len>n*2)res++;
//cout<<len<<endl;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

#define max ( 120000 + 1 )

using namespace std;


int main(void){

	vector< bool > p( max, true );
	vector< int > pr;
	vector< int > sum( max, 0 );
	p[0] = false;
	p[1] = false;

	for( int i = 2; i < max; i++ ) {
		if( p[i] == false ) continue;
		for( int j = 2 * i; j < max; j += i ) {
			p[j] = false;
		}
	}

	pr.push_back(0);
	for( int i = 2; i < max; i++ )
		if( p[i] ) pr.push_back( i );

	for( int i = 1; i < pr.size(); i++ ) {
		sum[i] = sum[i-1] + pr[i];
	}

	int n;
	while( true ) {
		scanf("%d",&n);
		if( !n ) break;
		cout << sum[n] << endl;
	}

    return 0;
}

Measured memory_bytes: 1800
#include <stdio.h>
#include <stdlib.h>

int main(void){

    int num, i, j;
    int ans[81];
    scanf("%d", &num);
    int count = 0;
    int flag = 0;

    for(i = 1; i <= 9; i++){
        for(j = 1; j <= 9; j++){
            ans[count] = i * j;
            count++;
        }
    }

    for(i = 0; i < 81; i++){
        if(ans[i] == num) {
            printf("Yes\n");
            flag = 1;
            break;
        }
    }

    if(flag == 0) printf("No\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long  int   ll;
const ll big=200005;
map <string,int> freq ;
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,r=0;
    cin>>n;
   string s[big];
    for(int i=0;i<n;++i){
        cin>>s[i];
        freq[s[i]]++;}
       ll max1=freq[s[0]];
       ll in=0;
       for(int i=1;i<n;++i){
        if(freq[s[i]]>max1){max1=freq[s[i]];in=i;}
       }
 
 
     set <string> s2;
     s2.insert(s[in]);
       for(int i=0;i<n;++i){
            if(i!=in){
                if(freq[s[i]]==freq[s[in]]){s2.insert(s[i]);}
            }}
     set <string>::iterator it;
      for(it=s2.begin();it!=s2.end() ;++it){cout<<*it<<endl;}
    return 0;
}

Measured memory_bytes: 34816
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
int r,c,n,xx1,yy1,xx2,yy2;
inline bool isbound(int x,int y) {
    return !x||x==r||!y||y==c;
}
struct point {
    int x,y,id;
    point(){}
    point(int x,int y,int id):x(x),y(y),id(id){}
} p[maxn<<1];
inline bool cmp1(point p1,point p2) {
    return p1.x<p2.x;
}
inline bool cmp2(point p1,point p2) {
    return p1.y<p2.y;
}
inline bool cmp3(point p1,point p2) {
    return cmp1(p2,p1);
}
inline bool cmp4(point p1,point p2) {
    return cmp2(p2,p1);
}
vector<point> v;
stack<int> stk;
int main()
{
    scanf("%d%d%d",&r,&c,&n);
    for (int i=0;i<n;++i) {
        scanf("%d%d%d%d",&xx1,&yy1,&xx2,&yy2);
        if (isbound(xx1,yy1)&&isbound(xx2,yy2)) {
            v.push_back(point(xx1,yy1,i));
            v.push_back(point(xx2,yy2,i));
        }
    }
    sort(v.begin(),v.end(),cmp1);
    for (int i=0;i<(int)v.size();++i)
        if (v[i].y==0) {
            if (!stk.empty()&&stk.top()==v[i].id) {
                stk.pop();
                continue;
            }
            stk.push(v[i].id);
        }
    sort(v.begin(),v.end(),cmp2);
    for (int i=0;i<(int)v.size();++i)
        if (v[i].x==r&&v[i].y!=0&&v[i].y!=c) {
            if (!stk.empty()&&stk.top()==v[i].id) {
                stk.pop();
                continue;
            }
            stk.push(v[i].id);
        }
    sort(v.begin(),v.end(),cmp3);
    for (int i=0;i<(int)v.size();++i)
        if (v[i].y==c) {
            if (!stk.empty()&&stk.top()==v[i].id) {
                stk.pop();
                continue;
            }
            stk.push(v[i].id);
        }
    sort(v.begin(),v.end(),cmp4);
    for (int i=0;i<(int)v.size();++i)
        if (v[i].x==0&&v[i].y!=0&&v[i].y!=c) {
            if (!stk.empty()&&stk.top()==v[i].id) {
                stk.pop();
                continue;
            }
            stk.push(v[i].id);
        }
    puts(stk.empty()?"YES":"NO");
    return 0;
}


Measured memory_bytes: 4468
#include<iostream>
using namespace std;
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N ;
    string S ;
    cin >> N;
    cin >> S;
    if (N % 2 != 0){
      cout << "No" << endl;
    }
    else {  
      int n = N / 2;
      string S2 = S;
      string s1 = S.erase(n);
      string s2 = S2.substr(n);
      if (s1 == s2){
          cout<<"Yes"<<endl;
      }
      else {
          cout<<"No"<<endl;
      }
    }
}


Measured memory_bytes: 3524
import Control.Monad
import Data.List
import qualified Data.Set as S
f m _ _ [] = m
f m s ([a,b]:rs) bs@([c,d]:_) 
  | a < c = f m (S.insert b s) rs bs
f m s rs ([c,d]:bs) 
  | Just x <- S.lookupLT d s = f (m+1) (S.delete x s) rs bs
  | otherwise = f m s rs bs
main = do
  n <- readLn
  rs <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  bs <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  print $ f 0 S.empty (sort rs) (sort bs)

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.rbegin(), v.rend()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e3+10;

struct BIT {
  vector<ll> data;
  int N;

  BIT(int n) {
    N = n;
    data = vector<ll>(N+1);
  }

  void add(int i, ll x) {
    for (int k = i; k <= N; k += k&-k) data[k] += x;
  }

  void update(int i, ll x) {
    add(i, x-get(i));
  }

  ll sum(int i) {
    ll res = 0;
    for (int k = i; k > 0; k -= k&-k) res += data[k];
    return res;
  }

  ll get(int i) {
    return sum(i) - sum(i-1);
  }

};


ll N, K;
ll A[MAX];
vector<ll> nums;

int main() {

  cin >> N >> K;
  BIT bit(N+10);
  REP (i, N) {
    cin >> A[i];
    bit.add(i+1, A[i]);
  }

  REP (i, N+1) REP (j, i) {
    nums.push_back(bit.sum(i)-bit.sum(j));
  }


  ll M = nums.size();
  ll ans = 0;
  REPR(k, 41) {
    sort(ALL(nums));
    ll X = (1l<<k);
    if (nums[K-1] & X) {
      int l = 0, r = M;
      while (r-l > 1) {
        int m = (l+r)/2;
        if (nums[m] >= X) l = m;
        else r = m;
      }
      vector<ll> nums2(r);
      REP (i, r) nums2[i] = nums[i]-X;
      nums = nums2;
      M = r;
      ans += X;
    }
    else {
      REP (i, K) {
        if (nums[i] >= X) nums[i] -= X;
        else break;
      }
    }
  }

  cout << ans << endl;
}



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

public class Main {
    public static void main(String[] args) {
        // @DONE: Plan solve [DOCUMENT TIME]
        // So basically there's this like, thing right lol
        // A + B + C = X, A > 0, B > 0, C > 0.
        // Number of ways to make A + B = 0 through X
        // WAIT HOLD UP THIS IS C&P LOLOL
        // Basically divide into pieces, probably subtract 3N - S JUST TO BE SAFE
        // @DONE: Test on paper [DOCUMENT TIME]
        // Not necessary
        // @DONE: Implement solve [DOCUMENT TIME]

        Scanner in = new Scanner(System.in);

        String s = in.nextLine();
        StringTokenizer st = new StringTokenizer(s);

        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());

        a++;

        // sum to B, less than A
        // so... total of B + 2 choose 2 ways
        // and then B - A + 2 choose 2 ways? PIE

        // Since you can add 3 for zeroes or no oh wait no
        int original = (b + 2)*(b + 1)/2;

        if(b >= a) {
            // Subtract
            original -= (b - a + 2)*(b - a + 1)*3/2;
        }
        if(b >= 2*a) {
            original += (b - 2*a + 2)*(b - 2*a + 1)*3/2;
        }

        System.out.println(original);
    }
}


Measured memory_bytes: 21716
#include<stdio.h>
int main()
{
    int n,r1,r2,i,j,c,d=0,m;
    scanf("%d%d%d",&n,&r1,&r2);
    for(i=1; i<=n; i++)
    {
        m=i;
        c=0;
        while(m>0)
        {
            c=c+m%10;
            m=m/10;
        }
        if(c>=r1 && c<=r2)
        {
            d+=i;
        }

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


Measured memory_bytes: 128
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var num1 = Convert.ToInt32(input[0]);
        var num2 = Convert.ToInt32(input[2]);
        var result = input[1] == "+" ? num1 + num2 : num1 - num2;
        Console.WriteLine(result);
    }
}

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

int main(void)
{
	while(1) {
		char point[100][100];
		bool check[100][100], ep = false;
		int Y, X;
		int x, y;

		for(int i = 0; i < 100; i++) {
			for(int j = 0; j < 100; j++) {
				point[i][j] = '.';
				check[i][j] = false;
			}
		}

		cin >> Y >> X;

		if(Y == 0 && X == 0) break;

		for(int i = 0; i < Y; i++) {
			for(int j = 0; j < X; j++) {
				cin >> point[j][i];
			}
		}

		x = 0, y = 0;

		while(1) {
			if(check[x][y] == true) {
				cout << "LOOP" << endl;
				break;
			} else {
				check[x][y] = true;

				switch(point[x][y]) {
				case '>' : x += 1; break;
				case '<' : x -= 1; break;
				case '^' : y -= 1; break;
				case 'v' : y += 1; break;
				case '.' : ep = true; break;
				};

				if(ep == true) {
					cout << x << " " << y << endl;
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

#define ll long long
#define ull unsigned long long

using namespace std;
int main(void) {
	int A = 0, B = 0, C = 0, D = 0;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	printf("%s\n", (abs(B - C) <= D && abs(B - A) <= D) || (abs(C - A) <= D) ? "Yes" : "No");
	return 0;
}

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

using namespace std;

typedef long long ll;

const int MAXN = 3000;

string s, t;
int dp[MAXN + 1][MAXN + 1];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> s >> t;
    for (size_t i = 1; i <= s.size(); i++) {
        for (size_t j = 1; j <= t.size(); j++) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            if (s[i - 1] == t[j - 1])
                dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1]);
        }
    }
    string lcs;
    size_t i = s.size(), j = t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == 1 + dp[i - 1][j - 1] && s[i - 1] == t[j - 1]) {
            lcs.push_back(s[i - 1]);
            i--;
            j--;
        } else if (dp[i - 1][j] >= dp[i][j - 1]) {
            i--;
        } else {
            j--;
        }
    }
    reverse(lcs.begin(), lcs.end());
    cout << lcs << endl;
}


Measured memory_bytes: 35456
A,B,C,X,Y = list(map(int,input().split()))

if A+B <= 2*C:
    ans = A*X+B*Y
else:
    ans = 2*C*min(X,Y)
    if X > Y:
        if A > 2*C:
            ans += 2*C*(X-Y)
        else:
            ans += A*(X-Y)
    elif X < Y:
        if B > 2*C:
            ans += 2*C*(Y-X)
        else:
            ans += B*(Y-X)

print(ans)

Measured memory_bytes: 3064
### constant

MAX_P = 10 ** 6

### subroutines

def gen_primes(max_p)
  primes = (max_p + 1).times.map{true}
  primes[0] = primes[1] = false

  s_max_p = Math.sqrt(max_p + 0.5).to_i

  for p in (2..s_max_p)
    if primes[p]
      for q in (p * p).step(max_p, p)
        primes[q] = false
      end
    end
  end

  primes
end

### main

primes = gen_primes(MAX_P)

loop do
  a, d, n = gets.split.map(&:to_i)
  break if (a | d | n) == 0

  seq = a
  np = 0

  while np < n
    np += 1 if primes[seq]
    seq += d
  end

  puts seq - d
end

Measured memory_bytes: 14080
#include <iostream>
using namespace std;
 
int main()
{
    int n, i, j, m = 1, p = 0, q;
    cin >> n;
 
    q = n;
 
    for (i = 9;i >= 0;i--) {
        for (j = 1;j <= i;j++) {
            m *= 10;
        }
        if(n - m >= 0) {
            p += n / m;
            n -= m * (n / m);
        }
        m = 1;
    }

    if(p == 0) {
        p = 1000000001;
    }
 
    if (q % p == 0){
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
 
    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

string to_upper(string str) {
    int diff = 'a' - 'A';
    for (int i = 0; i < str.size(); i++) {
        char c = str[i];
        if ('A' <= c && c <= 'Z') {
            c += diff;
            str[i] = c;
        }
    }
    return str;
}

class Stack {
    int index = -1;
    vector<int> ary;

public:
    Stack() : ary(100, 0) {}

    void push(int c) {
        index++;
        ary[index] = c;
    }

    int pop() {
        int res = ary[index];
        index--;
        return res;
    }
};

int main() {
    string s;
    getline(cin, s);


    vector<string> words;
    words.push_back("");
    for (int i = 0; i < s.size(); i++) {
        char c = s[i];
        if (c == ' ') {
            words.push_back("");
        } else {
            words.back() += c;
        }
    }

    Stack stack;

    for (int i = 0; i < words.size(); i++) {
        string word = words[i];
        if (word == "+") {
            int k = stack.pop();
            int l = stack.pop();
            stack.push(k + l);
        } else if (word == "-") {
            int k = stack.pop();
            int l = stack.pop();
            stack.push(l - k);
        } else if (word == "*") {
            int k = stack.pop();
            int l = stack.pop();
            stack.push(k * l);
        } else {
            int j = atoi(word.c_str());
            stack.push(j);
        }
    }

    cout << stack.pop() << endl;

}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
  int n;
  ll ans=0;
  vector<ll>vec(5);
  cin>>n;
  rep(i,n){
    string s;
    cin>>s;
    if (s.at(0)=='M') {
      vec.at(0)+=1;
    }
    else if (s.at(0)=='A') {
      vec.at(1)+=1;
    }
    else if (s.at(0)=='R') {
      vec.at(2)+=1;
    }
    else if (s.at(0)=='C') {
      vec.at(3)+=1;
    }
    else if (s.at(0)=='H') {
      vec.at(4)+=1;
    }
  }
  rep(i,3){
    for (int j=i+1; j<4; j++) {
      for (int k=j+1; k<5; k++) {
        ans+=vec.at(i)*vec.at(j)*vec.at(k);
      }
    }
  }
  cout<<ans<<endl;
}

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

const int mod=int(1e9)+7;

int main(){
  long n, k;
  cin >> n >> k;
  cout << (n*(n+1)*(n+2)/6+ n+1 - k*(k-1)*(3*n-2*k+4)/6-k+1)%mod;
  return 0;
}

Measured memory_bytes: 3180
n = int(input())
s = []

b = 0
a = 0
ba = 0
ans = 0

for i in range(n):
    s.append(input())
    ans += s[i].count('AB')
    if s[i].startswith('B') and s[i].endswith('A'):
        ba += 1
    elif s[i].startswith('B'):
        b += 1
    elif s[i].endswith('A'):
        a += 1

if ba == 0:
    ans += min(a, b)
elif ba != 0 and b + a > 0:
    ans += ba + min(a, b)
elif ba != 0 and b + a == 0:
    ans += ba - 1

print(ans)


Measured memory_bytes: 3700
n = int(input())
p = list(map(int, input().split()))
count = 0
m = [0] * n

memo = n
for i in range(n):
    if memo > p[i]:
        m[i] = p[i]
        memo = p[i]
    else:
        m[i] = memo

for i in range(1, n+1):
    if p[i-1] <= m[i-1]:
        count += 1

print(count)

Measured memory_bytes: 75472
#include <bits/stdc++.h>
using namespace std;
#define MAX 1e6

int main()
{
  vector<int> prime(MAX);
  int x;
  cin >> x;
  for (int i = 0; i < MAX; i++) prime[i] = 0;
  prime[0] = 1;

  for (int i = 2; i <= MAX / 2; i++) {
    for (int j = 2; i * j <= MAX; j++) {
      if (prime[i * j-1] == 0) prime[i * j-1] = 1;
    }
  }
  for (int i = x-1; i < MAX; i++) {
    if (prime[i] == 0)  {
      printf("%d\n", i+1);
      return 0;
    }
  }
}


Measured memory_bytes: 4224
import Foundation

extension String {
    var argi: [Int] { return self.characters.split(" ").map { Int(String($0))! } }
}

let arr = readLine()!.argi

let a: Int = arr[0]
let b: Int = arr[1]

var res: String = ""

if a == b {
    res = "Draw"
}
else {
    if a == 1 || a > b && b != 1 {
        res = "Alice"
    }
    else {
        res = "Bob"
    }
}

print(res)


Measured memory_bytes: 7268
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int a,b,c;
  
  cin >> a >> b >> c;
  
  vector<int> vec{a,b,c};
  
  sort(vec.begin(),vec.end());
  
  cout << (vec[0] + vec[1] == vec[2] ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef pair<int, P> iP;
typedef pair<P, int> Pi;
int main(void){
	ll h, hh, k, kk;
	cin >> h >> hh >> k >> kk;
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll hp = h * a + hh * b, kp = k * a + kk * b;
	hp += (h / 10) * c + (hh / 20) * d;
	kp += (k / 10) * c + (kk / 20) * d;
	if(hp > kp) cout << "hiroshi" << endl;
	else if( hp < kp) cout << "kenjiro" << endl;
	else cout << "even" << endl;	
	return 0;
}


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

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

  int a=-1, b=-1, c=-1;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=n-i; j++){
      if((y-10000*i-5000*j)/1000==n-i-j){
        a=i; b=j; c=n-i-j;
        goto ex;
      }
    }
  }

  ex:
  cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct tagItem Item;
typedef struct tagNode Node;
struct tagItem {
    char name[16];
    int time;
};
struct tagNode {
    Item item;
    Node *prev;
    Node *next;
};

void push(Node *queue, Item *item)
{
    //printf("push %s %d\n", item->name, item->time);
    Node *node = (Node *)malloc(sizeof(Node));
    node->item = *item;
    node->prev = queue->prev;
    node->next = NULL;
    if (queue->next == NULL) {
        queue->next = node;
    } else {
        queue->prev->next = node;
    }
    queue->prev = node;
}

int pop(Node *queue, Item *item)
{
    //printf("pop %p\n", queue->next);
    Node *node = queue->next;
    if (node != NULL) {
        if (node->next != NULL) {
            node->next->prev = NULL;
        }
        queue->next = node->next;
        if (queue->next == NULL) {
            queue->prev = NULL;
        }
        *item = node->item;
        free(node);
        //printf("pop %s %d\n", item->name, item->time);
        return 1;
    }
    //printf("pop error\n");
    return 0;
}

int main(void)
{
    Node queue;
    queue.prev = NULL;
    queue.next = NULL;
    int n, q, i, t;
    Item item;
    scanf("%d%d", &n, &q);
    for (i = 0; i < n; ++i) {
        scanf("%s%d", item.name, &item.time);
        push(&queue, &item);
    }
    t = 0;
    while(pop(&queue, &item)) {
        if (item.time <= q) {
            t += item.time;
            printf("%s %d\n", item.name, t);
        } else {
            t += q;
            item.time -= q;
            push(&queue, &item);
        }
    }

    return 0;
}



Measured memory_bytes: 4048
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
C = [int(a) - 1 for a in input().split()]
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

def EulerTour(n, X, i0):
    f = lambda k: k * (k + 1) // 2
    USED = [0] * n
    ORG = [0] * n
    TMP = [0] * n
    P = [-1] * n
    ct = -1
    ET1 = [0] * n
    ET2 = [0] * n
    ANS = [f(n)] * n
    IND = [len(x) for x in X]
    i = i0
    while i >= 0:
        ind = IND[i]
        if not ind:
            ET2[i] = ct
            USED[C[i]] += 1 + TMP[i]
            if i:
                k = ET2[i] - ET1[i] + 1 - USED[C[P[i]]] + ORG[i]
                ANS[C[P[i]]] -= f(k)
                TMP[P[i]] += k
            i = P[i]
            continue
        
        j = X[i][ind - 1]
        if P[i] == j:
            IND[i] -= 1
            continue
        
        P[j] = i
        IND[i] -= 1
        i = j
        ORG[i] = USED[C[P[i]]]
        ct += 1
        ET1[i] = ct
    
    for i in range(n):
        ANS[i] -= f(n - USED[i])
    return ANS

print(*EulerTour(N, X, 0), sep = "\n")

Measured memory_bytes: 137848
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
int main(){
    int n,l; cin>>n>>l;
    string s[110];
    rep(0,i,n) cin>>s[i];
    sort(s,s+n);
    rep(0,i,n){
        cout<<s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt();
		int D = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= M; i++) {
			for(int j = 1; j <= D; j++) {
				if(j % 10 < 2 || j / 10 < 2) continue;
				if((j % 10) * (j / 10) == i) ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(void){
    int a,b;
    char op;
    while(1){
    scanf("%d %c %d",&a,&op,&b);
    if      (op == '+') printf("%d\n",a+b);
    else if (op == '-') printf("%d\n",a-b);
    else if (op == '*') printf("%d\n",a*b);
    else if (op == '/') printf("%d\n",a/b);
    else break;
    }
}


Measured memory_bytes: 2140
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	ll n, a[5];
	scanf("%lld", &n);
	REP(i, 5) {
		scanf("%lld", &a[i]);
	}

	ll ans=0;
	ll min = n;
	REP(i, 5) {
		if (min > a[i]) {
			ans = (n+a[i]-1) / a[i];
			min = a[i];
		}
		ans = Maxl(ans, 1);
	}
	PRINTL(ans + 4);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int N,A,B;
int test(int x)
{
    int sum=0;
    while(x){
        sum+=x%10;
        x/=10;
    }
    if(sum<=B&&sum>=A) return 1;
    else return 0;
}
int main()
{

    while(cin>>N>>A>>B){
        int s=0;
        for(int i=1;i<=N;i++){
            if(test(i)) s+=i;
        }
        cout<<s<<endl;
    }
    return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.size(); i++) {
        int v = ((s[i] - 'A') + 23) % 26;
        cout << (char)('A' + v);
    }
    cout << endl;
    return 0;
}

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

int n;
ll k;
ll a[MAX], b[MAX];

bool check(ll mid){
    ll cnt = 0;
    for(int i = 1; i <= n; i++){
        if(a[i]*b[i] > mid){
            cnt += (a[i]-mid/b[i]);
        }
    }
    return cnt <= k;
}

bool cmp(ll a, ll b){
    return a > b;
}

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
    }
    for(int i = 1; i <= n; i++){
        scanf("%lld", &b[i]);
    }
    sort(a+1, a+n+1, cmp);
    sort(b+1, b+n+1);
    ll l, r, mx = 0, mid, ans;
    for(int i = 1; i <= n; i++){
        mx = max(mx, a[i]*b[i]);
    }
    l = 0, r = mx;
    while(l <= r){
        mid = (l+r)>>1;
        if(check(mid)) ans = mid, r = mid-1;
        else l = mid+1;
    }
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
x, n = map(int, input().split())
p = list(map(int, input().split()))


if x not in p or not p:
    print(x)
    exit()

left = x
while True:
    if left not in p:
        break
    left -= 1

right = x
while True:
    if right not in p:
        break
    right += 1

if abs(x-left) <= abs(x-right):
    print(left)
else:
    print(right)

Measured memory_bytes: 9200
S = gets

a = S[0..1].to_i
b = S[2..3].to_i

Y = 'YYMM'
M = 'MMYY'
A = 'AMBIGUOUS'
N = 'NA'

y, m = false

if 1 <= b && b <= 12
  y = true
end

if 1 <= a && a <= 12
  m = true
end

if y && m
  puts A
elsif y
  puts Y
elsif m
  puts M
else
  puts N
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pairSS
#define int long long
#define MOD 1000000007
int gcd(int a,int b){
  if(a==0){
    return b;
  }
  return gcd(b%a,a);
}
int lcm(int a,int b){
  return a*b/gcd(a,b);
}
int keta(int a){
  int count = 0;
  while(a!=0){
    a = a/10;
    count++;
  }
  return count;
}
signed main(){
  int a;
  string s;
  cin >> a >> s;
  if(a>=3200){
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
}


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



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

    cout << (n*(n-1))/2+(m*(m-1))/2 << endl;
}


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

//50 
typedef long long ll;

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = b - a + 1;
	//cout << ans << endl;
	ans -= ((b/ c) - ((a - 1)/ c));
	//cout << ans << endl;
	ans -= ((b / d) - ((a - 1) / d)) ;
	//cout << ans << endl;
	ll p = (d *c) / __gcd(d,c);
	ans += ((b / p)) - ((a - 1) / (p));
	//cout << ans << endl;
	cout << ans;  
}


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

using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<ll> s(n);
  
  for(int i=0; i<n; i++) cin >> s[i];
  sort(s.begin(), s.end());
  ll sum = accumulate(s.begin(), s.end(), 0);
  
  if(sum%10==0){
    for(int i=0; i<n; i++){
      if(s[i]%10){
        sum -= s[i];
        break;
      }
    }
  }
  
  if(sum%10==0) sum=0;
  
  cout << sum << endl;
  

  return 0;
}

Measured memory_bytes: 3624
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ls = list(mapint())
Ls.sort()

from bisect import bisect_left
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(Ls, Ls[i]+Ls[j])
        ans += idx-1-j

print(ans)

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

int main()
{

    int N, M;
    cin >> N >> M;
    multiset<int> A;
    for (int i = 0; i < N; ++i)
    {
        int a;
        scanf("%d", &a);
        A.insert(a);
    }

    for (int i = 0; i < M; i++)
    {
        int a = *(--A.end()) / 2;
        A.erase(--A.end());
        A.insert(a);
    }
    cout << accumulate(A.begin(), A.end(), 0LL) << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include <boost/rational.hpp>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll a;cin>>a;
  string b; cin>>b;

  ll bb=0;
  for(char c: b){
    if(c=='.')continue;
    bb = 10*bb+c-'0';
  }

  cout<<(ll)(a*bb/100)<<endl;
//  cout<<(ll)(a*bb)<<endl;

//cout<<a<<' '<<bb<<' '<<b<<endl;

  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[][] arr = new int[n][2];
      for(int i = 0; i < n; i++) {
        arr[i][0] = sc.nextInt();
        arr[i][1] = sc.nextInt();
      }
      Arrays.sort(arr, (a, b) -> a[1] - b[1]);
      long total = 0;
      for(int i = 0; i < arr.length; i++) {
       
        int cost = arr[i][0];
         total += cost;
        int deadLine = arr[i][1];
        if(total > deadLine) {
          System.out.println("No");
          return;
        }
      }
      System.out.println("Yes");
  }
}

Measured memory_bytes: 110944
x, y, z = map(int, input().split())
matrix1 = list()
matrix2 = list()
ans = list()
for i in range(x):
    matrix1.append(list(map(int, input().split())))
for j in range(y):
    matrix2.append(list(map(int, input().split())))
for i in range(x):
    row = list()
    for j in range(z):
        term = 0
        for k in range(y):
            term += matrix1[i][k]*matrix2[k][j] 
        row.append(term)
    ans.append(row)
for i in range(x):
    print (' '.join(map(str, ans[i])))


Measured memory_bytes: 6900
use std::io::{stdin, stdout, StdinLock, StdoutLock, BufReader, BufWriter, BufRead, Write};

fn main() {
    let (std_in, std_out) = (stdin(), stdout());
    let mut io = IO::new(std_in.lock(), std_out.lock());
    let r = io.r::<f64>();
    io.w(2.0 * r * 3.1415926535);
}


struct IO<'a> {
    br: BufReader<StdinLock<'a>>,
    bw: BufWriter<StdoutLock<'a>>,
}

#[allow(dead_code)]
impl IO<'_> {
    fn new<'a>(il: StdinLock<'a>, ol: StdoutLock<'a>) -> IO<'a> {
        IO {br: BufReader::new(il), bw: BufWriter::new(ol) }
    }

    fn r<T: std::str::FromStr>(&mut self) -> T {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().parse().ok().unwrap()
    }

    fn rb(&mut self) -> Vec<u8> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().as_bytes().to_vec()
    }

    fn rv<T: std::str::FromStr>(&mut self) -> Vec<T> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
    }

    fn rvb(&mut self) -> Vec<Vec<u8>> {
        let mut buf = String::new();
        self.br.read_line(&mut buf).ok();
        buf.trim().split_whitespace().map(|e| e.as_bytes().to_vec()).collect()
    }

    fn w<T: std::fmt::Display>(&mut self, x: T) {
        let _ = writeln!(self.bw, "{}", x);
    }

    fn wb(&mut self, s: &[u8]) {
        let _ = writeln!(self.bw, "{}", unsafe{std::str::from_utf8_unchecked(s)});
    }

    fn wv<T: std::fmt::Display>(&mut self, v: &[T]) {
        let _ = write!(self.bw, "{}", v[0].to_string());
        for x in v[1..].iter() {
            let _ = write!(self.bw, " {}", x.to_string());
        }
        let _ = writeln!(self.bw);
    }

    fn wvb(&mut self, v: &[Vec<u8>]) {
        let _ = write!(self.bw, "{}", unsafe{std::str::from_utf8_unchecked(&v[0])});
        for x in v[1..].iter() {
            let _ = write!(self.bw, " {}", unsafe{std::str::from_utf8_unchecked(x)});
        }
        let _ = writeln!(self.bw);
    }
}


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

using namespace std;

#define int long long

vector<vector<int>>v(10,vector<int>(10,0));

int32_t main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int val=i;
        while(val>=10)val/=10;
        v[val][i%10]+=1;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        int val=i;
        while(val>=10)val/=10;
        ans+=v[i%10][val];
    }
    cout<<ans<<endl;
}


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

bool myfunc(const pair<string, int> &i, const pair<string, int> &j)
{
	if(i.first > j.first) return i.first < j.first;
	else if(i.first < j.first) return i.first < j.first;
	else return i.second > j.second;
}
 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n, val;
	
	cin >> n;
	
	string s;
	
	vector< pair<string, int> > p;
	map< pair<string, int>, int> mp;
	
	for(int i = 0; i < n; i++){
		cin >> s >> val;
		p.push_back(make_pair(s, val));
		mp[{s, val}] = i+1;
	}
	
	sort(p.begin(), p.end(), myfunc);
	
	for(int i = 0; i < n; i++){
		//cout << p[i].first << " " << p[i].second << "\n";
		cout << mp[{p[i].first, p[i].second}] << "\n";
	}
	
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int N; cin >> N;
    vector<int> d(N); REP(i, N) cin >> d[i];

    sort(all(d));

    int cnt = 1;
    REP(i, N - 1) {
        if(d[i] < d[i + 1]) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K; cin >> N >> K;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    REP(k, K) {
        vector<i64> B(N + 1, 0);
        REP(i, N) {
            B[max((i64)0, i - A[i])]++;
            B[min(N, i + A[i] + 1)]--;
        }
        bool ok = true;
        REP(i, N) {
            if (i > 0) B[i] += B[i - 1];
            A[i] = B[i];
            if (A[i] != N) ok = false;
        }
        if (ok) {
            break;
        }
    }

    REP(i, N) cout << A[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 6368
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 100010;
const int M = 1000000007;

int n,m;
ll ans;
ll fac[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	ans = 0;
	n = read(), m = read();
	
	if(n<m) swap(n,m);
	
	fac[1] = 1;
	for(int i = 2; i <= 100000; i++){
		fac[i] = 1LL * fac[i-1] * i % M;
	}
	
	
	if(n - m > 1) ans = 0;
	else{
		ans = 1LL * fac[n] * fac[m] % M;
	}
	if(m == n) ans = 1ll* ans * 2 % M;
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 4540
package main

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

func scan() (uint64, uint64) {

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	a, _ := strconv.ParseUint(scanner.Text(), 10, 64)

	scanner.Scan()
	b, _ := strconv.ParseUint(scanner.Text(), 10, 64)

	return a, b
}

func main() {

	a, b := scan()
	fmt.Println(a + b/2)
}


Measured memory_bytes: 640
L = []
f = True
for _ in range(3):
    l =list(map(int, input().split()))
    L.append(l)
for i in range(2):
    cnt = 0
    tmp1 = -1
    for j in range(3):
        if tmp1 !=  L[i+1][j] -L[i][j]:
            cnt += 1
        tmp1 = L[i+1][j] -L[i][j]
    if cnt > 1:
        f = False

for i in range(2):
    cnt = 0
    tmp1 = -1
    for j in range(3):
        if tmp1 !=  L[j][i+1] -L[j][i]:
            cnt += 1
        tmp1 = L[j][i+1] -L[j][i]
    if cnt > 1:
        f = False

if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import math

A, B, X = map(int, input().split())
ans = float('inf')

for a in range(math.ceil(X/1000)+1):
    if X-1000*a < 0: b = 0
    else: b = math.ceil((X-1000*a)/500)
    ans = min(ans, A*a+B*b)

print(ans)


Measured memory_bytes: 5668
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(void)
{
	int N, K, T, V, U, L;
	double eat_d, distance;
	double result = 0.0;
	int c_num = 0, eat_num;
	cin >> N >> K >> T >> U >> V >> L;
	vector<int> D(N);
	rep(i, N){
		cin >> D[i];
	}
	rep(i, N){
		if (i == 0){
			eat_d = (double)D[i];
			result += eat_d / U;
		}else{
			eat_num = 0;
			distance = (double)D[i] - eat_d;
			while(c_num > 0 && distance > (double)V*T*(eat_num+1)){
				c_num--;
				eat_num++;
			}
			result += (double)T*eat_num;
			eat_d += (double)V*T*eat_num;

			distance = (double)D[i] - eat_d;
			if (distance > (double)V*T){
				result += (double)T + (distance-(double)V*T) / U;
				eat_d = (double)D[i];
			}else if(c_num == K){
				result += distance / V;
				eat_d = (double)D[i];
			}else{
				c_num++;
			}
		}
	}

	eat_num = 0;
	distance = (double)L - eat_d;
	while(c_num > 0 && distance > (double)V*T*(eat_num+1)){
		c_num--;
		eat_num++;
	}
	result += (double)T*eat_num;
	eat_d += (double)V*T*eat_num;

	distance = (double)L - eat_d;
	if (distance > (double)V*T){
		result += (double)T + (distance-(double)V*T) / U;
	}else{
		result += distance / V;
	}

	cout << fixed << setprecision(9) << result << endl;

	return 0;
}


Measured memory_bytes: 3288