akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

template<typename Monoid,typename OperatorMonoid,typename F,typename G,typename H>
struct Segtree{
	int size=1;
	vector<Monoid>dat;
	vector<OperatorMonoid>lazy;
	const F f;
	const G g;
	const H h;
	Monoid M;
	OperatorMonoid OM;
	void set(int a,Monoid x){
		dat[a+size-1]=x;
	}
	void init(){
		for(int i=size-2;i>=0;i--){
			dat[i]=f(dat[i*2+1],dat[i*2+2]);
		}
	}
	void eval(int k,int l,int r){
		if(lazy[k]!=OM){
			dat[k]=g(dat[k],lazy[k],(r-l));
			if(r-l>1){
				lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2],lazy[k]);
			}
			lazy[k]=OM;
		}
	}
	void update(int a,int b,OperatorMonoid M,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			lazy[k]=h(lazy[k],M);
			eval(k,l,r);
			return;
		}
		update(a,b,M,k*2+1,l,(l+r)/2);
		update(a,b,M,k*2+2,(l+r)/2,r);
		dat[k]=f(dat[k*2+1],dat[k*2+2]);
	}
	Monoid query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l)return M;
		if(a<=l&&r<=b)return dat[k];
		Monoid lv=query(a,b,k*2+1,l,(l+r)/2);
		Monoid rv=query(a,b,k*2+2,(l+r)/2,r);
		return f(lv,rv);
	}
	template<class C>
	int minLeft(int a,int b,C &check,Monoid x,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l||!check(dat[k],x))return -1;
		if(r-l==1)return l;
		int lv=minLeft(a,b,check,x,k*2+1,l,(l+r)/2);
		if(lv!=-1)return lv;
		return minLeft(a,b,check,x,k*2+2,(l+r)/2,r);
	}
	template<class C>
	int maxRight(int a,int b,C &check,Monoid x,int k=0,int l=0,int r=-1){
		if(r==-1)r=size;
		eval(k,l,r);
		if(r<=a||b<=l||!check(dat[k],x))return -1;
		if(r-l==1)return l;
		int rv=maxRight(a,b,check,x,k*2+2,(l+r)/2,r);
		if(rv!=-1)return rv;
		return maxRight(a,b,check,x,k*2+1,l,(l+r)/2);
	}
	Segtree(int x,F f,G g,H h,Monoid M,OperatorMonoid OM)
	:f(f),g(g),h(h),M(M),OM(OM){
		while(size<x)size*=2;
		dat.resize(size*2-1,M);
		lazy.resize(size*2-1,OM);
	}
};

auto f=[](int a,int b)->int{return min(a,b);};
auto g=[](int a,int b,int sz)->int{return min(a,b);};
auto h=[](int a,int b)->int{return min(a,b);};
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,Q;cin>>N>>Q;
	Segtree<int,int,decltype(f),decltype(g),decltype(h)>segtreeH(N,f,g,h,N-1,N-1),segtreeW(N,f,g,h,N-1,N-1);
	int now=(N-2)*(N-2);
	while(Q--){
		int t;cin>>t;
		if(t==1){
			int y;cin>>y;y--;
			int x=segtreeW.query(y,y+1);
			now-=x-1;
			segtreeH.update(0,x,y);
		}else {
			int x;cin>>x;x--;
			int y=segtreeH.query(x,x+1);
			now-=y-1;
			segtreeW.update(0,y,x);
		}
	}
	cout<<now<<"\n";
}

Measured memory_bytes: 19580
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int (i)=(s);(i)<(t);(i)++)

template<typename T>
class DiffUnionFind {
	T calc(int x) {
		int r = root(x);
		return dist[x];
	}
	vector<int> par;
	vector<T>dist;

public:
	DiffUnionFind(int n) {
		par.assign(n, -1);
		dist.assign(n, 0);
	}
	int size(int x) { return -par[root(x)]; }
	bool same(int x, int y) { return root(x) == root(y); }

	// !
	int root(int x) {
		if (par[x] < 0)return x;
		int r = root(par[x]);
		dist[x] += dist[par[x]];
		return par[x] = r;
	}
	void unionSet(int x, int y, T val) {
		int rx = root(x), ry = root(y);
		val = val - (dist[y]) + (dist[x]); // !
		if (rx == ry)return;
		if (size(ry) < size(rx)) {
			swap(ry, rx);
			val = -val; // !
		}
		par[rx] += par[ry];
		par[ry] = rx;
		dist[ry] = val; // !

	}

	pair<bool, T>comp(int x, int y) {
		if (!same(x, y))return make_pair(false, 0);
		return make_pair(true, (calc(y) - calc(x)));
	}
};


