akhauriyash/Code-Regression huggingface dataset:
<?php
// input取得パターン（横並び2）
fscanf(STDIN, "%s", $s);
$arr = array('Sunny','Cloudy','Rainy');

$result = array_search($s, $arr);

if($result+1 >= count($arr)){
  $result = 0;
}else{
  $result ++;
}
echo $arr[$result];


Measured memory_bytes: 4856
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007 
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1 == p2)?EOF:*p1++)
using namespace std ;
//char buf[(1 << 22)] , *p1 = buf , *p2 = buf ;
inline int read ()
{
    char c = getchar () ; int x = 0 , f = 1 ;
    while (c < '0' || c > '9') { if (c == '-') f = -1 ; c = getchar () ; }
    while (c >= '0' && c <= '9'){ x = x * 10 + c - '0' ; c = getchar () ; }
    return x * f ;
}
int f[20][2][2] , a[20] , n , len , ans ;
int GetAns (int x)
{
//	cout << x << "\n" ;
	memset (f , 0 , sizeof (f)) ;
	f[0][0][0] = 1 ;
	int lim = x / 2 , ret = 0 ;
	for (int i = 0 ; i < lim ; i ++)
		for (int j = 0 ; j <= 1 ; j ++)
			for (int k = 0 ; k <= 1 ; k ++)
				if (f[i][j][k])
					for (int l = 0 ; l <= 9 ; l ++)
					{
						int A = l + a[i + 1] + k , num = A % 10 ;
						int K = A / 10 , J = j * 10  + l - num - a[x - i] ;
						if (J < 0 || J > 1) continue ;
						if (! i && (! l || ! num)) continue ;
						f[i + 1][J][K] += f[i][j][k] ;
					}
	if (x & 1)
		for (int i = 0 ; i <= 1 ; i ++)
			for (int j = 0 ; j <= 1 ; j ++)
			{
				if (f[lim][i][j])
					for (int k = 0 ; k <= 9 ; k ++)
					{
						int num = k + a[(x + 1) / 2] + j ;
						if (num % 10 == k && num / 10 == i) ret += f[lim][i][j] ;
					}
			}
	else for (int i = 0 ; i <= 1 ; i ++) ret += f[lim][i][i] ;
	return ret ;
}
signed main ()
{
//	freopen ("mirrored.in" , "r" , stdin) ; freopen ("mirrored.out" , "w" , stdout) ;
	cin >> n ; 
	int tmp = n ;
	while (tmp)
	{
		a[++ len] = tmp % 10 ;
		tmp /= 10 ;
	}
	for (int i = len ; i <= len * 2 ; i ++)
		ans += GetAns (i) ;
	cout << ans ;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	final int mod = 1000000007;
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		combi(4, 3);
		for(int i=1; i<=k; i++) {
			//n-k+1 C i * k-1 C i-1
			long ans = combi(n-k+1, i) * combi(k-1, i-1);
			ans %= mod;
			System.out.println(ans);
		}

		sc.close();
	}

	private long fact(long x) {
		long ans = 1;
		for(int i=1; i<=x; i++) {
			ans *= i;
			ans %= mod;
		}
		return ans;
	}

	private long pow(long x, long n) {
		if(n==0) return 1;
		if(n%2==0) {
			long tmp = pow(x, n/2);
			return tmp * tmp % mod;
		}else {
			long tmp = pow(x, n-1);
			return tmp * x % mod;
		}
	}

	private long inv(long x) {
		return pow(x, mod-2);
	}

	private long combi(long n, long k) {
		if(n<k) return 0;
		if(k==0) return 1;
		long ans = 0;
		ans = ((fact(n) * inv(fact(n-k)) % mod) * inv(fact(k))) % mod;
		return ans;
	}
}


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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		long[] a = new long[n];
		long length = 0;
		for (int i=0; i<n; i++) {
			a[i] = in.nextInt();
			length += a[i];
		}

		long left = 0;
		long closest = Integer.MAX_VALUE;
		for (int i=0; i<n; i++) {
			left += a[i];
			long right = length - left;
			if (Math.abs(left - right) < closest)
				closest = Math.abs(left - right);
		}

		System.out.println(closest);
	}
}



Measured memory_bytes: 88828
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int N,M,X; cin >> N >> M >> X;
  int i, tmp, L = 0, R = 0;
  rep(i,M){
      cin >> tmp;
      if(tmp < X){L++;}else{R++;}
  }

  cout << min(L,R) << endl;

  return 0;
}


