akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<map>
using namespace std;

string S;
map<string,int> M;
int size;
int pos=0;
vector<vector<int> > V;

bool rev;

int gcd(int a, int b){ return a%b ? gcd(b, a%b) : b; }
int lcm(int a, int b){ return a/gcd(a,b)*b; }

vector<int> read(){
	vector<int> res(size,0);
	if(S[pos]=='+' || S[pos]==')' ||S[pos]=='-'){pos++;return res;}
	if(S[pos]=='.'){return res;}

	vector<int> now(size,0);
	string s="";
	if(S[pos]=='('){pos++;res=read();}
	else{
		s+=S[pos];
		if(islower(S[pos+1]))
			s+=S[++pos];
		pos++;
		res[M[s]-1]=1;
	}
	int num=1;
	if(isdigit(S[pos])){
		num=S[pos]-'0';
		if(isdigit(S[pos+1])){
			num*=10;
			num+=S[++pos]-'0';
		}
		pos++;
	}
	for(int i=0;i<res.size();i++) res[i]*=num;
	vector<int> next=read();
	for(int i=0;i<next.size();i++)
		res[i]+=next[i];
	return res;
}

void print(){
	
	for(int y=0;y<V.size();y++){
		for(int x=0;x<V[y].size();x++)
			cout<<V[y][x]<<" ";
		cout<<endl;
	}
	cout<<endl;
}

void solve()
{
	size=0; M.clear(); pos=0;V.clear(); rev=false;
	while(S[pos]!='.'){
		string s;
		if(!isalpha(S[pos])){pos++; continue;}
		s+=S[pos];
		if(islower(S[pos+1])){s+=S[pos+1];pos++;}
		pos++;
		if(M[s]==0){M[s]=++size;}
	}
	V.resize(size);
	pos=0;
	while(S[pos]!='.'){
		if(S[pos]=='>'){rev=true;pos++;}
		vector<int> res=read();
		for(int i=0;i<res.size();i++)
			V[i].push_back(rev? -res[i]:res[i]);
	}
	// verifyed!

	for(int i=0;i<V[0].size()-1;i++){
		if(V[i][i]==0){
			int z=i+1;
			while(V[z][i]==0) z++;
			swap(V[i],V[z]);
		}
		if(V[i][i]<0){
			for(int z=0;z<V[i].size();z++)
				V[i][z]*=-1;
		}

		for(int j=0;j<V.size();j++){
			if(V[j][i]==0 || i==j) continue;
			if(V[j][i]<0)
				for(int z=0;z<V[j].size();z++)
					V[j][z]*=-1;
			int l=lcm(V[i][i],V[j][i]);
			int mul=l/V[i][i];
			for(int z=0;z<V[i].size();z++)
				V[i][z]*=mul;
			mul=l/V[j][i];
			for(int z=0;z<V[j].size();z++)
				V[j][z]*=mul;
			for(int z=0;z<V[i].size();z++)
				V[j][z]-=V[i][z];
		}
		for(int j=0;j<V.size();j++){
			int l=0;
			for(int z=0;z<V[j].size();z++){
				if(V[j][z]==0) continue;
				if(l==0)l=abs(V[j][z]);
				else l=gcd(abs(V[j][z]),l);
			}
			if(l!=0){
				for(int z=0;z<V[j].size();z++)
					V[j][z]/=l;
			}
		}
	}

	int l=abs(V[0][0]);
	for(int i=0;i<V[0].size()-1;i++)
		l=lcm(l,abs(V[i][i]));

	for(int i=0;i<V[0].size()-1;i++){
		int mul=l/abs(V[i][i]);
		cout<<mul*abs(V[i][V[i].size()-1])<<" ";
	}

	cout<<l<<endl;;
}