void solve_ABC_087_D() {
	int N, M; cin >> N >> M;
	DiffUnionFind<long long> wuf(N);
	int flag = 1;
	FOR(i, 0, M) {
		long long l, r, d;
		cin >> l >> r >> d;
		l--, r--;
		if (wuf.same(l, r)) {
			if (wuf.comp(l, r).second != d)flag = 0;
		}
		else {
			wuf.unionSet(l, r, d);
		}
	}
	cout << (flag ? "Yes" : "No") << endl;

}

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

	solve_ABC_087_D();

	return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
"""
C - Remainder Minimization 2019
https://atcoder.jp/contests/abc133/tasks/abc133_c

"""
import sys
from itertools import combinations

def solve(l, r):
    res = set()
    for i in range(l, r+1):
        res.add(i % 2019)
        if len(res) == 2019:
            break
    ans = set()
    for a, b in combinations(res, 2):
        ans.add(a * b % 2019)
    return min(ans)


def main(args):
    l, r = map(int, input().split())
    ans = solve(l, r)
    print(ans)


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


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
void shikhar7s(int cas)
{
    int n,m,i;
    cin>>n>>m;
    string s;
    int a,c[n]={0},ans=0,f=0;
    fr(i,m)
    {
        cin>>a>>s;
        //cout<<i<<" "<<s<<endl;
        if(s=="AC")
        {
            if(c[a-1]!=1)
            {
                ans-=c[a-1];
                f++;
                c[a-1]=1;
            }
        }
        else
        {
            if(c[a-1]!=1)
            {
                c[a-1]--;
            }
        }
    }
    cout<<f<<" "<<ans;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int main()
{
  int h, w, n; cin >> h >> w >> n;
  vecstr s(h);
  REP(i,h) cin >> s[i];
  vec2bool g(h,vecbool(w,false)); ///true->white
  int infl = (h - 1)*(w - 1);
  int ans = (h - 1)*(w - 1);
  REP(bit, 1 << h - 1){
    int tate = 0; // number of tatesen
    int yoko = 0; // number of yokosen
    /////////tate line search
    int g = 0;
    vecint id(h,0);
    REP(i,h){
      id[i] = g;
      if(bit >> i & 1){
	g ++;
      }
    }
    yoko = g;
    // cout << "BIT" << endl;
    // REP(i,h){
    //   cout << id[0] << " ";
    // }
    // cout << endl;
    int j = 0;
    int cnt = 0;
    vecint sum(g + 1,0);
    while(j < w){
      bool ok = true;
      REP(i,h){
	if(s[i][j] == '1'){
	  sum[id[i]]++;
	}
      }
      REP(i,h){
	if(sum[id[i]] > n){
	  ok = false;
	  break;
	}
      }
      if(ok){
	j++;
	cnt++;
      }else{
	if(cnt == 0){
	  tate = infl;
	  break;
	}else{
	  tate ++;
	  REP(i,g + 1){
	    sum[i] = 0; 
	  }
	}
      }
    }
    ans = min(ans,tate + yoko);
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  N = parseInt(input[0]);
  x = new Array(N);
  y = new Array(N);
  h = new Array(N);
  var notzero=0;
  for(i=0;i<N;i++){
    tmp=input[i+1].split(" ");
    x[i]=parseInt(tmp[0]);
    y[i]=parseInt(tmp[1]);
    h[i]=parseInt(tmp[2]);
    if(h[i]!=0){
      notzero++;
    }
  }
  for(i=0;i<N;i++){
    if(h[i]!=0){
      var x1=x[i];
      var y1=y[i];
      var h1=h[i];
      break;
        }
  }
  ans=0;
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      var H =h1+Math.abs(i-x1)+Math.abs(j-y1);
      var count=0;
      for(k=0;k<N;k++){
        if(h[k]==H-Math.abs(i-x[k])-Math.abs(j-y[k])||h[k]==0){
          count++;
        }
      }

    if(count==N){
      ans=i+" "+j+" "+H;
      break;
    }
    }
  }
  if(notzero==1){
    ans=x1+" "+y1+" "+h1;
  }
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
#include<bits/stdc++.h>
using namespace std;
int s=200005,t,l,r,n,a[200005],b[200005];
int main()
{
	scanf("%d",&n);l=1,r=n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=0;i<n;i++) scanf("%d",&b[n-i]);
	for(int i=1;i<=n;i++)
		if(a[i]==b[i])
		{
			if(s==200005) s=i;
			t=i;
		}
	for(int i=s;i<=t;i++)
		if(a[l]!=b[i]&&b[l]!=b[i]){swap(b[l],b[i]);l++;}
		else if(a[r]!=b[i]&&b[r]!=b[i]){swap(b[r],b[i]);r--;}
		else{puts("No");return 0;}
	puts("Yes");
	for(int i=1;i<=n;i++) printf("%d ",b[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 5308
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)*}
    };
}

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

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