Measured memory_bytes: 3608
// D - Not Divisible
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

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

	int mx = 0;
	map<int,int> m;
	rep(i, N){
		int a; cin>>a;
		m[a]++;
		mx = max(mx, a);
	}

	int ans = 0;
	vi l(mx+1, 0);
	for(auto x:m){
		int a, c; tie(a, c) = x;
		// if(c > 1) continue;
		// cout<<" a "<<a<<"\n";
		if(c == 1 && l[a] == 0){
			ans++;
		}
		for(int i=a; i<=mx; i+=a){
			// cout<<" i "<<i<<"\n";
			l[i] = 1;
		}
	}

	// for(auto x:m){cout<<x.first<<" "<<x.second<<"\n";}
	// for(auto x:l){cout<<x<<" ";}
	// puts("");/////////////

	cout<< ans <<endl;
}


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

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

  vector<int> tree(N);
  for(int i = 0; i < N; i++) {
    cin >> tree.at(i);
  }

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

  int mini = 1000000000;
  for(int i = 0; i <= N - K;i++) {
  int s = tree.at(i + K - 1) - tree.at(i);
  mini = min(s,mini);
  }

  cout << mini << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

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

ll rec (ll val) {
	if (val >= 2) {
		return 1 + rec (val / 2) * 2;
	}
	return 1;
}
	
int main () {
	ll h;
	cin >> h;
	cout << rec (h) << "\n";	
}


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

using namespace std;