int main()
{
	while(cin>>S){
		if(S==".") break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main()
{
	char s[100+5];
	scanf("%s",s+1);
	int k;
	cin>>k;
	int p=0;
	for(int i=1;i<=100;i++)
		if(s[i]=='1')
			p=i;
		else
			break;
	if(k<=p)
		cout<<1<<endl;
	else
		cout<<s[p+1]<<endl;
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a%2 == 0 || b%2 == 0) {
  	cout << "Even" << endl;
  }
  else {
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3608
N, M = map(int, input().split())
p = [False]*(N+1)
for _ in range(M):
    res = None
    a, b = map(int, input().split())
    if a == 1:
        res = b
    if b == N:
        res = a
    if res is not None:
        if p[res]:
            print('POSSIBLE')
            exit()
        else:
            p[res] = True
print('IMPOSSIBLE')


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
const int A = 1e6;
vector<int> factor[A + 1];
int freq[A + 1];
int main() {
// ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	for (int i = 1; i <= A; i++)
		for (int j = 1; j * i <= A; j++)
			factor[i * j].push_back(i);
	int n, ans = 0;
	scanf("%d", &n);
	int v[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", v + i);
		freq[v[i]]++;
	}
	for (int i = 0; i < n; i++) {
		bool absent = true;
		freq[v[i]]--;
		for (int f : factor[v[i]])
			if (freq[f])
				absent = false;
		ans += absent;
		freq[v[i]]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 122640
n=gets.to_i
p=gets.split.map &:to_i
cnt=0
p.each_with_index do |e,i|
    if e != i+1
        cnt += 1
        if cnt > 3
            break
        end
    end
end

if cnt==0 || cnt==2
    puts "YES"
else
    puts "NO"
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main(int argc,char* argv[])
{
    ll n,k;
    cin>>n>>k;
    ll h[n],mi=LINF;
    rep(i,n)cin>>h[i];
    sort(h,h+n);
    for(int i=0;i<n-k+1;i++) mi=min(h[i+k-1]-h[i],mi);
    cout<<mi<<endl;
    return 0;
}


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

long long a, b, k;
long long ans;

int main(){

    cin >> a >> b >> k;

    if ((a-k)<=0){
        if ((b-(k-a))>0){
            cout << 0 << " " << b-(k-a) << endl;
        }
        else{
            cout << 0 << " " << 0 << endl;
        }
    }
    else{
        cout << a-k << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

typedef tuple<int, int, int> T;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<T> a(n);
    vector<int> ans(q,-1);
    rep(i,n){
        int s, t, x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        a[i] = make_tuple(x, s, t);
    }
    stable_sort(a.begin(), a.end());
    set<P> s;
    rep(i,q){
        int d;
        cin >> d;
        s.insert(make_pair(d, i));
    }
    rep(i,n){
        int x, l, r;
        tie(x, l, r) = a[i];
        auto it = s.lower_bound(P(l,-1));
        while(it != s.end()){
            if(it->first >= r) break;
            ans[it->second] = x;
            s.erase(it++);
        }
    }
    rep(i,q) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 14424
import fileinput

#for line in fileinput.input():
#    tokens = list(map(int, line.strip().split()))
#    a, b = tokens[0], tokens[1]
#    print(a*b, 2*(a+b))

a = int(input())
h = int(a / (60*60))
m = int((a / 60) % 60)
s = int(a % 60)


print(str(h)+":"+str(m)+":"+str(s))

Measured memory_bytes: 7696
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	string S;
	
	cin >> S;
	
	if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
		cout << "Bad" << endl;
	} else {
		cout << "Good" << endl;
	}


	return 0;
}


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

int main(){
    int N, L;
    cin >> N >> L;
    int a = 1e9;
    int idx = 0;
    int sum = 0;
    for(int i=1; i<=N; i++){
        sum += L+i-1;
        if(a > abs(L+i-1)){
            a = abs(L+i-1);
            idx = i;
        }
    }

    cout << sum - (L+idx-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	int K,N,i;
	cin>>K>>N;
	vector<int> A(N),D(N);
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	for (i=0;i<N-1;i++){
		D[i]=A[i+1]-A[i];
	}
	D[N-1]=K-A[N-1]+A[0];
	sort(D.begin(),D.end());
	int ans=0;
	for (i=0;i<N-1;i++){
		ans+=D[i];
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int sum=0;
  for(int i=0; i<n; ++i) 
  {
    cin >> a[i];
    if (i>0)
    {
      for(int j=i-1; j>=0; --j) sum += a[i]*a[j];
    }
  }
  cout << sum;
  return 0;
}

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

int main(){
  int a[1000005];
  int s,i=2,ans=0,m;
  
  cin >> s;
  a[1]=s;
  while(1){
    if(a[i-1]%2==0){
      a[i]=a[i-1]/2;
    }else{
      a[i]=3*a[i-1]+1;
    }
    for(int j=1;j<i;j++){
      if(a[j]==a[i]){
	ans=1;
	m=i;
      }
    }
    if(ans==1){
      break;
    }
    i++;
  }
  
  cout << m << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n,q;
  cin>>n;
  vector <int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  cin>>q;
  for(int i=0;i<q;i++){
    int k;
    cin>>k;
    cout<<binary_search(a.begin(),a.end(),k)<<endl;
  }
  return 0;

}



Measured memory_bytes: 3092
LI = lambda: list(map(int, input().split()))

N, M = LI()
A = [int(input()) for _ in range(M)]

MOD = 10 ** 9 + 7


def main():
    s = set(A)
    dp = [0] * (N + 1)
    dp[0] = 1
    for i in range(1, N + 1):
        if i in s:
            continue
        v = dp[i - 1]
        if i >= 2:
            v += dp[i - 2]
        dp[i] = v % MOD
    
    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19128
#include <cstdio>
#include <vector>
using namespace std;

int n;
vector<int> a;
bool judge() {
	if (n % 10 == n / 100)
		return true;
	return false;
}
int main(void) {
	scanf("%d", &n);
	if (judge())
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long val; long long name;
bool operator<(const point& rhs) const {
return val < rhs.val;
}
};
*/

ll const MAX = 200005;
ll const MOD = 1e9 + 7;

ll a[MAX];
ll b[MAX];
ll c[MAX] = {};

void makec(ll n) {
	ll u = 1; ll v = 1;
	REP(i, 1, n * 2) {
		if (a[u] > b[v]) {
			c[u + v - 1] = -1;
			v++;
		}
		else {
			c[u + v - 1] = 1;
			u++;
		}
	}
}

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		cin >> a[i];
	}
	REP(i, 1, n) {
		cin >> b[i];
	}
	SORT(a, n); SORT(b, n);
	a[n + 1] = b[n + 1] = 1e16;
	makec(n);
	ll cnt = 0;
	ll ans = 1;
	REP(i, 1, n * 2) {
		if (cnt*c[i] < 0) {
			ans = ans * abs(cnt) % MOD;
		}
		cnt += c[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;


int main() {
	int a,b,c;
	cin >> a >> b >> c;

	if (c <= a+b) {
		cout  << "Yes" << endl;
	}else {
		cout  << "No" << endl;
	}
	
	return 0;
}


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

int main() {
    int L, R;
    cin >> L >> R;
    
    if (L / 2019 != R / 2019) cout << 0 << endl;
    else {
        int ans = 2019 * 2019;
        L %= 2019;
        R %= 2019;
        for (int i = L; i <= R; i++) {
            for (int j = i + 1; j <= R; j++) {
                ans = min(ans, (i * j) % 2019);
            }
        }
        cout << ans << endl;
    }
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
const int maxn = 305;

int a[maxn][maxn], n, m;
int sum[maxn], now[maxn];

bool judge(int x)
{
	memset(sum,0,sizeof(sum));
	fo(i,1,n) sum[a[i][1]] ++, now[i] = 1;
	for(;;)
	{
		int i;
		for(i=1;i<=m;++i)
			if(sum[i]>x)
				break;
		sum[i] = -1;
		if(i==m+1) return true;
		fo(s,1,n) if(a[s][now[s]]==i)
		{
			while(now[s]<=m&&sum[a[s][now[s]]]==-1)++now[s];
			if(now[s]==m+1) return false;
			sum[a[s][now[s]]] ++;
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	fo(i,1,n) fo(j,1,m) scanf("%d",&a[i][j]);
	int lb=1,ub=n,mid,pos;
	while(lb<=ub)
	{
		mid=lb+ub>>1;
		if(judge(mid)) pos=mid,ub=mid-1;
		else lb=mid+1;
	}
	printf("%d\n",pos);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,k,q,a[10005],b[10005],ans=1e9;
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<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
bool check(int l,int r){
	int p=0,j,t,s=0;
	for(int i=1;i<=n+1;++i)
		if(a[i]<b[l]){
			for(t=0,j=p;++j<i;)if(a[j]<=b[r])++t;
			s+=max(0,min(t,i-p-k));p=i;
		}
	return s>=q;
}
int main(){
	n=read(),k=read(),q=read();
	for(int i=1;i<=n;++i)a[i]=read(),b[i]=a[i];
	sort(b+1,b+n+1);
	for(int i=1,j=1;i<=n;++i){
		while(j<=n&&!check(i,j))++j;
		if(j<=n)ans=min(ans,b[j]-b[i]);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
X, N = map(int, input().split())
ans = sorted(list(set(range(-50, 51)) - set([Y - X for Y in list(map(int, input().split()))])), key=lambda x: abs(x))
if len(ans) == 1:
    print(X + ans[0])
elif ans[0] == - ans[1]:
    print(X + min(ans[0], ans[1]))
else:
    print(X + ans[0])


Measured memory_bytes: 9204
import math
N = int(input())
a = math.floor(N / 4)
b = math.floor(N / 7)
ans = "No"
for i in range(a + 1):
  for j in range(b + 1):
    if i * 4 + j * 7 == N:
      ans = "Yes"
      break
  else:
    continue
  break
print(ans)


Measured memory_bytes: 62092
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ll n,m;
    cin >> n >> m;
    ll a[m];
    string s[m];
    for(ll i=0;i<m;++i) cin >> a[i] >> s[i];
    ll ac=0, wa=0;
    ll l=max(n,m);
    ll cnt[l];
    ll ans[l];
    for(ll i=0;i<l;++i) {
        cnt[i]=1;
    }
    for(ll i=0;i<m;++i) {
      if(s[i]=="AC") ans[a[i]]=1;
    }
    for(ll i=0;i<m;++i) {
        if(s[i]=="AC" && cnt[a[i]]!=0) {
            ++ac;
            cnt[a[i]]=0;
        }
        if(s[i]=="WA" && cnt[a[i]]!=0 && ans[a[i]]==1) {
            ++wa;
        }
    }
    cout << ac << " " << wa << endl;
}



Measured memory_bytes: 8064
fn main() {
    let _n = read::<usize>();
    let mut v = read_vec::<u32>();
    v.sort();
    println!("{}", v.iter().max().unwrap() - v.iter().min().unwrap());
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

    int H, W;
    int x[200][200];
    string s[200];

    cin >> H >> W;
    rep(i, 0, H) rep(j, 0, W) x[i][j] = INF;

    rep(i, 0, H) cin >> s[i];

    if (s[0][0] == '#')
        x[0][0] = 1;
    else
        x[0][0] = 0;

    rep(i, 0, H)
    {
        rep(j, 0, W)
        {
            if (i < H - 1)
            {
                if (s[i][j] == '.' && s[i + 1][j] == '#')
                    chmin(x[i + 1][j], x[i][j] + 1);
                else
                    chmin(x[i + 1][j], x[i][j]);
            }

            if (j < W - 1)
            {
                if (s[i][j] == '.' && s[i][j + 1] == '#')
                    chmin(x[i][j + 1], x[i][j] + 1);
                else
                    chmin(x[i][j + 1], x[i][j]);
            }
        }
    }

    cout << x[H - 1][W - 1] << '\n';
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while ( left < right ) {
		mid = ( left + right) / 2;
		if ( key == A[mid] ) return 1;
		if ( key > A[mid] ) left = mid + 1;
		else if ( key < A[mid] ) right = mid;
	}
	return 0;
}

int main() {
	int i, q, k, sum = 0;

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

	scanf("%d", &q);
	for ( i = 0; i < q; i++ ) {
		scanf( "%d", &k );
		if ( binarySearch( k ) ) sum++ ;
	}
	printf("%d\n" , sum);

	return 0;
}



Measured memory_bytes: 2952
#include <iostream>
using namespace std;
using ll = long long;
int main() {
    int n,m;
    cin >> n >> m;
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= (m - i);
        ans %= 1000000007;
    }
    ll p = 1;
    ll q = 0;
    for (int i = 0; i < n; i++) {
        ll pp = p;
        ll qq = q;
        p *= (m - n);
        p += qq * (m - n + 1);
        q = (qq+pp) * (n - i - 1);
        p %= 1000000007;
        q %= 1000000007;
    }
    cout << ans*p%1000000007 << endl;
}

Measured memory_bytes: 3164
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
csf = [tuple(li()) for _ in range(n-1)]

for start in range(n-1):
    time = csf[start][1]
    for station in range(start,n-1):
        if time >= csf[station][1]:
            time = (-(-time//csf[station][2]))*csf[station][2]
            time += csf[station][0]
            
        else:
            time = csf[station][1]
            time += csf[station][0]
            
    print(time)
    
print(0)

Measured memory_bytes: 3188
import sys
 
t = sys.stdin.read()
a = map(int, t.split("\n")[1].split())
 
def check(a):
    for b in a:
        if b % 2 == 0:
            if b % 3 == 0 or b % 5 == 0:
                pass
            else:
                return False
    return True
 
if check(a):
    print "APPROVED"
else:
    print "DENIED"
    

Measured memory_bytes: 2568
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    cin >> n;
    ll a[n+1],b[n];
    inrep(n+1,a);
    inrep(n,b);

    ll ans = 0;
    
    rep(i,0,n){
	rep(j,i,i+2){
	    if(b[i] >= a[j]){
		ans += a[j];
		b[i] -= a[j];
		a[j] = 0;
	    }else{
		ans += b[i];
		a[j] -= b[i];
		b[i] = 0;
	    }
	}
    }
    P(ans);
    return  0;
}


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


void solve(long long N, long long K){
	if (K == 1) {
		cout << 0 << endl; 
		return; 
	}

	long long q = N/K; 
	long long m = N - q*K; 
	long long mp = abs(m - K); 

	cout << min(m, mp) << endl; 
}

// 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);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
//abc119_a.cpp
//Sat Mar  2 08:56:10 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;

	int year = stoi(s.substr(0,4));
	int month = stoi(s.substr(5,2));
	int day = stoi(s.substr(8,2));

//	cout << year << " " << month << " " << day << endl;

	if (year > 2019){
		cout << "TBD" << endl;
	}else if (year == 2019 && month > 4){
		cout << "TBD" << endl;
	}else {
		cout <<"Heisei" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005, inf=1e9+5;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n;cin>>n;
    double arr[n+2];
    memset(arr,0.0,sizeof(arr));
    arr[0]=1.0;
    repn(i,n){
        double corr,incorr;
        cin>>corr;
        incorr = 1.0 - corr;
        bac(j,i+1,0){
            if(j)
            arr[j]=arr[j-1]*corr + arr[j]*incorr;
            if(!j){
                arr[j]*=incorr;
            }
        }
    }
    long double ans=0;
    for(ll heads=0;heads<=n;heads++){
        ll tails = n- heads;
        if(heads>tails){
            ans+=arr[heads];
        }
    }
    cout<<fixed<<setprecision(10)<<ans;
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdlib>

using namespace std;

int a, b, c, k, sum, largest;

int main()
{
    cin >> a >> b >> c >> k;
    largest = max(max(a, b), c);
    sum = a + b + c - largest;
    k--;
    largest *= (2 << k);
    sum += largest;
    cout << sum;
    return 0;
}

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

using namespace std;

int main(){

	string str;
	int a,b;
	while(cin>>str>>a>>b){
		cout<<str<<" "<<a+b<<" "<<a*200+b*300<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
a,b,c,d = map(int, input().split())
U = b - a + 1
import fractions
 
def lcm(x,y):
  return (x * y) // fractions.gcd(x, y)

A = (a-1)//c + (a-1)//d - (a-1)//(lcm(c,d))
B = b//c + b//d - b//(lcm(c,d))
print(U - B + A)

Measured memory_bytes: 5048
n, k = map(int, input().split())
s = input()
ret = ""

ini = s[0]
ret += ini

is_renzoku = False

for key, v in enumerate(s):
    if key == 0:
        continue
    if v != ini and k != 0:
        is_renzoku = True
        if v == "R":
            ret += "L"
        else:
            ret += "R"
    else:
        if is_renzoku:
            k -= 1
        is_renzoku = False
        ret += v

ans = 0
for key, v in enumerate(ret):
    if key == 0: continue
    if v == ret[key-1]: ans += 1

print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
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;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
string S[105];
int A[105];
signed main(){
	cin>>N;
	rep(i,N)cin>>S[i]>>A[i];
	vector<int>v(N);
	iota(all(v),0);
	auto comp=[](int a,int b){
		if(S[a]!=S[b])return S[a]<S[b];
		return A[a]>A[b];
	};
	sort(all(v),comp);
	for(int i:v)cout<<i+1<<"\n";
}


Measured memory_bytes: 3644
import numpy as np

n, l = [int(i) for i in input().split()]
tastes = []
for i in range(n):
    tastes.append(i + l)
if 0 in tastes:
    print(sum(tastes))
elif np.abs(tastes[0]) > np.abs(tastes[-1]):
    print(sum(tastes[:-1]))
elif np.abs(tastes[0]) == np.abs(tastes[-1]):
    print(sum(tastes))
else:
    print(sum(tastes[1:]))

Measured memory_bytes: 21632
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	long long int a,b;
	while(scanf("%lld%lld",&a,&b)!=EOF)
	{
		if(a>0&&b>0)
		printf("Positive\n");
		else if(a<0&&b>0)
		printf("Zero\n");
		else if(a==0||b==0)
		printf("Zero\n");
		else  if(a<0&&b<0)
		{
			if((b-a+1)%2==0)
			printf("Positive\n");
			else
			printf("Negative\n");
		}
		
	}
	return 0;
}

Measured memory_bytes: 128
from math import ceil, log2
n, k = map(int, input().split())
ans = 0.0
for i in range(1, n + 1):
    if k > i:
        ans += (1 / n) * ((1 / 2)**(ceil(log2(k / i))))
    else:
        ans += 1/n
print(ans)

Measured memory_bytes: 3060
from collections import Counter
from collections import defaultdict
from heapq import heapify
from heapq import heappop
from heapq import heappush
from _collections import defaultdict

h,w,m=[int(x) for x in input().split()]

hcnt=defaultdict(int)
wcnt=defaultdict(int)
bomb=set()
for _ in range(m):
    hi,wi=[int(x)-1 for x in input().split()]
    hcnt[hi]+=1
    wcnt[wi]+=1
    bomb.add((hi,wi))

hmax=max(hcnt.values())
wmax=max(wcnt.values())

hidx=[x for x,y in hcnt.items() if y==hmax]
widx=[x for x,y in wcnt.items() if y==wmax]

ofst=-1
for i in hidx:
    for j in widx:
        if not (i,j) in bomb:
            ofst=0
            break
                
print(hmax+wmax+ofst)

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

std::vector<int> z_algorithm(std::string s) {
	int n = s.size();
	std::vector<int> z(n);
	z[0] = n;
	int l = 0, r = 0;
	for(int i = 1; i < n; i++) {
		if (r < i) {
			l = i; r = i;
			for(int j = 0; r < n; j++, r++) {
				if (s[j] != s[r]) break;
			}
			z[i] = r - l;
		} else {
			int p = i - l, q = r - i;
			if (z[p] != q) {
				z[i] = std::min(z[p], q);
			} else {
				l = i;
				for(int j = q; r < n; j++, r++) {
					if (s[j] != s[r]) break;
				}
				z[i] = r - l;
			}
		}
	}
	return z;
}


int main() {
	int n;
	string s;
	cin >> n >> s;
	int mx = 0;
	rep(i, n) {
		string st = s.substr(i);
		auto z = z_algorithm(st);
		for(int j = 1; j < n - i; j++) {
			mx = max(mx, min(z[j], j));
		}
	}
	cout << mx << endl;
}



Measured memory_bytes: 256
/*
* @Author: AsilenceBTF
* @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
* @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-09-16 17:00:32
*/

#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define debug(x) cout << "##### " << x << endl; 
typedef long long ll;

// #define cin in
// #define cout out
// ifstream in("in.txt");
// ofstream out("out.txt");

const int MOD = 1e9 + 7;

ll f[3050];
int main(){
    int n;
    cin >> n;
    for(int i = 3; i <= n; ++i){
        f[i] = 1;
        for(int j = 3; j <= n; ++j){
            if(i - j < 3) break;
            f[i] += f[j];
            f[i] %= MOD;
        }
    }
    cout << f[n] << endl; 
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>

using namespace std;

int ans,tot;

int main (){
    char s[10];
    scanf("%s",s);
    for(int i = 0;i < 3;i++){
	if(s[i] == 'R'){
	    tot ++;
	    ans = max(ans,tot);
	}
	else{
	    tot = 0;
	}
    }
    printf("%d",ans);
    return 0;
}


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

ll N, A, B, C, D, E;

int main() {
  cin >> N >> A >> B >> C >> D >> E;
  ll X = min(A, min(B, min(C, min(D, E))));
  cout << (N + X - 1) / X + 4 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define SIZEN 100000
#define SIZEQ 50000

int binarySearch(int *S, int n, int key){
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (S[mid] == key)
      return 1;
    else if (key < S[mid])
      right = mid;
    else
      left = mid + 1;
  }
  // not found
  return 0;
}

int main(void){
  int n, q, S[SIZEN] = {0}, T[SIZEQ] = {0}, C = 0, i;

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &S[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++)
    scanf("%d", &T[i]);

  // search for S
  for (i = 0; i < q; i++)
    if (binarySearch(S, n, T[i]))
      C++;
  printf("%d\n", C);

  return 0;
}

Measured memory_bytes: 1192
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
b=gets.chomp.to_i
puts a[b-1]

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	if(n==3||n==5||n==7) print1("YES");
	else print1("NO");
	return 0;
}


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

i = 0
while i < n:
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 and a[i] % 5 != 0:
      break
  
  i += 1

print('APPROVED' if i == n else 'DENIED')

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    bool bool_x = false;
    bool bool_y = false;
    // 水平方向の計算
    if(0<=x-r&&w>=x+r){
        bool_x = true;
    }
    if(0<=y-r&&h>=y+r){
        bool_y = true;
    }
    if(bool_x == true && bool_y == true){
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }
}


Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n;
	cin>>n;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	sort(all(in));
	int mi=inf;
	rep(i,n)loop(j,max(0,i-10),min(n,i+10))if(i!=j)
		mi=min(mi,(in[i].first-in[j].first)*(in[i].first-in[j].first)+
			(in[i].second-in[j].second)*(in[i].second-in[j].second));
	cout<<mi<<endl;
}

Measured memory_bytes: 4896
MOD = 10 ** 9 + 7
ONE = '1'.freeze

def nCk(n, k)
  res = 1
  i = k
  j = 1
  while i > 0
    res = res * (n - i + 1)
    res %= MOD
    j *= i
    j %= MOD
    i -= 1
  end
  res *= inv(j)
  res %= MOD
  res
end

def repeated_nCk(n, k)
  # 仕切りのイメージで
  nCk(n + k - 1, n - 1) % MOD
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

s = gets.to_i
ans = 0
div = s / 3
div.times do |i|
  group = i + 1
  rest = s - 3 * group
  ans += repeated_nCk(group, rest)
end
puts ans % MOD


Measured memory_bytes: 14376
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
    string s; cin >> s;
    int size = s.size();
    int cnt = 0;
    for(int i = 0; i < size / 2; i++){
        if(s[i] != s[size-i-1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> ans(N);
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    ans.at(A-1)=i+1;
  }
  for(int i=0;i<N;i++){
    cout << ans.at(i);
    if(i==N-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}
    

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

int main() {
string s,t,u;
cin >> s >>t >> u;
cout << "A" << t.at(0) << "C" << endl;
 }

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        double h,w; cin>>h>>w;
        if(h==1||w==1)cout<<1<<endl;
        else cout<<(long)ceil(h*w/2)<<endl;
}

Measured memory_bytes: 256
i = gets.chomp.split(" ").map(&:to_i);
i.sort!
if i[0] == i[1]
  if i[1] == i[2] 
    puts "No"
  else 
    puts "Yes"
  end
else
  if i[1] == i[2]
    puts "Yes"
  else
    puts "No"
  end
end

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

int main()
{
    char a;
    cin >> a;
    string c = "qwertyuiopasdfghjklzxcvbnm";
    rep(i, c.length())
    {
        if (c[i] == a)
        {
            cout << 'a' << endl;
            return 0;
        }
    }
    cout << 'A' << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int A = rei();
	int B = rei();
	cout << (B-1+A-2) / (A-1) << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll n, m;
	cin >> n >> m;
	vector<ll> v;
	v.push_back(0);
	for( int i = 0; i < n; ++i ){
		ll temp;
		cin >> temp;
		v.push_back((temp+v.at(i))%m);
	}
	/*
	a 個の同じ数に対して，区間のとり方は aC2 = a * (a-1) / 2 通りある
	*/
	sort(v.begin(), v.end());
	ll test = v.at(0);
	ll g = 1;
	ll res = 0;
	v.push_back(m);
	for( int i = 1; i <= n+1; ++i ){
		if( test == v.at(i) ){
			g++;
		} else {
			test = v.at(i);
			res += (g*(g-1))/2;
			g = 1;
		}
	}
	cout << res << endl;
	return 0;
}

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

int main()
{
	int sum = 1, n, x,cnr=0;
	cin >> n >> x;
	int *a = new int[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	int *cnt = new int[n];
	for (int i = 0; i < n; ++i)
	{
		cnr += a[i];
		cnt[i] = cnr;
	}
	for (int i = 0; i < n; ++i)
	{
		if (cnt[i] <= x)
			sum++;
	}
	cout << sum;
	return 0;
}

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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
#define ll long long
using namespace std;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  loop(0, N, i) {
    int x, y;
    cin >> x >> y;
    A[i] = make_pair(x, y);
  }
  sort(A.begin(), A.end());

  double total = 0;
  int count = 0;
  do {
    loop(1, N, i) {
      int vx = A[i].first - A[i-1].first;
      int vy = A[i].second - A[i-1].second;
      total += sqrt(vx*vx + vy*vy);
    }
    count++;
  } while(next_permutation(A.begin(), A.end()));
  cout << fixed << setprecision(9) << total/count << endl;
}


Measured memory_bytes: 3852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
		int day = 0;
		for (int i = 0; i < S.length(); i++) {
			char s = S.charAt(i);
			char t = T.charAt(i);

			if (s == t) {
				day++;
			}
		}
		System.out.println(day);
		sc.close();

	}
}


Measured memory_bytes: 22612
t_hp,t_ap,a_hp,a_ap=map(int,input().split())
if t_hp%a_ap==0:
    tp=t_hp//a_ap
else:
    tp=t_hp//a_ap+1
if a_hp%t_ap==0:
    ap=a_hp//t_ap
else:
    ap=a_hp//t_ap+1

if ap<=tp:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 500;
const int N2 = 100000;

int c[N+1][N+1], ans[N2];

int main() {
	int n,m,q;cin>>n>>m>>q;
	rep(i,n+1) rep(j,n+1) c[i][j]=0;
	int l,r;
	rep(i,m) {cin>>l>>r;c[l][r]++;}
	for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) c[i][j]+=c[i][j-1];
	for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) c[i][j]+=c[i-1][j];
	int p,q2;
	rep(i,q) {cin>>p>>q2;ans[i]=c[q2][q2]-c[p-1][q2];}
	rep(i,q) cout<<ans[i]<<endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)

int ordnum(int n)
{
    int ret = 0;
    while (n != 0)
    {
        ret++;
        n /= 10;
    }
    return ret;
}

int main()
{
    string s;
    cin >> s;
    int a[s.size()];
    rep(i, s.size()) a[i] = 0;
    int r[2] = {0, 0};
    int l[2] = {0, 0};
    int cnt = 0;
    int pos = -1;
    int i = 0;
    while (i < s.size())
    {
        rep(j, 2)
        {
            r[j] = 0;
            l[j] = 0;
        }
        cnt = 0;
        while ((s[i] == 'R'))
        {
            r[cnt % 2]++;
            cnt++;
            i++;
        }
        pos = i - 1;
        a[pos] += r[0];
        a[pos + 1] += r[1];
        cnt = 0;
        while ((s[i] == 'L') && i < s.size())
        {
            l[cnt % 2]++;
            cnt++;
            i++;
        }
        a[pos] += l[1];
        a[pos + 1] += l[0];
    }
    rep(i, s.size()) cout << a[i] << " ";
    cout << endl;
    return 0;
}

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

int main() {
    int n, m, t;
    cin >> n >> m >> t;
    int imos[t + 1];
    memset(imos, 0, sizeof(imos));

    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        imos[a - m + 1] += 1;
        if (a + m + 1 <= t)
            imos[a + m + 1] -= 1;
    }

    int ans = 0;
    for (int i = 0; i < t; i++) {
        imos[i + 1] += imos[i];
    }

    for (int i = 1; i <= t; i++)
        if (imos[i] == 0) ans++;

    cout << ans << endl;
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define repp(i, n) for (int i = 0; i <=(int)(n); i++)
int main(){
    string s,t;
    cin >> s >> t;
    rep(i,s.length()){
        if(s[i]!=t[i])
            {
                cout << "No" ;
                return 0;
            }
    }

cout << "Yes";
 return 0;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MAX 100002
#define NIL -1
int n, D[MAX];

struct node{
    int p, l, r;
};
node T[MAX];

void printTree(){
    for(int i=0;i<n;++i){
        printf("node %d: parent = %d, depth = %d, ",i,T[i].p,D[i]);
        if(T[i].p == NIL) printf("root, [");
        else{
            if(T[i].l == NIL) printf("leaf, [");
            else printf("internal node, [");
        }
        for(int j=T[i].l;j != NIL;){
            printf("%d",j);
            j = T[j].r;
            if(j != NIL){
                printf(", ");
            }
            else break;
        }
        printf("]\n");
    }
}


void recDepth(int pos, int depth){
    D[pos] = depth;
    if(T[pos].l != NIL){
        recDepth(T[pos].l,depth+1);
    }
    if(T[pos].r != NIL){
        recDepth(T[pos].r,depth);
    }
}

int main(){

    scanf("%d",&n);
    for(int i=0;i<n;++i){
        T[i].l = T[i].p = T[i].r = NIL;
        D[i] = 0;
    }
    int id, num_child, child_id, sib, root;

    for(int i=0;i<n;++i){
        cin >> id >> num_child;
        for(int j=0;j<num_child;++j){
            cin >> child_id;
            if(j==0) T[id].l = child_id;
            else T[sib].r = child_id;
            sib = child_id;
            T[child_id].p = id;
        }
    }
    for(int i=0;i<n;++i){
        if(T[i].p==NIL) root=i;
    }
    recDepth(root,0);
    printTree();
    return 0;
}



Measured memory_bytes: 4696
import java.util.*;

public class Main{
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args){
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++)
           arr[i] = in.nextInt();

        long count = 0;
        int max = arr[0];
        for(int i = 1; i < n; i++){
            if(arr[i] < max)
                count += (max - arr[i]);
            max = Math.max(max, arr[i]);
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 60964
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)

	a := 0
	arr := [3]int{}
	var e error
	for i, r := range n {
		arr[i], e = strconv.Atoi(string(r))
		if e != nil {
			fmt.Println(e)
		}
	}
	var t = arr[0]
	if arr[0] < arr[1] || arr[0] < arr[2] {
		t++
	}
	a = t*100 + t*10 + t
	fmt.Println(a)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,M;
    cin >> N >> M;
    if(N<M){
        for(int i=0;i<M;i++){
            cout << N;
        }
    }
    else{
        for (int i=0;i<N;i++)
        cout << M;
    }
}

Measured memory_bytes: 256