fn main() {
    input! {
        n: u32,
        m: [u128; n],
    }

    if m.contains(&0) {
        println!("0");
        std::process::exit(0);
    }
    
    let mut ans: u128 = 1;
    let limit = 10u128.pow(18u32);
    for a in m {
        ans *= a;
        if ans > limit {
            println!("-1");
            std::process::exit(0);
        }
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 5528
N = int(input())
H = [int(x) for x in input().split()]
for i in range(N - 2, -1, -1):
  if H[i] > H[i + 1] + 1:
    print('No')
    break
  if H[i] > H[i + 1]:
    H[i] -= 1
else:
  print('Yes')

Measured memory_bytes: 14252
S = input()
s = list(S)
year = int(s[0] + s[1] + s[2] + s[3])
month = int(s[5] + s[6])
day = int(s[8] + s[9])
if year <2019:
    print('Heisei')
elif month < 5:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 3060
from collections import deque
n , m , k = map(int,input().split())
tomo = [set() for i in range(n+1)]
to = [0 for i in range(n+1)]
bro = [set() for i in range(n+1)]
for i in range(m):
    a , b = map(int,input().split())
    tomo[a].add(b)
    tomo[b].add(a)
    to[a] += 1
    to[b] += 1
for i in range(k):
    c , d = map(int,input().split())
    bro[c].add(d)
    bro[d].add(c)

visit = [True for i in range(n+1)]
kurasuta = []
for i in range(1,n+1):
    if visit[i]:
        kar = {i}
        d = deque()
        d.append(i)
        cou = 1
        visit[i] = False
        while d:
            now = d.popleft()
            for j in tomo[now]:
                if visit[j]:
                    visit[j] = False
                    kar.add(j)
                    d.append(j)
                    cou += 1
        kurasuta.append([kar,cou])
    else:
        continue
ans = [0 for i in range(n)]

for i in range(len(kurasuta)):
    for j in kurasuta[i][0]:
        ans[j-1] = len(kurasuta[i][0]) - to[j] - 1 - len(kurasuta[i][0] & bro[j])

print(*ans)


Measured memory_bytes: 112828
#include <iostream>

using namespace std;

int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    if (a % b == 0) return b;
    else {
        return gcd(b, a % b);
    }
}

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

    cout << 1 + x + y - gcd(x, y) << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.length();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";
    else cout<<"No";
}

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

long long int n,M=1e+9+7;
long long int power(long long int x,long long int p)
{
	if(p==0)
		return 1;
	long long int ans=power(x,p/2);
	ans=(ans*ans)%M;
	if(p%2==1)
		ans=(ans*x)%M;
	return ans;
}

int main()
{
	cin>>n;
	long long int ans=power(10,n)-power(9,n)-power(9,n)+power(8,n);
	ans=ans%M;
	ans=(ans+M)%M;
	cout<<ans;
}



Measured memory_bytes: 3636
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int inv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	int math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=inv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;
struct node{int a,b;};
bool operator <(node p,node q)
{
	return 1ll*q.a*(p.b+1)<1ll*p.a*(q.b+1);
}
vector<node> shop;
vector<int> zero;
int n,T;
ll f[40];

int main()
{
	n=read();T=read();
	rep(i,1,n)
	{
		int x=read(),y=read();
		if (!x) zero.pb(y+1);
		else shop.pb((node){x,y});
	}
	sort(shop.begin(),shop.end());
	sort(zero.begin(),zero.end());
	rep(i,1,30) f[i]=T+1;
	f[0]=0;
	int len=shop.size();
	rep(i,0,len-1)
	{
		int a=shop[i].a,b=shop[i].b;
		per(j,30,1)
			f[j]=min(f[j],1ll*(a+1)*(f[j-1]+1)+b);
	}
	//cout << f[1] << " " << f[2] << endl;
	int ans=0;
	len=zero.size();
	rep(i,1,len-1) zero[i]+=zero[i-1];
	//rep(i,0,len-1) cout << zero[i] << " ";cout << endl;
	rep(i,0,30)
	{
		if (f[i]>T) break;
		int cnt=0,rst=T-f[i];
		if (len) cnt=upper_bound(zero.begin(),zero.end(),rst)-zero.begin();
		ans=max(ans,i+cnt);
	}
	printf("%d",ans);
}




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

#define INF 0x3f3f3f3f
#define MOD 10000

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

int N, W;
int v[105], w[105];
int dp[105][10010];

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

	cin >> N >> W;
	for (int i = 0; i < N; i++) cin >> v[i] >> w[i];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j < w[i]) dp[i+1][j] = dp[i][j];
			else dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
		}
	}

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

	return 0;
}