int main() {
    string a,b;
    cin>>a>>b;
    int n=a.size();
    int m=b.size();
    //cout<<a[0]<<endl<<b<<endl;
    int ar[n+1][m+1];

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0||j==0)
            {
                ar[i][j]=0;
                continue;
            }
            if(a[i-1]==b[j-1])
            {
                ar[i][j]=ar[i-1][j-1]+1;
                //cout<<a[i-1]<<b[j-1]<<" ";
            }
            else
            {
                ar[i][j]=max(ar[i-1][j],ar[i][j-1]);
            }
        }
    }
    
    string s="";
    int k=1;
    int i=n;
    int j=m;
    while(k)
    {   if(i>0&&j>0)
        {
            if(ar[i][j]==ar[i-1][j])
            {
                i--;
            }
            else if(ar[i][j]==ar[i][j-1])
            j--;
            else
            {   
                //cout<<a[i]<<endl;
               s=s+(a[i-1]);
               i--;
               j--; 
            }
        }
        else
        {
            k=0;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 35456
a=int(input())
ans=[]
la=input().split()
lis=[[int(la[i]),i] for i in range(a)]
lis=sorted(lis)
for i in range(a):
  if i!=a-1:
  	print(lis[i][1]+1,end=" ")
  else:
    print(lis[i][1]+1)

Measured memory_bytes: 27252
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main(){

  int n,x,i;
  list <int> a;
  list<int>::iterator it;
  string com;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>com;
    if(com=="deleteFirst") a.pop_front();
    else if(com=="deleteLast") a.pop_back();
    else{
      cin>>x;
      if(com=="insert") a.push_front(x);
      else for(it=a.begin();it!=a.end();it++) if(*it==x){
            a.erase(it);
            break;
          }
    }
  }
  i=0;
  for(it=a.begin();it!=a.end();it++){
    if(i++) cout<<" ";
    cout<<*it;
  }
  cout<<endl;

  return 0;

}



Measured memory_bytes: 34332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> PII;
typedef pair<ll,ll> Pll;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef pair<ll,ll>P;
#define N  1000000+10
#define M  4000000+10
#define INF 1e9
#define fi first
#define se second
#define MP make_pair
#define pb push_back
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define per(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define lowbit(x) x&(-x)
#define Rand (rand()*(1<<16)+rand())
#define id(x) ((x)<=B?(x):m-n/(x)+1)
#define ls p<<1
#define rs p<<1|1
#define fors(i) for(auto i:e[x]) if(i!=p)

const int MOD=1e9+7,inv2=(MOD+1)/2;

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



int read()
{
  int v=0,f=1;
  char c=getchar();
  while(c<48||57<c)
  {
    if(c=='-') f=-1;
    c=getchar();
  }
  while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
  return v*f;
}

ll readll()
{
  ll v=0,f=1;
  char c=getchar();
  while(c<48||57<c)
  {
    if(c=='-') f=-1;
    c=getchar();
  }
  while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
  return v*f;
}

int main()
{
   int a=read();
int b=read();
int s;
if(a!=3&&b!=3)
    s=3;
if(a!=1&&b!=1)
    s=1;
    if(a!=2&&b!=2)
    s=2;


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


Measured memory_bytes: 256
n, w = map(int, input().split())

dp = [[float('inf') for _ in range(10**5+1)] for i in range(n)]

v_sum = 0

for i in range(n):
    wi, vi = map(int, input().split())
    v_sum += vi
    if i == 0:
        dp[i][0] = 0
        dp[i][vi] = wi
    else:
        for k in range(v_sum+1):
            if k < vi:
                dp[i][k] = dp[i-1][k]
            else:
                dp[i][k] = min(dp[i-1][k], dp[i-1][k-vi]+wi)

for i in range(v_sum, -1, -1):
    if dp[n-1][i] <= w:
        print(i)
        exit()


Measured memory_bytes: 311412
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, x;
	int d[100];
	int ans;
	
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		x -= d[i];
	}
	
	sort(d, d + n);
	
	ans = (x / d[0]) + n;
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {
    
    int K,X;
    cin >> K >> X;
    string out ="No";
    if(K*500>=X) out = "Yes";
    cout << out << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

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

	int n, k;
	cin >> n >> k;
	int a = k;
	int cnt = 1;

	while (true) {
		if (n <= k - 1) break;
		k *= a;
		cnt++;
	}
	
	cout << cnt << endl;




	return 0;
}


Measured memory_bytes: 3552
n=int(input())
L=[int(i) for i in input().split()]
A=[0 for i in range(n)]
mod=998244353

for num in L:
    
    A[num]+=1

if A[0]!=1 or L[0]!=0:
    print(0)
else:
    ans=1
    for i in range(n-1):
        ans*=A[i]**A[i+1]
        ans=ans%mod
    print(ans%mod)

Measured memory_bytes: 14396
n = int(input())
plus = {}

for i in range(n):
    a = input()
    if a in plus.keys():
        plus[a] += 1
    else:
        plus[a] = 1

m = int(input())
minus = {}
for i in range(m):
    a = input()
    if a in minus.keys():
        minus[a] += 1
    else:
        minus[a] = 1

mv = 0
for i in plus.keys():
    if i in minus.keys():
        t = plus[i] - minus[i]
    else:
        t = plus[i]
    mv = max(t, mv)

print(mv)


Measured memory_bytes: 3064
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 100001
#define int long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
const int maxn=10000000000ll;
map<int,int> e;
bool vis[10001];
int cnt,p[1001];
int n,ans,s[N],d[N],inv[N],mx;
bool tag[N];
main()
{
//	open(D);
	mx=ceil(pow(maxn,1/3.0))+3;
	re(n);
	for(int i=1;i<=n;++i)
		re(s[i]),d[i]=1;
	for(int i=2;i<=mx;++i)
	{
		if(!vis[i])
			p[++cnt]=i;
		for(int j=1,k;j<=cnt && (k=i*p[j])<=mx;++j)
		{
			vis[k]=1;
			if(i%p[j]==0)break;
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=cnt;++j)
			while(s[i]%(p[j]*p[j]*p[j])==0)
				s[i]/=p[j]*p[j]*p[j];
		++e[s[i]];
		inv[i]=s[i];
		for(int j=1;j<=cnt;++j)
		{
			if(inv[i]%(p[j]*p[j])==0)d[i]*=p[j];
			else if(inv[i]%p[j]==0)d[i]*=p[j]*p[j];
			while(inv[i]%p[j]==0)inv[i]/=p[j];
			//if(d[i]>maxn)d[i]=0;
		}
		if (inv[i] == 1) continue;
		int w=sqrt(inv[i]);
		if(w*w==inv[i])d[i]*=w;
		else d[i] *= inv[i]*inv[i];
	}
	if(e[1])++ans,e[1]=0;
	for(int i=1;i<=n;++i)
		ans+=max(e[s[i]],e[d[i]]),e[s[i]]=e[d[i]]=0;
	printf("%lld\n",ans);
}

Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (){
    int N,M,p[100000];
    string S[100000];
    bool ac_check[100000];
    bool is_ac[100000];
    for(int i = 0;i<M;i++){
        ac_check[i] = 0;
        is_ac[i] = 0;
    }

    cin >> N;
    cin >> M;
    for(int i = 0;i<M;i++){
        cin >> p[i] >> S[i];
      	if(S[i] == "AC")
        is_ac[p[i]] = 1;
    }
    int ac = 0;
    int wa = 0;

    for(int i = 0;i<M;i++){
        if(S[i]== "AC"&&!ac_check[p[i]]){
            ac_check[p[i]] = 1;
            ac++;
        }
        if(S[i]== "WA"&&!ac_check[p[i]]&&is_ac[p
        [i]]){
            wa++;
        }
    }
    
    cout << ac << " " << wa << endl;
    
    

    
    return 0;
}


Measured memory_bytes: 6272
use std::io::*;
use std::str::*;

// const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let a: usize = read().unwrap();
    let b: usize = read().unwrap();
    let c: usize = read().unwrap();
    let k: usize = read().unwrap();

    let mut mx = std::cmp::max(a, b);
    mx = std::cmp::max(mx, c);

    let mut sum = a + b + c - mx;
    for _ in 0..k {
        mx *= 2;
    }
    println!("{}", mx + sum);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost; 
    int a,b,x;
    cin>>a>>b>>x;
    if(x==a*a*b)
    {
        cout<<fixed << setprecision(9)<<0.0;return 0;
    }
    double tn;
    if(2*x<=a*a*b)
    {
       tn=(double)2*x/((double)a*b*b);
    }
    else
    {
        tn=(((double)a*a*a)/2) / (a*a*b-x);
    }
    cout<<fixed << setprecision(9)<<90-atan(tn)*180/(3.14159265);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int cnt[N+2],vis[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n,m;cin>>n>>m;int ans=0;
  while(m--)
  {
    int x;string s;cin>>x>>s;
    if(s=="AC")
    {
      if(vis[x])continue;
      ans+=cnt[x];vis[x]=1;
    }
    else
    {
      cnt[x]++;
    }
  }
  int one=0;
  for(int i=1;i<=n;i++)one+=vis[i];cout<<one<<" "<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4736
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

int dx8[8] = { -1,-1,-1, 0, 1, 1, 1, 0 };
int dy8[8] = { -1, 0, 1, 1, 1, 0,-1,-1 };
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>>nums(H + 2, vector<int>(W + 2));
	for (int i = 0; i < H; ++i) {
		string st; cin >> st;
		for (int j = 0; j < W; ++j) {
			if (st[j] != '.') {
				nums[i+1][j+1] = st[j] - '0';
			}
		}
	}
	queue<pair<int, int>>que;
	vector<vector<int>>newnums(nums);
	for (int y = 1; y < H + 1; ++y) {
		for (int x = 1; x < W + 1; ++x) {
			if (nums[y][x] <= 0) {
				for (int way = 0; way < 8; ++way) {
					const int ax = x + dx8[way];
					const int ay = y + dy8[way];
					newnums[ay][ax]--;
					if (!newnums[ay][ax]) {
						que.push(make_pair(ax, ay));
					}
				}
			}
		}
	}
	nums = newnums;
	int ans = 0;
	while (!que.empty()) {
		queue<pair<int, int>>newque;
		while (!que.empty()) {
			auto p(que.front());
			que.pop();
			const int x = p.first;
			const int y = p.second;
			for (int way = 0; way < 8; ++way) {
				const int ax = x + dx8[way];
				const int ay = y + dy8[way];
				nums[ay][ax]--;
				if (!nums[ay][ax]) {
					newque.push(make_pair(ax, ay));
				}
			}
		}
		que = newque;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10836
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  string s = to_string(a) + to_string(b);
  ll x = atoi(s.c_str());
  for (int i = 0; i * i <= x; i++) {
    if (i * i == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
mat(co,9,9);
void solve(long long N){
  rep(i,9){
    rep(j,9){
      ll cnt=0;
      repf(k,1,N+1){
        if(k%10==j+1){
          ll t=k;
          ll last;
          while(t!=0){
            last=(t%10);
            t/=10;
          }
          if(last==i+1){
            cnt++;
          }
        }
      }
      co[i][j]=cnt;
    }
  }
  ll ans=0;
  rep(i,9){
    rep(j,9){
      ans+=co[i][j]*co[j][i];
    }
  }
  op(ans)
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

const long long MOD = 998244353;

long long fact[3000005];

long long powmod(long long a, long long b){
    long long x = 1;
    long long y = a;
    while(b){
        if(b&1){ x = (x*y)%MOD; }
        y = (y*y)%MOD;
        b >>= 1;
    }
    return x;
}

inline long long ncr(long long a, long long b){
    return fact[a]*powmod((fact[a-b]*fact[b])%MOD, MOD-2)%MOD;
}

long long solve(int N, int sum, int k){
    // exactly N non-negative integers
    // the sum is the variable sum
    // exactly k odd
    if((sum-k)&1){return 0;}
    if(sum-k<0){return 0;}

    // Let's make the k odd integers non-negative even integers
    // Then, the sum becomes (sum-k) and we can then divide by 2 to normalise the non-negative integers
    // The integers can now be any non-negative integer, without any other restriction, so formula can be used.
    // (((sum-k)/2)+(N-1)) choose (N-1) ways to make such integers

    // Don't forget that there are N choose k ways to arrange the odd integers.
    return ncr(N, k)*ncr( ((sum-k)>>1)+(N-1) , N-1)%MOD;
}

int main(){
    int N, M;
    scanf("%d%d", &N, &M);

    fact[0] = 1;
    for(int i = 1; i <= 3000004; i ++){
        fact[i] = (fact[i-1]*i)%MOD;
    }

    // Let us ignore the maximum integer rule and count the number of ways
    // There can only be at most M odd integers.
    long long temp1 = 0;
    for(int k = 0; k <= min(M, N); k ++){
        temp1 += solve(N, 3*M, k);
        //printf("solve(%d, %d, %d)=%lld\n", N, 3*M, k, solve(N, 3*M, k));
    }
    temp1 %= MOD;

    // Notice that the maximum integer cannot exceed 2M. There can only be a maximum of one violation
    // because 2M+2M = 4M > 3M, a contradiction. Hence, there are N ways to choose the violating integer.
    // Then, we can subtract 2M from the offending integer. 2M is even, hence there is no effect on parity.
    // Conditions remain the same as before, except that the offending integer must be positive.
    long long temp2 = 0;
    for(int k = 0; k <= min(M, N); k ++){
        temp2 += solve(N, M, k);
    }
    temp2 %= MOD;
    temp2=temp2*N%MOD;

    // Now, we count number of ways such that the offending integer is 0 because we have over-subtracted those cases.
    // There are only N-1 integers left since the offending integer can be removed, and that the number of odd
    // integers would remain the same since M is even.
    long long temp3 = 0;
    for(int k = 0; k <= min(M, N-1); k ++){
        temp3 += solve(N-1, M, k);
    }
    temp3 %= MOD;
    temp3=temp3*N%MOD;

    //printf("temp1=%lld temp2=%lld temp3=%lld\n", temp1, temp2, temp3);

    long long ans = (temp1-temp2+temp3+MOD*3)%MOD;
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 23680
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;


//class Prime {
//private:
//	vector<int> min_pf; // min_pf[i] = minimum prime factor of i
//	vector<int> prime;
//
//	// linear sieve https://cp-algorithms.com/algebra/prime-sieve-linear.html
//	void sieve(int N) {
//		min_pf[0] = min_pf[1] = -1;
//		for (int i = 2; i < N; i++) {
//			if (min_pf[i] == 0) {
//				prime.emplace_back(i);
//				min_pf[i] = i;
//			}
//			for (int j = 0; j < (int)(prime.size()); ++j) {
//				if (prime[j] > min_pf[i] || i * prime[j] >= N) break;
//				min_pf[i * prime[j]] = prime[j];
//			}
//		}
//	}
//
//public:
//	Prime(int N = 110000000) : min_pf(N + 1) { sieve(N + 1); }
//
//	vector<pair<Int, int>> factorize(Int n) {
//		vector<pair<Int, int>> res;
//		Int sz = (Int)min_pf.size();
//
//		for (Int i = 2; i * i <= n; i++) {
//			if (n < sz) break;
//			int cnt = 0;
//			while (n % i == 0) {
//				cnt++;
//				n /= i;
//			}
//			if (cnt) res.emplace_back(i, cnt);
//		}
//
//		if (n >= sz) res.emplace_back(n, 1);
//		else {
//			int prev = min_pf[n], cnt = -1;
//			while (n > 0) {
//				int now = min_pf[n];
//				n /= now;
//				cnt++;
//				if (prev != now) {
//					res.emplace_back(prev, cnt);
//					prev = now;
//					cnt = 0;
//				}
//			}
//		}
//
//		return res;
//	}
//
//	// verified using boost miller_rabin_test https://wandbox.org/permlink/6YepW3J9SQNFwWxu
//	bool isPrime(Int n) {
//		if (n < (int)(min_pf.size())) return min_pf[n] == n;
//		else if (n == 2 || n == 3) return true;
//		else if (n % 2 == 0 || n % 3 == 0) return false;
//		else if (n % 6 != 1 && n % 6 != 5) return false;
//		for (Int i = 5; i * i <= n; i += 6) {
//			if (n % i == 0) return false;
//			if (n % (i + 2) == 0) return false;
//		}
//		return true;
//	}
//};

bool isPrime(Int n) {
	if (n == 2 || n == 3) return true;
	else if (n % 2 == 0 || n % 3 == 0) return false;
	else if (n % 6 != 1 && n % 6 != 5) return false;
	for (Int i = 5; i * i <= n; i += 6) {
		if (n % i == 0) return false;
		if (n % (i + 2) == 0) return false;
	}
	return true;
}

int main() {

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

	Int N;
	cin >> N;

	map<Int, Int> cnt;

	Int temp;
	for (Int i = 2; i <= N; i++) {
		if (isPrime(i)) {
			temp = i;
			while (temp <= N) {
				cnt[i] += N / temp;
				temp *= i;
			}
		}
	}

	Int ans=0;

	Int c2 = 0;
	Int c4 = 0;
	Int c14 = 0;
	Int c24 = 0;
	Int c74 = 0;

	for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
		if (itr->second >= 2)c2++;
		if (itr->second >= 4)c4++;
		if (itr->second >= 14)c14++;
		if (itr->second >= 24)c24++;
		if (itr->second >= 74)c74++;
	}

	
	if(c74)ans += c74;
	if (c4) {
		if (c2 >= 2) {
			ans +=c4*(c4-1)/2*(c2-2) ;
		}
	}
	if (c4)ans += c14 * (c4 - 1);
	if (c2)ans += c24 * (c2 - 1);

	cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std; int dp[999][2]; int dx[6] = { 1,-1,-2,-1,1,2 };
int main() {
	dp[0][0] = 2; for (int i = 1; i < 999; i++) { dp[i][0] = (dp[i - 1][0] * 2) % 1000000; }
	dp[0][1] = 4; dp[1][1] = 12; for (int i = 2; i < 999; i++) { int Z = dx[i % 6]; dp[i][1] = (dp[i - 1][1] * 3 + dp[i - 2][1] + Z) % 1000000; }
	int H, W; cin >> H >> W; cout << dp[H - 1][W - 1] << endl;
	return 0;
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}

 
int main() {
  string N, ans;
  cin >> N;

  int len = N.length()-1;
  if(N[len] == '0'|| N[len] == '1' || N[len] == '6' || N[len] == '8'){
    ans = "pon";
  }else if(N[len] == '3'){
    ans = "bon";
  }else{
    ans = "hon";
  }

  cout << ans << endl;
}

Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i=0; i<n; i++) cin>>s[i]>>t[i];
    string x; cin>>x;

    int ans = -1;
    for(int i=0; i<n; i++){
        if(0 <= ans) ans += t[i];
        if(s[i] == x) ans = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> A(N);
    rep(i,N){
        cin>>A[i];
    }

    ll ans =A[0];
    rep(i,N-1){
        ans = gcd(ans,A[i+1]);
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 4016
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int coin = 0;
        coin = (x-a);
        coin = (coin%b);
        System.out.println(coin);
    }
}

Measured memory_bytes: 21844
N = int(input())
A = []
ans = -100000000

for i in range(N):
    A.append(input())

M = int(input())
B = []

for i in range(M):
    B.append(input())

for c in A:
    X = A.count(c) - B.count(c)
    ans = max(ans, X)

if ans <= 0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<map>
#include<string>
using namespace std;

int main() {
	string s; cin >> s;
	map<char, int> ans;

	for (int i = 0; i < s.length(); i++) {
		ans[s[i]] += 1;
	}

	for (map<char,int>::iterator i = ans.begin(); i != ans.end(); i++) {
		if (i->second % 2) {
			cout << "No" << endl;
			return 0;
		}
	}

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

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

int main() {
    int N,i,j;
    double sum;
    cin >> N;
    cout << fixed << setprecision(7);
    vector<double> vec(N);
    for (i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    for (i = 1; i < N; i++){
        std::sort(vec.begin(),vec.end());
        sum = (vec.at(0) + vec.at(1))/2;
        vec.at(0) = sum;
        for (j = 1; j < N-i; j++){
            vec.at(j) = vec.at(j+1);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b) cout<<0;
    else if(n==1){
        if(a==b) cout<<1;
        else cout<<0;
    }
    else cout<<(b-a)*(n-2)+1;
}

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

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

    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    unordered_map<int, bool> check;

    int current = 1;
    check[1] = true;

    int ans = 0;
    while (1) {
        if (current == 2) {
            cout << ans << endl;
            return 0;
        }

        current = a[current - 1];

        if (check[current]) {
            cout << -1 << endl;
            return 0;
        }

        check[current] = true;
        ans++;
    }

    return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
 
#define hell 998244353
#define PI acos(-1.0)
#define S second
#define F first
#define lli long long int
#define li long int
#define ld long double
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define run(j, n) for(auto ii=j;ii!=n;ii++)
#define out(j, n) for(auto ii=j;ii!=n;ii++) cout<<(*ii)<<" ";


int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);

int l, r;cin>>l>>r;
int d;cin>>d;
int s1 = l/d, s2 = r/d;
cout<<(s2-s1)+(l%d==0?1:0);


return 0;
}

Measured memory_bytes: 3648
import math
import numpy as np

S = input()
ans = np.zeros((len(S)), dtype=np.int)
count = idx = i = 0

while i < len(S):
    if S[i:i+2] == 'RL':
        idx = i
        ans[idx:idx+2] += [count//2+1, math.ceil(count/2)+1]
        i += 2
        count = 0
    elif S[i:i+2] == 'LR':
        count += 1
        ans[idx:idx+2] += [math.ceil(count/2), count//2]
        count = 0
        i += 1
    else:
        count += 1
        i += 1

ans[idx:idx+2] += [math.ceil(count/2), count//2]

print(' '.join(map(str, ans)))

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

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> c(h);
    for(int i=0;i<h;i++){
        cin>>c[i];
    }

    vector<pair<int,int>> pos;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(c[i][j]=='B'){
                pos.push_back(make_pair(i,j));
                break;
            }
        }
        for(int j=w-1;j>=0;j--){
            if(c[i][j]=='B'){
                pos.push_back(make_pair(i,j));
                break;
            }
        }
    }

    int res=0;
    for(auto p1:pos){
        for(auto p2:pos){
            int d=abs(p1.first-p2.first)+abs(p1.second-p2.second);
            res=max(res,d);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll x,n,a;cin>>x>>n;
	ll arr[200]={0};
	for(int i=0;i<n;i++){
		cin>>a;
		arr[a]=1;
	}
	ll mn=INT_MAX;
	for(int i=0;i<=200;i++){
		if(arr[i]==0){
			mn=min(mn,abs(x-i));
		}
	}
	ll ans=-1;
	for(int i=0;i<=200;i++){
		if(arr[i]==0 and abs(x-i)==mn){
			cout<<i;return;
		}
	}
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}




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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  string s;
  cin >> s;
  int i;
  
  for(i=0;i<s.size();i++){
  	if(i==5||i==13||i==19) s.at(i) = ' ';
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            System.out.println((A * B) % 2 == 1 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 23764
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;
use std::collections::VecDeque;

fn judge(d1: usize, d2: usize, t: usize) -> bool {
    let diff_t = t*t - (t-1)*(t-1);
    d1 < d2 && diff_t < d2-d1
}

fn main() {
    input! {
        n : usize,
        k : usize,
        sushis : [(usize, usize); n],
    }

    let mut ss = sushis;
    ss.sort_by(|a, b| b.1.cmp(&a.1));
    let mut ss: VecDeque<_> = ss.into_iter().collect();

    let mut cnt = 0;
    let mut selected_t = HashSet::with_capacity(k);
    let mut selected_d = VecDeque::with_capacity(k);

    ss.retain(|s| {
        if cnt < k {
            if selected_t.contains(&s.0) {
                true
            } else {
                selected_t.insert(s.0);
                selected_d.push_front(s.1);
                cnt+=1;
                false
            }
        } else {
            true
        }
    });

    let mut ts = cnt;

    ss.retain(|s| {
        if cnt < k {
            selected_d.push_back(s.1);
            cnt+=1;
            false
        } else {
            true
        }
    });

    for (_t, d) in ss {
        if judge(*selected_d.front().unwrap(), d, ts) {
            selected_d.pop_front();
            selected_d.push_back(d);
            ts-=1;
        } else {
            break;
        }
    }

    println!("{}", selected_d.iter().sum::<usize>() + ts*ts);
}


Measured memory_bytes: 11516
#include<iostream>
using namespace std;
int main()
{
    long long sx,sy,tx,ty,i;
    while(cin>>sx>>sy>>tx>>ty)
    {
        for(i=1;i<=ty-sy;i++)
            cout<<'U';
        for(i=1;i<=tx-sx;i++)
            cout<<'R';
        for(i=1;i<=ty-sy;i++)
            cout<<'D';
        for(i=1;i<=tx-sx;i++)
            cout<<'L';
            cout<<'L';
        for(i=0;i<=ty-sy;i++)
            cout<<'U';
        for(i=0;i<=tx-sx;i++)
            cout<<'R';
        cout<<'D';
        cout<<'R';
        for(i=0;i<=ty-sy;i++)
            cout<<'D';
        for(i=0;i<=tx-sx;i++)
            cout<<'L';
            cout<<'U'<<endl;
    }
    return 0;
}


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

int main() {
	int a,b;
	while(cin>>a>>b){
		
		int prod=a*b;
		if(prod%2==0){
			printf("Even\n");
		}
		else{
			printf("Odd\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(A):
    A = sorted(A)
    a0 = A[0]
    for a in A[1:]:
        if a0 == a:
            return "NO"
        a0 = a
    return "YES"


if __name__ == "__main__":

    N = int(input())
    A = map(int, input().split())

    ans = solv(A)

    print(ans)


Measured memory_bytes: 26676
#include <stdio.h>
int main(void){
    int N,i,H[20],max=0,cnt=0;
    for(i=0;i<20;i++)
    H[i]=0;
    
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
    scanf("%d",&H[i]);
    if(H[i]>=max){
    max=H[i];
    cnt++;
    }
    }
    printf("%d",cnt);
    return(0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int x = -1, y = INF;
    rep(i, 0, m){
        int l, r;
        cin >> l >> r;
        l--; r--;
        x = max(x, l);
        y = min(y, r);
    }
    int ans = max(0LL, y - x + 1);
    cout << ans << endl;
}


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

char DistanceMeal(int x , int a , int b){
    int da = 0 , db = 0;
   
    if( a - x >= 0) da = a - x ;
    else da = x - a ;
    if( b - x >= 0) db = b - x ;
    else db = x - b ;
    
    if(da < db) return 'A' ;
    return 'B' ;
    
}
int main() {
    int x = 0 , a = 0 , b = 0 ;
    cin >> x >> a >> b ;
    
    cout << DistanceMeal(x, a, b) ;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a,b,n,x;
int main(){
    cin>>a>>b>>n;
    if(n>=b){
        x=b-1;
        cout<<a*x/b<<endl;
    }
    else{
        x=n;
        cout<<a*x/b<<endl;
    }
}


Measured memory_bytes: 3636
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };
int x[501];
int ans[250001];
vector<int>G[505];

void disp(int n) {
	rep(i, n*n) {
		if (i)cout << ' ';
		cout << ans[i];
	}cout << endl;
}

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> x[i];
	
	vector<P>V;
	rep(i, n) {
		V.push_back(P(x[i], i));
	}
	sort(V.begin(), V . end());
	int uu = 0;
	rep(i, n) {
		int X = V[i].first, I = V[i].second;
		if (ans[X - 1]) {
			puts("No");
			return 0;
		}
		ans[X - 1] = I + 1;
		rep(j, I) {
			while (ans[uu]) {
				if (uu == X - 1) {
					puts("No");
					return 0;
				}
				uu++;
			}
			ans[uu] = I + 1;
		}
	}

	rep(i, n) {
		int X = V[i].first, I = V[i].second;
		rep(j, n - I-1) {
			while (ans[uu]) {
				uu++;
			}
			if (uu == n*n) {
				puts("No");
				return 0;
			}
			ans[uu] = I + 1;
		}
	}

	rep(i, n*n) {
		G[ans[i]-1].push_back(i);
	}
	rep(i, n) {
		if (G[i][i] != x[i] - 1) {
			puts("No");
			return 0;
		}
	}

	puts("Yes");
	disp(n);
}


Measured memory_bytes: 5120
N = int(input())
p_f = [0.0]
p_b = [0.0]
for p in list(map(float,input().split())):
    p_f.append(p)
    p_b.append(1.0-p)

#一次軸：コイントスの回数、二次軸：勝ち数、値：発生確率
dp = [[0.0] * (N+1) for i in range(N+1)]
dp[0][0] = 1.0

def cointoss(n_toss):
    global p_majority
    for i in range(n_toss):
        dp[n_toss][i+1] += dp[n_toss-1][i] * p_f[n_toss]
        dp[n_toss][i  ] += dp[n_toss-1][i] * p_b[n_toss]

for i in range(1,N+1):
    cointoss(i)

p_majority = 0.0
n_majority = N // 2 + 1

for i in range(n_majority,N+1):
    p_majority += dp[N][i]

print(p_majority)

Measured memory_bytes: 112092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll d = 0;
  cin >> d;
  vector<ll> c(26);
  //ll min = 0;
  //min = pow(10,18);
  //ll mini = 0;
  for(int i = 0;i < 26;i++){
    cin >> c[i];
    //if(min > c[i])min = c[i],mini = i;
  }
  vector<vector<ll>> s(d,vector<ll>(26));
  vector<ll> last(26);
  for(int i = 0;i < 26;i++)last[i] = -1;
  for(int i = 0;i < d;i++){
    ll now = 0;
    ll nowi = 0;
    for(int j = 0;j < 26;j++){
      cin >> s[i][j];
      s[i][j] += c[j] * (i - last[j]) * (d - i + 1);
      if(now < s[i][j]){
        now = s[i][j];
        nowi = j;
      }
    }
    last[nowi] = i;
    cout << nowi + 1 << endl;
  }
  //for(int i = 0;i < 365;i++)cout << mini + 1 << endl;
}



Measured memory_bytes: 3716
num = list(map(int,input()
.split()))
if num[1] !=100:
    if num[0] == 0:
        ans = num[1]
    elif num[0] == 1:
        ans = num[1]*100
    elif num[0] == 2:
        ans = num[1]*10000
else:
    if num[0] == 0:
        ans = num[1]+1
    elif num[0] == 1:
        ans = num[1]*100+100
    elif num[0] == 2:
        ans = num[1]*10000+10000

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int desc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return -1;
  if (*A < *B) return 1;
  return 0;
}

int main()
{
  long x,y,z,k,i,j,l,jmax,lmax,count=0,sum[10000000];
  scanf("%ld %ld %ld %ld",&x,&y,&z,&k);
  long A[x],B[y],C[z];
  
  for(i=0;i<x;i++){
    scanf("%ld",&A[i]);
  }
  for(i=0;i<y;i++){
    scanf("%ld",&B[i]);
  }
  for(i=0;i<z;i++){
    scanf("%ld",&C[i]);
  }
  qsort(A, sizeof(A) / sizeof(long), sizeof(long), desc);
  qsort(B, sizeof(B) / sizeof(long), sizeof(long), desc);
  qsort(C, sizeof(C) / sizeof(long), sizeof(long), desc);
  
  for(i=0;i<x;i++){
    jmax=(k+i)/(i+1);
    if(jmax>y){
      jmax=y;
    }
    for(j=0;j<jmax;j++){
      lmax=(k+(i+1)*(j+1)-1)/((i+1)*(j+1));
      if(lmax>z){
        lmax=z;
      }
      for(l=0;l<lmax;l++){
        sum[count]=A[i]+B[j]+C[l];
        /*printf("%ld %ld\n",count, sum[count]);*/
        count++;
      }
    }
  }
  /*for(i=0;i<count;i++){
    printf("%ld\n",sum[i]);
  }*/
  
  qsort(sum, count, sizeof(long), desc);
  
  for(i=0;i<k;i++){
    printf("%ld\n",sum[i]);
  }
  
  return 0;

}

Measured memory_bytes: 4220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<string> s(n);
    string ans;

    for (int i = 0; i < n; ++i) cin >> s[i];

    string alp = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < alp.size(); ++i) {
        int m = 51;
        for (int j = 0; j < n; ++j) {
            int t = count(s[j].begin(), s[j].end(), alp[i]);
            if (m > t) m = t;
        }
        for (int j = 0; j < m; ++j) ans.push_back(alp[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
s = gets.chomp
sum_all = 0
(2**(s.size-1)).times do |cmb|
  sum = 0
  x = 0
  s.each_char do |c|
    x = x*10 + c.to_i
    if (cmb & 1) == 1
      sum += x
      x = 0
    end
    cmb >>= 1
  end
  sum_all += sum + x
end
p sum_all

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

using namespace std;

int main()
{
    string input;
    cin >> input;
    int number = input[input.size()-1] - '0';
    if(number == 2 || number == 4 || number == 5 || number == 7 || number == 9)
    {
        cout << "hon";
    }
    else if(number == 3)
    {
        cout << "bon";
    }
    else
    {
        cout << "pon";
    }
}


Measured memory_bytes: 3628