akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

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

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func powMod(a, n int) int {
	if n < 0 {
		log.Fatal("pow error")
	}
	if n == 0 {
		return 1
	}
	if n%2 == 0 {
		d := powMod(a, n/2) % mod
		return d * d % mod
	}
	return a * powMod(a, n-1) % mod
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

type key struct {
	Positive bool
	First    int
	Second   int
}

func toPositive(a, b int) (int, int, bool) {
	if a == 0 && b == 0 {
		return a, b, true
	}
	if a == 0 {
		if b > 0 {
			return a, b, true
		}
		return a, -b, false
	}

	if b == 0 {
		if a > 0 {
			return a, b, true
		}
		return -a, b, false
	}

	if a > 0 && b > 0 {
		return a, b, true
	}
	if a > 0 && b < 0 {
		return a, -b, false
	}
	if a < 0 && b > 0 {
		return -a, b, false
	}
	if a < 0 && b < 0 {
		return -a, -b, true
	}
	log.Fatal("positive error")
	return 0, 0, true
}

const mod = 1000000007

func main() {
	n := nextInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		b[i] = nextInt()
	}
	count := make(map[key]int)
	twoZeroes, zeroOne, oneZero := 0, 0, 0
	for i := 0; i < n; i++ {
		var val key
		if a[i] == 0 && b[i] == 0 {
			twoZeroes++
		} else if a[i] == 0 {
			// val = key{true, 0, 1}
			zeroOne++
		} else if b[i] == 0 {
			// val = key{false, 1, 0}
			oneZero++
		} else {
			pa, pb, pos := toPositive(a[i], b[i])
			g := gcd(pa, pb)
			val = key{pos, pa / g, pb / g}
			count[val]++
		}
		// count[val]++
	}
	// fmt.Println(count)

	ans := (powMod(2, zeroOne) + powMod(2, oneZero) - 1 + mod) % mod
	used := make(map[key]bool)
	for k, cnt := range count {
		if used[k] {
			continue
		}

		pair := key{!k.Positive, k.Second, k.First}
		if pcnt, ok := count[pair]; ok {
			ans *= (powMod(2, cnt) + powMod(2, pcnt) - 1 + mod) % mod
			used[pair] = true
		} else {
			ans *= powMod(2, cnt)
		}
		ans %= mod
	}
	ans += twoZeroes % mod
	ans--
	ans = (ans + mod) % mod
	fmt.Println(ans)
}


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

#define int long long

#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

int x,y;
bool can=false;