Measured memory_bytes: 7012
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<map>
#include<set>
#define FOR(i,a) for(int i=0;i<a;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define ll long long
using namespace std;
int n;
int t[3];
int pos[3];
int main() {
	cin >> n;
	pos[0] = 0;
	pos[1] = 0;
	pos[2] = 0;
	FOR(i, n) {
		FOR(j, 3) cin >> t[j];
		int count = 0;
		if (pos[1] - t[1] < 0)count +=(pos[1] - t[1]) * -1;
		else count += (pos[1] - t[1]);

		if (pos[2] - t[2] < 0)count += (pos[2] - t[2]) * -1;
		else count += (pos[2] - t[2]);

		if ((count > t[0]-pos[0]) || ((t[0] - pos[0] - count)%2 == 1)) {
			cout << "No" << endl;
			return 0;
		}
		FOR(j, 3) {
			pos[j] = t[j];
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

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

const int nax = 1e5+20;
const  ll mod =  1e9+7;



void add_self(ll& a, ll b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
void sub_self(ll& a , ll b){
    a -= b;
    if(a < 0)
        a+= mod;
}

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

    int n,k;
    cin>>n>>k;

    vector<ll>dp(k+1);

    dp[0] = 1;

    for(int child = 0; child < n; child++) {
        int upto;
        cin >> upto;
        vector<ll>fake(k+1);
        for (int used = k; used >= 0; --used) {
            int L = used+1;
            int R = used + min(upto, k - used);
            ll tmp = dp[used];
            if (L <= R) {
                add_self(fake[L], tmp);
                if (R + 1 <= k) {
                    sub_self(fake[R + 1], tmp);
                }
            }

        }
        ll prefix_sum = 0;

        for(int i = 0; i <= k; ++i){
            add_self(prefix_sum,fake[i]);
            add_self(dp[i],prefix_sum);
        }
    }

    cout<<dp[k];







}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    string s;
    cin >> s;
    cout << s;
    if(s.back()=='s'){
        cout << "es\n";
    }else{
        cout << "s\n";
    }
    return 0;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
using namespace std;

int main() {
    char ch;
    
    while (1) {
        scanf("%c", &ch);
        if (islower(ch)) printf("%c",toupper(ch));
        else printf("%c", tolower(ch));
        
        if (ch == '\n') break;
    }
    
    return 0;
}

Measured memory_bytes: 3112
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int b = n%10;
    if (b==3){
      System.out.println("bon");
      return;
    }
    if ((b==0)||(b==1)||(b==6)||(b==8)){
      System.out.println("pon");
      return;
    }
    System.out.println("hon");
  }
}


Measured memory_bytes: 35780
#include <cstdio>
#include <string>
#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()

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

using ll = long long;

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

const std::string ACGT = "ACGT";

ll N;
mint dp[110][4][4][4];

// ?GC AG? ACG GAC AGC

int main()
{
  scanf( "%lld", &N );
  
  dp[0][3][3][3] = 1;

  rep( i, N ) rep( j, 4 ) rep( k, 4 ) rep( l, 4 ) rep( m, 4 )
  {
    if( m == 2 )
    {
      if( k == 0 && l == 1 )
        continue;
      if( k == 1 && l == 0 )
        continue;
      if( j == 0 && l == 1 )
        continue;
      if( j == 0 && k == 1 )
        continue;
    }
    if( m == 1 && k == 0 && l == 2 )
      continue;

    dp[i+1][k][l][m] += dp[i][j][k][l];
  }

  mint ans = 0;

  rep( j, 4 ) rep( k, 4 ) rep( l, 4 )
    ans += dp[N][j][k][l];

  printf( "%lld\n", ans.x );

  return 0;
}

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

int main() {
  long long N;
  cin>>N;
  vector<long long>A(N);
  long long sum=0;
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;i++) sum+=A[i];
  
    long long half=sum/2;
    long long x=0;
    for(int i=0;i<N;i++){
      if(x+A[i]<=half) x+=A[i];
      else break;
    }
    long long ans;
    long long y=0;
    for(int i=0;i<N;i++){
      if(y+A[i]<=half) y+=A[i];
      else{
        y+=A[i];
        break;
      }
    }
    ans=min(sum-2*x,2*y-sum);
  cout<<ans<<endl;
}

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

int main()
{
  string s;
  int    n;
  
  cin >> s;
  cin >> n;
  bool flip = false;
  
  deque<char> q;
  for(c : s)q.push_back(c);
  
  rep(ix, n)
  {
    int t;
    cin >> t;
    
    if 		(t == 1)
    {
      flip = !flip;
    }
    else if (t == 2)
    {
      int h; char c;
      cin >> h >> c;
      
      if (flip) h = 3 - h;
      
      if(h == 1) q.push_front(c);
      if(h == 2) q.push_back(c);
    } 
  }
  
  string ans = "";
  
  if (flip) reverse(q.begin(), q.end());
  
  for (c : q) ans += c;
  
  cout << ans << endl;
}


Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define m3(a, b, c) max(c, max(a, b))
#define m4(a, b, c, d) min(d, min(c, min(a, b)))
#define test long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const ll minn=-1e18;
 ll ans[100005][4];
 
 void solve(ll arr[],ll n,ll q[])
 {
 	for(int i=1;i<=n;i++)
 	for(int j=1;j<=3;j++)
 	{
 		ans[i][j]=max(ans[i-1][j],ans[i][j-1]+arr[i-1]*q[j-1]);
 	}
 }
 
 int main()
 { /*memset(ans,0,sizeof(ans));
  for(int i=1;i<4;i++)
  ans[0][i]=(minn*3)-1;*/
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll m=0,n=0;
m=max(1LL*a*c,1LL*a*d);
n=max(1LL*b*c,1LL*b*d);
m=max(m,n);
cout<<m;
 }

Measured memory_bytes: 3636
#include<stdio.h>

int main(void){

    int N,i,j,result = 1;
    int H[20];

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&H[i]);
    }

    for(i = 1;i < N;i++){
        for(j = 0;j < i;j++){
            if(H[j] > H[i]){
                goto loop;
            }
        }
        result++;
        loop:
        continue;
    }

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

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main(void){
int n,x;
cin>>n>>x;
long long int sum=0;
vector<int> a(n),b(n-1);
cin>>a[0];
if(a[0]>x){
	sum+=a[0]-x;
	a[0]=x;
}
for(int i=1;i<n;i++){
	cin>>a[i];
	b[i-1]=a[i]+a[i-1];
}
int k;
for(int i=0;i<n-2;i++){
if(b[i]>x){
	k=b[i]-x;
	sum+=k;
	b[i+1]-=k;
}
}
if(b[n-2]>x){
	sum+=b[n-2]-x;
}

cout<<sum<<endl;
	return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
    int count = 0 ;
    string s ;
    cin >> s ;
    for(int i = 0 ; i<(int)s.length() ;i++) {
        if(s[i] == '1') count++ ;
    }
    cout << count << endl ;
    return 0 ;
}

Measured memory_bytes: 256
import java.util.*;

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

    public void main() {
        Scanner scanner = new Scanner(System.in);

        int aNum = Integer.parseInt(scanner.nextLine());
        String[] aLine = scanner.nextLine().split(" ", aNum);
        int[] a = new int[aNum];
        for (int i = 0; i < aNum; i++) {
            a[i] = Integer.parseInt(aLine[i]);
        }

        int mNum = Integer.parseInt(scanner.nextLine());
        String[] mLine = scanner.nextLine().split(" ", mNum);
        for (int i = 0; i < mNum; i++) {
            int m = Integer.parseInt(mLine[i]);
            if (this.makableBySum(m, 0, a)) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }
    }

    private boolean makableBySum(int m, int aInd, int[] a) {
        if (m == 0) {
            return true;
        }
        if (aInd == a.length - 1) {
            return m == a[aInd];
        } else {
            return this.makableBySum(m, aInd + 1, a) || this.makableBySum(m - a[aInd], aInd + 1, a);
        }
    }
}



Measured memory_bytes: 26648
#include <bits/stdc++.h>
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int h,w,n,m;