signed main(){
    cin>>x>>y;
    int xx=abs(x),yy=abs(y);
    int ans=xx>yy?xx-yy:yy-xx;
    if(xx==yy){
        cout<<ans+1<<endl;
        return 0;
    }
    if(yy>xx)can=true;
    if(x>0&&y>0&&!can)ans+=2;
    if(x>=0&&y<=0)ans+=1;
    if(x<0&&y>0)ans+=1;
    if(x<0&&y<0&&can)ans+=2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

a,b,c = read_ints()
ans = 0
amt = min(b,c)
ans += 2*amt
b -= amt
c -= amt 

amt = min(a,c)
ans += amt
a -= amt 
c -= amt 
# print ans 

if c > 0:
    ans += 1
ans += b 
print ans 


Measured memory_bytes: 2568
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C, D;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> A >> B >> C >> D;
    ll ans = max(A * B, C * D);
    cout << ans << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3620
#include<stdio.h>

int main(){
  int a[3] = {};
  for(int i = 0; i < 3; i++){
    scanf("%d", &a[i]);
  }

  int temp = 0;

  for(int i = 0; i < 2; i++){
    if(a[i] > a[i+1]){
      temp = a[i+1];
      a[i+1] = a[i];
      a[i] = temp;
    }
  }
  if(a[0] > a[1]){
    temp = a[1];
    a[1] = a[0];
    a[0] = temp;
  }

  //for(int i = 0; i < 3; i++)printf("%d ", a[i]);

  int c = 0;

  while(a[1] < a[2]){
    a[0] += 1;
    a[1] += 1;
    c += 1;
    }
  //printf("\n");
/*  for(int i = 0; i < 3; i++)printf("%d ", a[i]);
    printf("\n");
    printf("%d", c);
*/

  while(a[0] < a[1]){
    a[0] += 2;
    c += 1;
  }
//  printf("\n");
//  for(int i = 0; i < 3; i++)printf("%d ", a[i]);
//    printf("\n");
//    printf("%d", c);

  if(a[0] > a[1]){
    a[1] += 1;
    a[2] += 1;
    c += 1;
    printf("%d", c);
  }else{printf("%d", c);}

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  P a[n],b[m];
  rep(i,n) cin >> a[i].F >> a[i].S;
  rep(i,m) cin >> b[i].F >> b[i].S;
  rep(i,n) {
    int M=MAX,x;
    rep(j,m) {
      int d=abs(a[i].F-b[j].F)+abs(a[i].S-b[j].S);
      if(d<M) {
        M=d;
        x=j+1;
      }
    }
    pr(x);
  }
}

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


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

int main(){
  int N, K;
  cin >> N >> K;

  vector<int> L(N);
  for (int i=0; i<N; i++){
    cin >> L[i];
  }
  sort(L.begin(), L.end(),greater<int>());
  int sum = 0;
  for (int i=0; i<K; i++){
    sum += L[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
ll KS(ll a,ll b)
{
	ll x=1;
	while(b)
	{
		if(b&1)
		{
			x=x*a%mod;
		}
		a=a*a%mod;
		b>>=1;
	}
	return x;
}
int main()
{
	ll n;
	cin>>n;
	ll sum;
	sum=(KS(10,n)-2*(KS(9,n))+KS(8,n))%mod;
	sum=(sum+mod)%mod;
	cout<<sum<<endl;
}

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

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

const int MAX_N = 100000;
const int MAX_V = 1000000000;

int N;
int X[MAX_N];
int L[MAX_N];

void input() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d%d", X+i, L+i);
    }
}

P ps[MAX_N];

int solve() {
    for (int i = 0; i < N; i++) {
        ps[i] = P(X[i]+L[i], X[i]-L[i]);
    }
    sort(ps, ps+N);
    int cur = -MAX_V;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (cur <= ps[i].second) {
            ans++;
            cur = ps[i].first;
        }
    }
    return ans;
}

int main() {
    input();
    int ans = solve();
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

constexpr int MAX_N = 200000;
constexpr ll INF = std::numeric_limits<ll>::max()>>2;

ll N;
ll A[MAX_N];
ll S[MAX_N+1];
ll L[MAX_N], R[MAX_N];
ll ans = INF;

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
    scanf( "%lld", A+i );
  rep( i, N )
    S[i+1] = S[i]+A[i];

  int l = N-1, r = N-1;

  while( l >= 0 && r >= 0 )
  {
    while( 2*(S[l+1]-S[r]) < S[l+1] )
      --r;

    if( llabs(2*(S[l+1]-S[r])-S[l+1]) > llabs(2*(S[l+1]-S[r+1])-S[l+1]) )
      ++r;

    L[l] = r;
    --l;
  }

  l = r = 0;
  while( l < N && r < N )
  {
    while( 2*(S[r+1]-S[l+1]) < (S[N]-S[l+1]) )
      ++r;

    if( llabs(2*(S[r+1]-S[l+1])-(S[N]-S[l+1])) > llabs(2*(S[r]-S[l+1])-(S[N]-S[l+1])) )
      --r;

    R[l] = r;
    ++l;
  }

  rep( i, N )
  {
    ll arr[4] = { S[L[i]], S[i+1]-S[L[i]], S[R[i]+1]-S[i+1], S[N]-S[R[i]+1] };

    ans = std::min( ans, *std::max_element( arr, arr+4 )-*std::min_element( arr, arr+4 ) );
  }

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

Measured memory_bytes: 6400
#include<stdio.h>

int main(){
	int a[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	for(int i=0;i<2;i++){
		for(int j=0;j<2-i;j++){
			if(a[j]>a[j+1]){
				int t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}
	if(a[0]+a[1]==a[2]){
		printf("Yes");
	}
	else{
		printf("No");
	}
} 

Measured memory_bytes: 128
costs = [2,5,5,4,5,6,3,7,6]

N, M = map(int, input().split())
A = list(map(int, input().split()))
neginf = -1 * 1e20
D = [neginf]*(N+1)

def dp(n_match):
    D[0] = 0
    for n in range(1,n_match+1):
        arr = [D[n-costs[a-1]] if n-costs[a-1]>=0 else neginf for a in A]
        if max(arr) < 0:
            continue

        D[n] = max(arr)+1

def main():
    dp(N)
    n = N
    ans = ''
    while n>0:
        arr = [ a for a in A if n-costs[a-1] >= 0 and D[n-costs[a-1]]==D[n]-1 ]
        if len(arr)>0:
            a = max(arr)
            ans += str(a)
            n -= costs[a-1]
        # else:
        #     break
    print(ans)

main()



Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll c[15][1005];
ll area(ll py,ll px,ll y,ll x)
{
	return (c[x][y]-c[px][y]-c[x][py]+c[px][py]);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll j,l,m,h,w,f,k,b,prevx,prevy,col,ans;
    	cin>>h>>w>>k;
    	string s; ans=mod;
    	rep(i,0,h)
    	{
    		cin>>s;
    		rep(j,0,w)
    		{
    			c[i+1][j+1]=c[i][j+1]+c[i+1][j]-c[i][j];
    			if(s[j]=='1')
    			c[i+1][j+1]+=1;
			}
		}
    	rep(cond,0,1<<(h-1))
    	{
    		prevx=0; col=0;
    		repi(x,1,w)
    		{
    			prevy=0;
    			repi(y,1,h)
    			{
    				if((cond & (1<<y-1)) || y==h)
    				{
    					if(area(prevx,prevy,x,y)>k)
    					{
    						prevx=x-1; col++;
    						break;
						}
						prevy=y;
					}
				}
    			if(x==w)
    			{
    				prevy=0;
    				repi(y,1,h)
    				{
    					if((cond & (1<<y-1)) || y==h)
    					{
    						if(area(prevx,prevy,x,y)>k)
    						{
    							col=mod;
    							break;
							}
							prevy=y;
						}
					}
				}
			}
			ans=min(ans,col+__builtin_popcount(cond));
		}
		cout<<ans;	
    }
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int h, w, m;
	cin >> h >> w >> m;
	int x[m], y[m];
	set<pair<int, int>> s;
	vector<int> H(h), W(w);
	rep(i, m) {
		cin >> x[i] >> y[i];
		x[i]--, y[i]--;
		s.insert({x[i], y[i]});
		H[x[i]]++;
		W[y[i]]++;
	}
	int maxh = 0, maxw = 0;
	rep(i, h) maxh = max(maxh, H[i]);
	rep(i, w) maxw = max(maxw, W[i]);
	set<int> X, Y;
	rep(i, h) {
		if (H[i] == maxh) X.insert(i);
	}
	rep(i, w) {
		if (W[i] == maxw) Y.insert(i);
	}
	for (auto nx : X) {
		for (auto ny : Y) {
			if (s.count({nx, ny}) == 0) {
				cout << maxh + maxw << "\n";
				return 0;
			}
		}
	}
	cout << maxh + maxw - 1 << "\n";
	return 0;
}

Measured memory_bytes: 50176
n=gets.to_i
red_pts=n.times.map{gets.split.map(&:to_i)}
blue_pts=n.times.map{gets.split.map(&:to_i)}.sort_by(&:first)
ans=0
n.times{|i|
  next unless blue_pts[i]
  bx,by=blue_pts[i]
  idx=y_max=-1
  r_cand=red_pts.each_with_index{|(x,y),i|
    if x<bx&&y<by
      if y_max<y
        y_max=y
        idx=i
      end
    end
  }

  next if idx==-1

  ans+=1
  red_pts.delete_at(idx)
}

puts ans

Measured memory_bytes: 1788
def main():
    N = int(input())
    S = input()

    if N % 2 == 0:
        if N == 2:
            if S[0] == S[1]:
                print("Yes")
            else:
                print("No")
        else:
            if S[0:(N//2-1)] == S[(N//2):N-1]:
                print("Yes")
            else:
                print("No")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	lint N;
	cin >> N;
	cout << N * (N - 1) / 2 << endl;
}


Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let x: usize = read();
  let mut dp = vec![0; 10010];
  dp[0] = 100;

  for i in 0..10000 {
    dp[i+1] = dp[i] + dp[i]/100;
  }

  let mut ans = 0;
  for i in 0..10000 {
    if dp[i] >= x {
      println!("{}", i);
      return
    }
  }

}


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

#define pb push_back
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll a[MAXN];
ll dp1[MAXN];
ll dp2[MAXN];
vector<ll> f;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	dp1[1] = 1;
	ll c;
	for(int i = 2; i <= n; i++){
		dp1[i] = dp1[i - 1] + 1;
		ll x = 2 * a[i - 1];
		while(x < 2 * a[i]){
			
			if(f.size() == 0) dp1[i] += (2ll * i - 2ll);
			else {
				dp1[i] += (2 * (i - f.back()));
				f.pop_back();
			}
			x*=4ll;
		}
		c = 2 * a[i];
		while(4ll * c <= x) {
			f.pb(i);
			c*=4;
		}
	}
	f.clear();
	
	dp2[n] = 0;
	for(int i = n - 1; i > 0; i--){
		dp2[i] = dp2[i + 1];
		ll x = a[i + 1];
		while(x < a[i]){
			if(f.size() == 0) dp2[i] += (2 * (n - i));
			else {
				dp2[i] += (2 * (f.back() - i));
				f.pop_back();
			}
			x*=4;
		}
		c = a[i];
		while(4ll * c <= x) {
			f.pb(i);
			c*=4;
		}
	}
	
	ll ans = INF;
	for(int i = 0;i <= n; i++) ans = min(ans, dp1[i] + dp2[i + 1]);
	cout << ans;
	return 0;
}


/*
4096 4096 4096
                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



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

int n;
vector<int64_t> score;
vector<vector<int>> a;
int64_t go(int mask) {
    if (score[mask] != -1)
        return score[mask];
    int bit_count = __builtin_popcount(mask);
    if (bit_count <= 1)
        return 0;
    // all as one group
    score[mask] = 0;
    int64_t all_score = 0;
    for (int i = 0; i < n; i++) {
        if (!(mask & (1 << i))) continue;
        for (int j = i + 1; j < n; j++) {
            if (!(mask & (1 << j))) continue;
            else all_score += a[i][j];
        }
    }
    score[mask] = max(score[mask], all_score);
    // split into some groups
    vector<int> ind;
    for (int j = 0; j < n; j++)
        if (mask & (1 << j)) 
            ind.push_back(j);
    for (int submask = 0; submask < (1 << bit_count); submask++) {
        if (__builtin_popcount(submask) > bit_count / 2) continue;
        int real_mask = 0;
        for (int j = 0; j < bit_count; j++)
            if (submask & (1 << j)) 
                real_mask |= (1 << ind[j]);
        int conj_mask = mask ^ real_mask;
        score[mask] = max(score[mask], go(real_mask) + go(conj_mask));
    }
    return score[mask];
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> n;
    a.resize(n, vector<int>(n));
    score.resize(1 << n, -1);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    cout << go((1 << n) - 1) << '\n';
    return 0;
}

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

int best = 9999999;
int l[8];
int idx[8];
int n, a, b, c;

inline int abs(int a) {
    if (a < 0) return -a;
    return a;
}

void recur(int m) {
    if (m == n) {
        int a_len = 0, b_len = 0, c_len = 0;
        int an = 0, bn = 0, cn = 0;
        for (int i=0; i<n; i++) {
            switch(idx[i]) {
                case 1:
                    a_len += l[i];
                    an++;
                    break;
                case 2:
                    b_len += l[i];
                    bn++;
                    break;
                case 3:
                    c_len += l[i];
                    cn++;
                    break;
                default:
                    break;
            }
        }
        int t = abs(a_len - a) + abs(b_len - b) + abs(c_len - c) + (an + bn + cn - 3) * 10;
        if (an >= 1 && bn >= 1 && cn >= 1 && t < best) {
#ifdef AAAAAA
            cerr << "New best: " << t << endl;
            cerr << "len:" << a_len << ' ' << b_len << ' ' << c_len << endl;
            cerr << "num:" << an << ' ' << bn << ' ' << cn << endl;
            for (int j = 0; j < n; j++) {
                cerr << idx[j];
            }
            cerr << endl;
#endif
            best = t;
        }
        return;
    }
    idx[m] = 0;
    recur(m + 1);
    idx[m] = 1;
    recur(m + 1);
    idx[m] = 2;
    recur(m + 1);
    idx[m] = 3;
    recur(m + 1);
}

int main() {

    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    recur(0);
    cout << best << endl;
}


Measured memory_bytes: 256
S = int(input())
M = 10 ** 9 + 7
def mod_pow(a, b, mod):
	bin_b = []
	while b:
		bin_b.append(b % 2)
		b >>= 1
	ret = 1
	for j in reversed(bin_b):
		ret = (ret * ret) % mod
		if j == 1:
			ret = (ret * a) % mod
	return ret
def mod_comb(n, k, mod):
	ret = 1
	for i in range(1, k+1):
		ret = (ret * (n+1-i)) % mod
		ret = (ret * mod_pow(i, mod-2, mod)) % mod
	return ret
ans = 0
for K in range(1, S // 3 + 1):
  ans = (ans + mod_comb(S - 2 * K - 1, K - 1, M)) % M
print(ans)

Measured memory_bytes: 68432
n,m=map(int,input().split())
l=["0"]*n
l[0]="1"
l[-1]="0"
f=[0]*n
frag=0
for i in range(m):
    s,c=map(int,input().split())
    if f[s-1]==0 or l[s-1]==str(c):
        l[s-1]=str(c)
        f[s-1]=1
    else:
        frag=1
        break
if frag==1 or (l[0]=="0" and n!=1):
    print(-1)
else:
    for j in l:
        print(j,end="")

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, M, ans=0, tmp=0;
vector<set<ll>> G;
vector<ll> color, nums;
string S;

void bfs(ll st, ll id) {
    queue<ll> Q;
    color[st] = id;
    Q.push(st);
    while(!Q.empty()) {
        ll u = Q.front();
        Q.pop();
        for(set<ll>::iterator itr=G[u].begin();itr!=G[u].end();itr++) {
            if(color[*itr]==-1) {
                color[*itr] = id;
                Q.push(*itr);
            }
        }
    }
}

signed main(){
    cin >> N >> M;
    color.resize(N, -1);
    G.resize(N);
    for(int i=0;i<M;i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[b].insert(a);
        G[a].insert(b);
    }
    //cout << "OK" << endl;
    for(int i=0;i<N;i++) {
        if(color[i]==-1) {
            bfs(i, tmp);
            tmp++;
        }
    }
    //cout << "OK" << endl;
    nums.resize(tmp, 0);
    for(int i=0;i<N;i++) {
        nums[color[i]]++;
    }
    for(int i=0;i<tmp;i++) {
        ans = max(ans, nums[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 33440
X=int(input())
A=X%100
B1=A//5
B2=A%5
C1=B2//4
C2=B2%4
D1=C2//3
D2=C2%3
E=D2//2
F=D2%2
ans=105*B1+104*C1+103*D1+102*E+101*F
if ans<=X:
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
def c_h_and_v():
    from itertools import product
    H, W, K = [int(i) for i in input().split()]
    C = [input() for _ in range(H)]

    ans = 0
    for rows in product([True, False], repeat=H):
        for cols in product([True, False], repeat=W):
            remain = 0
            for r, c in product(range(H), range(W)):
                if rows[r] and cols[c] and C[r][c] == '#':
                    remain += 1
            if remain == K:
                ans += 1
    return ans

print(c_h_and_v())

Measured memory_bytes: 8996
#include<bits/stdc++.h>
#define ll long long
#define maxn (1000+10)
#define mod 10000003
#define lnode node*2,start,mid
#define rnode node*2+1,mid+1,end
using namespace std;
int n,a[100001];
int main()
{   ios::sync_with_stdio(false);
	#define int ll
	cin>>n;
	for(int i=1;i<=n;i++)
	  cin>>a[i];
	int ans=0,res=0;
	for(int i=n;i>=2;i--)
	{  if(a[i]<=a[i-1])
	     res+=1;
	   else res=0;
	   if(res>ans) ans=res;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
s = input()
first = int(s[0] + s[1])
second = int(s[2] + s[3])
if first <= 12 and first >= 1 and second <= 12 and second >= 1:
    print("AMBIGUOUS")
elif first <= 12 and first >= 1:
    print("MMYY")
elif second <= 12 and second >= 1 :
    print("YYMM")
else: 
    print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main() {
    fastio
    int k;
    int a, b;
    cin>>k>>a>>b;
    int m = b/k;
    if(m*k<a) {
        cout<<"NG"<<endl;
    }
    else {
        cout<<"OK"<<endl;
    }
}

Measured memory_bytes: 3668
INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13

print(dp[len(S)][5])


Measured memory_bytes: 62300
import bisect
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
a=[0]
b=[0]
for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])
for i in range(N+1):
  if a[i]>K:
    break
  c=K-a[i]
  ans=max(ans,i+bisect.bisect_right(b,c)-1)
print(ans)

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

int calc(int n) {
  int total = 0;
  while (n > 0) {
    total += n % 10;
    n /= 10;
  }
  return total;
}

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

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int x = calc(i);
    if (A <= x && x <= B) {
      ans += i;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n],t[n];
    for(int i = 0; i < n; i++) {
        cin >> t[i] >> a[i];
    }
    ll pt=t[0];
    ll pa=a[0];
    for(int i = 1; i < n; i++) {
        double pr=double(pt)/double(pa);
        ll nt=t[i];
        ll na=a[i];
        double nr=double(nt)/double(na);
        if(pr>1){
            if(nr>pr){
                pa=((pa+na-1)/na)*na;
                pt=pa/na*nt;
            }
            else{
                pt=((pt+nt-1)/nt)*nt;
                pa=pt/nt*na;
            }
        }
        else{
            if(nr<pr){
                pt=((pt+nt-1)/nt)*nt;
                pa=pt/nt*na;
            }
            else{
                pa=((pa+na-1)/na)*na;
                pt=pa/na*nt;
            }
        }
    }
    cout << pt+pa << "\n";

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,i,ans;
    cin >> n;
    vector<int> a(n);
    for(i=0;i<n;i++) cin >> a.at(i);
    for(i=0;i<n;i++){
        if(i==a.at(a.at(i)-1)-1)ans++;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i = 0; i < n; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  cout << A.back() << " ";
  int t = n-1;
  for(int i = 0; i < n-1; ++i){
    if(2*A[i] >= A.back()){
      t = i;
      break;
    }
  }
  if(t == 0) cout << A[0] << endl;
  else{
    if(abs(2*A[t] - A.back()) < abs(2*A[t-1] - A.back())) cout << A[t] << endl;
    else cout << A[t-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 640
"""def power(x, y): 
    res = 1
    x=x
    while (y > 0): 
        if ((y & 1) == 1) : 
            res = (res * x) 
        y = y >> 1
        x = (x * x)
    return res""" 
"""def fact(n):
    if(n==0):
        return 1
    if(n==1):
        return 1
    return fact(n-1)+fact(n-2)"""

import math
#import combinations
#t=int(input())
#for _ in range(t):
#n=int(input())
arr=list(input().strip())
#n,m=map(int,input().split())
#count=0
n=len(arr)
flag=1
for i in range(n//2):
    if(arr[i]!=arr[n-i-1]):
        flag=0
        break
for i in range(((n-1)//2)//2):
    if(arr[i]!=arr[(n-1)//2-i-1]):
        flag=0
for i in range((n+3)//2 - 1 ,n):
    if(arr[i]!=arr[n-i-1]):
        flag=0
if(flag==1):
    print("Yes")
else:
    print("No")


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

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

    int kmax = (n-1)*(n-2)/2;
    if(k > kmax){
        cout << -1 << endl;
        return 0;
    }

    cout << (n-1) + (kmax-k) << endl;
    for(int i=2; i<=n; i++){
        cout << 1 << " " << i << endl;
    }
    int count = 0;
    for(int i=2; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            if(count == kmax - k) return 0;
            cout << i << " " << j << endl;
            count += 1;
        }
    }
    return 0;
}

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


int main()
{
    int n;
    cin >> n;
    int h[100001];
    for(int i=0; i<n; i++) cin >> h[i];

    for(int i=0; i<n-1; i++){
        if(h[i] < h[i+1]) h[i+1]--;
        if(h[i] > h[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }

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

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  string s;
  cin>>s;
  if(s=="ABC")puts("ARC");
  else puts("ABC");

}

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

int main() {
  int N,A,B,C,D;
  cin >>A>>B>>C>>D;
  N=0;
  while(A>0&&C>0){
    if(N%2==0){
      C-=B;
    }
    else{
      A-=D;
    }
    N++;
  }
  if(A>0){
    cout <<"Yes"<< endl;
    return 0;
  }
  cout <<"No"<< endl;
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb  = new StringBuilder(sc.next());

		List<StringBuilder> wordsList = new ArrayList<StringBuilder>();
		wordsList.add(new StringBuilder("dreamer"));
		wordsList.add(new StringBuilder("dream"));
		wordsList.add(new StringBuilder("erase"));
		wordsList.add(new StringBuilder("eraser"));

		sb = sb.reverse();
		for (StringBuilder word : wordsList) {
			word = word.reverse();
		}
		while (sb.length() > 0) {
			boolean hitFlg = false;

			for (StringBuilder word : wordsList) {
				if (sb.indexOf(word.toString()) == 0) {
					sb.delete(0, word.length());
					hitFlg = true;
					break;
				}
			}
			if (!hitFlg) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}

}


Measured memory_bytes: 28656
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = inp()
m = int(n)

ans = 0

for i in range(len(n)):
    ans += int(n[i])

ans %= 9

if ans == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9284
// In God We Trust


# include <bits/stdc++.h>
using namespace std;

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second

signed main(){
  int n;
  cin >> n;
  int mod;
  for (int i = 5; i >= 0; i--){
    mod = n % 100;
    if (mod == 0){
      cout << 1 << endl;
      return 0;
    }
    n -= (mod / i) * (100 + i);
    if (n < 0){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>

// #define int long は変なところでハマる可能性がるのでやらない。

int main()
{
	int N, A, B;
	std::cin >> N >> A >> B;

	std::cout << std::min(A, B) << " " << std::max(0, A + B - N) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
typedef long long ll;
using namespace std;

int main(){
  int x,ans = 0;
  scanf("%d",&x);
  
  int t,sum = 0;
  if(abs(x) >= 0){
    for(t = 1;;t++){
      sum += t;
      if(sum >= abs(x))break;
    }
  }

  printf("%d",t);
  return 0;
}

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

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    long long r, g, b, n;
    std::cin >> r >> g >> b >> n;

    long long count = 0;
    for (int i = 0; i <= n / r; i++) {
        for (int j = 0; j <= n / g; j++) {
            int k = n - i * r - j * g;
            if (k >= 0 && k % b == 0) {
                count++;
            }
        }
    }

    std::cout << count << std::endl;
}


Measured memory_bytes: 256
n=int(input())
x=[]
for k in range(n):
  x.append(input())
x.sort()
count=[1]
head=[0]
for k in range(1,n):
  if x[k]!=x[k-1]:
    head.append(k)
    count.append(1)
  else:
    count[-1]+=1
maxim=max(count)
for k in range(len(count)):
  if count[k]==maxim:
    print(x[head[k]])

Measured memory_bytes: 28640
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>
#include <climits>

using namespace std;

typedef struct {
  char name[11];
  int time;
} PROCESS;

int head;
int tail;

#define MAX 1000001

PROCESS Q[MAX];

void initizie(){
  head = tail = 0;
}

int isEmpty(){
  return head == tail;
}

int isFull(){
  return head == (tail+1) % MAX;
}

int enqueue(PROCESS p){
  if(isFull())
    return -1;
  memcpy(&Q[tail],&p,sizeof(PROCESS));
  if(tail+1==MAX)
    tail=0;
  else
    tail++;
  return 0;
}

PROCESS dequeue(){
  PROCESS p;
  memset(&p,0,sizeof(PROCESS));
  if(isEmpty())
    return p;

  memcpy(&p,&Q[head],sizeof(PROCESS));
  if(head+1==MAX)
    head=0;
  else
    head++;
  return p;
}

int main(){
  int n,q,t=0;
  PROCESS P;

  initizie();

  scanf("%d %d\n",&n,&q);
  for(int i=0;i<n;i++){
    scanf("%s %d\n",P.name,&P.time);
    if(P.time<=q){
      printf("%s %d\n",P.name,P.time+t);
      t+=P.time;
    }
    else {
      P.time-=q;
      t+=q;
      enqueue(P);
    }
  }
  for(int i=0;!isEmpty();i++) {
    P=dequeue();
    if(P.time<=q){
      printf("%s %d\n",P.name,P.time+t);
      t+=P.time;
    }
    else {
      P.time-=q;
      t+=q;
      enqueue(P);
    }
  }
}



Measured memory_bytes: 5256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,x,n) for(ll i=x;i<n;i++)
#define fl(i,x,n) for(ll i=n;i>=x;i--)
#define mod (ll)1e9+7
#define print(x) cout<<x<<endl
#define vec vector<ll>
#define pai pair<ll, ll>
#define itr(it) :: iterator it
#define MAX (ll)1e16
#define MIN (ll)-1e16
#define X first
#define Y second
#define up upper_bound
#define lo lower_bound
using namespace std;
       ///////////   ///     ///   ///      ///   ////////////  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///////////   ///      ///   ////////////  ////////////
               ///   ///     ///   ///      ///   ///      ///  ///      ///
               ///   ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///     ///   ////////////   ////////////  ///      ///
ll minn( ll a , ll b) 
{
    if(a>b)
        return b;
    return a;
}
ll maxx2( ll a , ll b)
{
    if(a>b)
        return a;
    return b;
}
ll maxx(ll a,ll b,ll c)
{
  return maxx2(a,maxx2(b,c));
}
ll gcdd(ll a, ll b)
{
    if(b==0)
        return a;
    else
        return gcdd(b,a%b);
}
ll dsum(ll n)
{
    ll sum=0;
    while(n>0)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}
ll poww(ll a,ll b)
{
    if(b<=0)
        return 1;
    if(b==1)
        return a;
    else
        return poww(a,b/2)*poww(a,b/2)*poww(a,b%2);
}
ll sumsq(ll x,ll y,ll z)
{
    return (x-y)*(x-y)+(y-z)*(y-z)+(z-x)*(z-x);
}
ll n,a[200001],dp[200001]={0};
ll solve(ll i)
{
    if(dp[i]!=-1)
        return dp[i];
    if(i<=0)
    {
        return 0;
    }
    if(i==1)
    {
        dp[1]=abs(a[1]-a[0]);
        return abs(a[1]-a[0]);
    }
    dp[i] =minn(abs(a[i]-a[i-1])+solve(i-1),abs(a[i]-a[i-2])+solve(i-2));
    return dp[i];
}
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    IOS;
    cin>>n;
    f(i,0,n)
    {
        cin>>a[i];
    }
    f(i,0,n)
    {
        dp[i]=-1;
    }
    ll ans=solve(n-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3456
package main

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

var INF = math.MaxInt32
var INF64 = math.MaxInt64

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []float64{}
	for _, field := range fields {
		num, _ := strconv.ParseFloat(field, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func dfs(dp [][][]float64, a, b, c, N int) float64 {
	if a == 0 && b == 0 && c == 0 {
		return 0.0
	}
	if dp[a][b][c] > -0.1 {
		return dp[a][b][c] // 已经有值, 则不需要重复计算
	}

	ans := 0.0
	e := float64(N)/float64(a+b+c) // 平均需要e步, 才能选中a,b,c中的一个
	if a > 0 {
		p := float64(a) / float64(a+b+c)
		ans += p*(dfs(dp, a-1, b, c, N)+e)
	}
	if b > 0 {
		p := float64(b) / float64(a+b+c)
		ans += p*(dfs(dp, a+1, b-1, c, N)+e)
	}
	if c > 0 {
		p := float64(c) / float64(a+b+c)
		ans += p*(dfs(dp, a, b+1, c-1, N)+e)
	}

	dp[a][b][c] = ans
	return ans
}

func main() {
	bf := bufio.NewReader(os.Stdin)
	N := readLineNums(bf)[0]
	A := readLineNums(bf)
	/*
		定义:
			dp[i][j][k]: 表示有i个碟子剩1个, j个碟子剩2个, k个碟子剩3个, 需要操作次数
		初始值:
			dp[a][b][c]=0, a b c为初始状态时, 数量为1 数量为2 数量为3的碟子数
		转移方程:
			dp[i][j][k]
				i,j,k可以转换到下面的状态
					dp[i-1][j][k]
					dp[i+1][j-1][k]
					dp[i][j+1][k-1]

				i,j,k可以由下面的状态转化
					dp[i-1][j+1][k] // 选中剩余数量为2的碟子
					dp[i+1][j][k] // 选中剩余数量为1的碟子
					dp[i][j-1][k+1] // 选中剩余数量为3的碟子
		答案:
			dp[0][0][0]
	*/
	a, b, c := 0, 0, 0
	for _, n := range A {
		if n == 1 {
			a++
		}
		if n == 2 {
			b++
		}
		if n == 3 {
			c++
		}
	}

	dp := make([][][]float64, N+1)
	for i := range dp {
		dp[i] = make([][]float64, N+1)
		for j := range dp {
			dp[i][j] = make([]float64, c+1)
			for k := range dp[i][j] {
				dp[i][j][k] = -1.0
			}
		}
	}

	fmt.Println(dfs(dp, a, b, c, N))
}


Measured memory_bytes: 256992
def is_month (n)
  1 <= n and n <= 12
end

def is_year(n)
  0 <= n and n <= 99
end

s = gets.chomp
f, l = s[0,2].to_i, s[2,2].to_i
 
if is_month(f) and is_month(l)
  puts "AMBIGUOUS"
elsif is_year(f) and is_month(l)
  puts "YYMM"
elsif is_month(f) and is_year(l)
  puts "MMYY"
else
  puts "NA"
end


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#define X_MAX 300001
using namespace std;

bool isMSP[X_MAX];
vector<int> msp;

void make() {
  bool flag = true;
  fill(isMSP, isMSP+X_MAX, true);
  for(int i = 0; i <= 5; ++i) isMSP[i] = false;
  for(int i = 6; i < X_MAX; i += (flag) ? 2 : 5, flag = !flag) {
    if(!isMSP[i]) continue;
    msp.push_back(i);
    for(int j = i*2; j < X_MAX; j += i) isMSP[j] = false;
  }
}

void solve(int x) {
  cout << x << ":";
  for(int i = 0; i < msp.size() && msp[i] <= x ; ++i) {
    if(x % msp[i] == 0) cout << " " << msp[i];
  }
  cout << endl;
}

main() {
  int x;
  make();
  while((cin >> x) && x != 1) {
    solve(x);
  }
}

Measured memory_bytes: 1464