int main(){
	cin >> h >> w >> n >> m;
	
	if((!(h%n))&&(!(w%m))) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		REP(i,0,h){
			REP(j,0,w){
				if((i%n==n-1)&&(j%m==m-1)) cout << -(n*m-1)*1000-1 << " ";
				else cout << 1000 << " ";
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int64_t A;
    double B;
    cin >> A >> B;
    cout << (A*(int)(B*100.01)) / 100 << endl;
    return 0;
}


Measured memory_bytes: 3724
#include<iostream>
using namespace std;
int main(){
    int H,W; 
    while (true){
        cin >> H >> W;
        if(H != 0 || W != 0){
            for(int i = 1; i <= H; i++){
                for(int j = 1; j <= W; j++){
                    cout << '#';
                
                }
                cout << endl;
            }
            cout << endl;
        } else {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
# ------------------------------------------------------------
# THIS IS METADATA FOR ATCODER_TOOLS
# BE CAREFULL WHEN YOU CHANGE THE VALUE
# 
# METADATA::START
# test-1
# input: "2 5\n"
# output: "10\n"
# test-2
# input: "100 100\n"
# output: "10000\n"
# MODE: TEST
# METADATA::FINISH
# 
# 
# select MODE from NONE, DEBUG, RUN, TEST
# problem: https://atcoder.jp/contests/abc169/tasks/abc169_a
# -------------------------------------------------------------

arr = gets.split(' ').map(&:to_i)
puts(arr[0] * arr[1])


Measured memory_bytes: 14304
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define FOR(variable,start,end) for(int variable = start; variable < end; ++variable)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second

using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int a[n];
    ll sum=0;
    map<int,int> m;
    FOR(i,0,n){
        cin >> a[i];
        m[a[i]]++;
        sum+=a[i];
    }
    int q;
    cin >> q;
    while(q--){
        int b,c;
        cin >> b >> c;
        if(m.find(b)==m.end()){
            cout << sum << endl;
        }
        else{
            int count=m[b];
            m[c]+=m[b];
            m.erase(b);
            sum=sum-((b-c)*count);
            cout << sum << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6924
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

const int maxn = 2e5 + 7;

int dp[maxn];
int st[4*maxn];

int update(int ss, int se, int curr, int idx, int val)
{
    if(idx < ss || idx > se)
        return st[curr];
    if(ss == se)
    {
        st[curr] = val;
        return st[curr];
    }
    int mid = (ss + se) / 2;
    int left = update(ss, mid, (curr << 1), idx, val);
    int right = update(mid + 1, se, (curr << 1) | 1, idx, val);
    st[curr] = max(left, right);
    return st[curr];
}

int query(int ss, int se, int curr, int l, int r)
{
    if(r < ss || l > se)
        return -1;
    if(l <= ss && se <= r)
        return st[curr];
    int mid = (ss + se) / 2;
    int left = query(ss, mid, (curr << 1), l, r);
    int right = query(mid + 1, se, (curr << 1) | 1, l, r);
    return max(left, right);
}

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<int> vh(n+1), va(n+1);
    for(int i = 1; i <= n; i++)
        cin >> vh[i];
    for(int i = 1; i <= n; i++)
        cin >> va[i];
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        int h = vh[i];
        int sum = 0;
        if(h > 1)
            sum = query(1, n, 1, 1, h-1);
        dp[i] = sum + va[i];
        update(1, n, 1, h, dp[i]);
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
using namespace std;
int score(int D,int c[27], int s[365][26], int t[365] ){
    int i=0;
    //int j=0;
    int day=0;
    int last[365][26] = {};
    long long int sat = 0;
    
    day = 0;
    last[day][t[day]] = day + 1;
    sat += s[day][t[day]];
    for (i= 0; i < 26; i++){
        sat -= c[i] * (day + 1 - last[day][i]);
    }
    
    for (day = 1; day < D; day++){
        for (i = 0; i<26; i++){
            last[day][i] = last[day-1][i];
        }
        last[day][t[day]] = day + 1;
        sat += s[day][t[day]];
        
        for (i= 0; i < 26; i++){
            sat -= c[i] * (day + 1 - last[day][i]);
        }
        
    }
    return sat;
}


int main(void){
    // Your code here!
    int D;
    cin >> D;
    
    int c[27] = {};
    int i=0;
    int j=0;
    for (i = 0; i<26; i++){
        cin >> c[i];
    }
    
    int s[365][26] = {};
    for (i = 0; i<D;i++){
        for (j=0; j<26; j++){
            cin >> s[i][j] ;
        }
    }
    
    int t[365] = {};
    int day = 0;
    
   
    int tempscore = 0;
    int temptype = 0;
    //int sum = 0;
    //int last[365][26] = {};
    
    for (day=0; day<D; day++){
        tempscore = score(day + 1, c, s, t);
        temptype = 0;
        for (i=0; i<26; i++){
            t[day] = i;
            //cout << score(day + 1, c,s,t) << endl;
            /*
            sum = s[day][i];
            for (j = 0; j < 26; j++){
                sum -= c[i] * 
            }
            */
            if( tempscore < score(day + 1, c,s,t)){
                tempscore = score(day + 1, c,s,t);
                temptype = i;
            }
            //cout << "t" << endl;
           //for (j = 0; j <26; j++)  cout << t[j] << endl;
            
        }
        t[day] = temptype;
        //cout << temptype << endl;
        
    }
    for (j = 0; j <D; j++)  cout << t[j] + 1 << endl;

    return 0;

}


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

int a[52];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, max_id = 0, cnt = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(abs(a[max_id]) < abs(a[i])) max_id = i;
    }

    if(a[max_id] > 0){
        if(max_id != 0) cnt++;
        for(int i = 1; i < n; i++){
            if(a[i] < 0){
                cnt += 2;
            }
            else cnt++;
        }

        cout << cnt << endl;
        if(max_id != 0) cout << max_id+1 << " " << 1 << endl;
        for(int i = 1; i < n; i++){
            if(a[i] < 0) {
                cout << i << " " << i+1 << endl;
                cout << i << " " << i+1 << endl;
            }
            else cout << i << " " << i+1 << endl;
        }
    }
    else if(a[max_id] == 0) cout << 0 << endl;
    else {
        if(max_id != n) cnt++;
        for(int i = n-2; i >= 0; i--){
            if(a[i] > 0) cnt += 2;
            else cnt++;
        }

        cout << cnt << endl;
        if(max_id != n) cout << max_id+1 << " " << n << endl;
        for(int i = n-2; i >= 0; i--){
            if(a[i] > 0) {
                cout << i+2 << " " << i+1 << endl;
                cout << i+2 << " " << i+1 << endl;
            }
            else cout << i+2 << " " << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){ 
  int n;
  cin >> n;
  map<int,int> mp;
  ll res = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mp[a]++;
  }
  for (auto e : mp) {
    if (e.second >= e.first) res += e.second - e.first;
    else res += e.second;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> b(n);
    int l,r;
    l = r = n/2;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(i%2 == 0){
            b[r] = a; r++;
        }else{
            l--; b[l] = a;
        }
    }
    if(n %2 != 0) reverse(b.begin(), b.end());
    for(int i = 0; i < n; i++){
        cout << b[i];
        if(i != n-1) cout << " ";
        else cout << endl;
    }

}

Measured memory_bytes: 2944
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
n = ni()

print(num2alpha(n).lower())

Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;

vector<pair<int, int> > neighbor_coords(int x, int y, int h, int w){
  vector<pair<int, int>> ans;
  for(int i = -1; i <= 1; ++i){
    if(x + i < 0 or x + i >= h) continue;
    for(int j = -1; j <= 1; ++j){
      if(!(i == 0 ^ j == 0)) continue;
      if(y + j < 0 or y + j >= w) continue;
      ans.push_back({x+i, y+j});
    }
  }
  return ans;
}

bool is_solitude_cell(int x, int y, vector<vector<char>>& field, int h, int w){
  const auto& neighbors = neighbor_coords(x, y, h, w);
  for(const auto& p: neighbors){
    if(field[p.first][p.second] == '#') return false;
  }
  return true;
}

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char> > field(h, vector<char>(w));
  for(int i = 0; i < h; ++i){
    string s;
    cin >> s;
    for(int j = 0; j < w; ++j){
      field[i][j] = s[j];
    }
  }
  
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(field[i][j] == '#' && is_solitude_cell(i, j, field, h, w)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD1e9 1000000007
int sosuu[168]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
ll check[1001];
int main(){
    ll n,num,ans=1;
    cin>>n;
    if(n<=2){
        cout<<n<<endl;
        return 0;
    }
    for(int i=2;i<=n;i++){
        num=i;
        for(int j=0;j<168;j++){
            if(num==1)break;
            while(num%sosuu[j]==0){
                num/=sosuu[j];
                check[sosuu[j]]++;
            }
        }
    }
    for(int i=0;i<168;i++){
        if(check[sosuu[i]]>0){
            ans=(((check[sosuu[i]]+1)%MOD1e9)*(ans%MOD1e9))%MOD1e9;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
fn read_line() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    return v;
}

fn read_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim_right().to_string()
}

fn main() {
    let vec = read_line();
    let h = vec[0];
    let w = vec[1];

    let mut cells = vec![];
    for _ in 0..h {
        let s = read_string();
        let mut vec = vec![];
        for c in s.chars() {
            vec.push(c);
        }
        cells.push(vec);
    }

    let directions = vec![[-1, 0], [0, 1], [1, 0], [0, -1]];

    for y in 0..h {
        for x in 0..w {
            if cells[y as usize][x as usize] == '#' {
                let mut drawable = false;
                for d in &directions {
                    let px = x + d[0];
                    let py = y + d[1];
                    if px < 0 || px >= w || py < 0 || py >= h {
                        continue;
                    }
                    if cells[py as usize][px as usize] == '#' {
                        drawable = true;
                        break;
                    }
                }
                if !drawable {
                    println!("No");
                    return;
                }
            }
        }
    }
    println!("Yes");
}


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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split();
        int A = int.Parse(input[0])-1;
        int B = int.Parse(input[1])-1;
        if (B % A == 0) { Console.WriteLine(B / A); }
        else { Console.WriteLine(B / A + 1); }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
   Scanner scan = new Scanner(System.in);
   int num = scan.nextInt();
   String a = scan.next();
   String[] a2 = a.split("");
   String b = scan.next();
   String[] b2 = b.split("");
   for (int i = 0; i < num; i++) {
     System.out.print(a2[i]);
     System.out.print(b2[i]);
   }
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

namespace
{
	ll ModPow(ll a, ll p, ll mod)
	{
		if (p == 0)
			return 1;
		if (p % 2 == 0)
		{
			ll halfp = p / 2;
			ll half = ModPow(a, halfp, mod);
			return (half * half) % mod;
		}
		else
		{
			return (a * ModPow(a, p - 1, mod)) % mod;
		}
	}

	ll Combination(int n, int r, ll mod)
	{
		r = min(r, n - r);
		ll num = 1;
		ll den = 1;
		for (int i = 0; i < r; ++i)
		{
			num *= (n - i);
			num %= mod;
			den *= (i + 1);
			den %= mod;
		}
		ll ret = (num * ModPow(den, mod - 2, mod)) % mod;
		return ret;
	}
}
void ABC110D()
{
	int N, M;
	cin >> N >> M;

	map<int, int> primeFactorization;
	for (int i = 2; i <= M; ++i)
	{
		while (M % i == 0)
		{
			M /= i;
			++primeFactorization[i];
		}
	}

	ll num = 1;
	int MODBASE = 1000000007;
	for (auto& x : primeFactorization)
	{

		num *= Combination(x.second + N - 1, min(x.second, N - 1), MODBASE);
		if (num > MODBASE)
		{
			num %= MODBASE;
		}
	}
	cout << num << endl;
}
int main()
{
	ABC110D();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define min(a, b) ((a)>(b) ? (b) : (a))

int main(){
  long long int n, k;  scanf("%lld%lld", &n, &k);
  n %= k;
  n = min(n, k-n);
  printf("%lld\n", n);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = math.radians(90-theta)
        min_x = length * math.cos(rad1)
        min_y = length * math.sin(rad1)
    elif 90 < theta <= 180:
        rad1 = math.radians(90 - theta)
        min_x = length * math.cos(rad1)
        min_y = length * math.sin(rad1)
    elif 180 < theta <= 270:
        rad2 = math.radians(450-theta)
        min_x = length * math.cos(rad2)
        min_y = length * math.sin(rad2)
    elif 270 < theta <= 360:
        rad2 = math.radians(450 - theta)
        min_x = length * math.cos(rad2)
        min_y = length * math.sin(rad2)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 62820
package main

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

func check(e error) {
	if e != nil {
		log.Fatalf("error: %v\n", e)
	}
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, err := strconv.Atoi(stdin.Text())
	check(err)

	var count int
	for i := 1; i <= n; i += 2 {
		if hasEightDivisor(i) {
			count++
		}
	}

	fmt.Println(count)
}

func hasEightDivisor(num int) bool {
	var count int
	for i := 1; i <= num; i++ {
		if num%i == 0 {
			count++
		}
	}
	return count == 8
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod = 998244353;

vector<int> L, R;
vector<ll> dp;

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

	int n, k; cin >> n >> k; dp.resize(n + 1);
	L.resize(k); R.resize(k); dp[1] = 1; dp[0] = 0;
	for (int i = 0; i < k; i++) cin >> L[i] >> R[i];

	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i - 1]; for (int j = 0; j < k; j++) if(i - L[j] > 0) 
			dp[i] = (dp[i] + dp[i - L[j]] - dp[max(0, i - R[j] - 1)] + mod) % mod;
	}

	cout << (dp[n] - dp[n - 1] + mod) % mod << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h,w,k;
    cin>>h>>w>>k;
    bool grid[h+1][w+1];
    for(int i=1;i<=h;i++)
    {
        string s;
        cin>>s;
        for(int j=1;j<=w;j++)
        {
            if(s[j-1]=='1')
            {
                grid[i][j]=1;
            }
            else
                grid[i][j]=0;
        }
    }
    int ans = h*w;
    for(int i=0;i<(1<<(h-1));i++)
    {
        int hcuts=0;
        vector<int> hh;
        for(int j=1;j<h;j++)
        {
            if(i&(1<<(j-1)))
            {
                hcuts++;
                hh.push_back(j);
            }
        }
        hh.push_back(h);
        int cc[hcuts+1];
        int pre[hcuts+1];
        for(int j=0;j<h+1;j++)
        {
            cc[j]=0;
            pre[j]=0;
        }
        bool possi=true;
        int vcuts=0;
        for(int j=1;j<=w and possi;j++)
        {
            int pos=1;
            bool vcu=0;
            for(int z=0;z<hh.size();z++)
            {
                cc[z]=0;
                for(;pos<=hh[z];pos++)
                {
                    cc[z]+=grid[pos][j];
                }
                if(cc[z]>k)
                    possi=0;
                if(pre[z]+cc[z]>k)
                {
                    vcu=1;
                }
                else
                {
                    pre[z]+=cc[z];
                }
            }
            if(vcu)
            {
                vcuts++;
                for(int z=0;z<hh.size();z++)
                {
                    pre[z]=cc[z];
                }
            }
        }
        if(possi)
        {
            ans = min(ans,hcuts+vcuts);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt(), b = scn.nextInt();
		int A,B,DEC;
		A = 0;
		B = 0;
		DEC = 1;
		for(int i = 0;i < b;i++) {
			A += DEC*a;
			DEC*=10;
		}
		DEC = 1;
		for(int i = 0;i < a;i++) {
			B += DEC*b;
			DEC*=10;
		}
		System.out.println((a<b)?A:B);
	}

}


Measured memory_bytes: 21844