akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {a[i]=sc.nextInt();}
        // int n=sc.nextInt();

        long n=sc.nextLong(), m=sc.nextLong(), d=sc.nextLong();
        double ans=m-1;
        if(d==0)
            out.println(ans/n);
        else
            out.println(ans*2*(n-d)/(n*n));
        out.flush();
    }
    

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class P implements Comparable<P>{
        long d;
        int id;
        P(int  id, long d) {
            this.id=id;
            this.d=d;
        } 
          
        public int compareTo(P p){
            long r = d - p.d;
            if(r==0)return 0;
            else return r > 0 ? 1 : -1;//des
        }
    }

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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

int main() {
  int N, H;
  cin >> N >> H;
  vector<int> a(N), b(N);
  for (int i = 0; i < N; ++i) cin >> a[i] >> b[i];
  
  int a_max = 0;
  for (int i = 0; i < N; ++i) if (a_max < a[i]) a_max = a[i];
  vector<bool> thrower(N);
  for (int i = 0; i < N; ++i) thrower[i] = (b[i] > a_max);
  vector<int> c;
  for (int i = 0; i < N; ++i) if (thrower[i]) c.push_back(b[i]);
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  
  int cnt = 0;
  int sum = 0;
  while (cnt < c.size()) {
    sum += c[cnt];
    ++cnt;
    if (sum >= H) break;
  }
  if (sum >= H) {
    cout << cnt << endl;
    return 0;
  } else {
    int h = (H - sum - 1) / a_max + 1;
    cout << cnt + h << endl;
    return 0;
  }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    vector<ll> v;
    ll sum=0;
    for (long long i = 0; i < N; i++) {
        sum ^= a[i];
    }
    // debg(sum);
    for (long long i = 0; i < N; i++) {
        v.push_back(sum^a[i]);
    }
    vout(v);

    return 0;
}


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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> values(n + 1);
  values[0] = 1;
  for (int i = 1; i <= n; i++) {
    values[i] = values[i - 1] * i;
  }
  return values;
}

vector<vector<FiniteField>> MakePartitionNumberTable(int n, int k) {
  vector<vector<FiniteField>> table(n + 1, vector<FiniteField>(k + 1));
  for (int i = 0; i <= n; i++) {
    table[i][1] = 1;
    for (int j = 2; j <= k; j++) {
      table[i][j] = table[i][j - 1];
      if (i - j >= 0) table[i][j] += table[i - j][j];
    }
  }
  return table;
};

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

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

  if (n < k) {
    cout << 0 << endl;
    return 0;
  }

  auto p_table = MakePartitionNumberTable(n - k, k);
  cout << p_table[n - k][k].Value() << endl;
}



Measured memory_bytes: 4216
N = int(input())
A = [(int(input()), i) for i in range(N)]
A.sort(key=lambda x:x[0])
idx = [0] * N
for i in range(N): idx[A[i][1]] = i

for i in range(N):
    j = idx[i]
    ans = A[-1]
    if j == N-1: ans = A[-2]
    print(ans[0])


Measured memory_bytes: 39440
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int64_t>a(n); for(auto&&i:a)cin>>i;
	int64_t base=0;
	for(auto&&i:a)base=(base+i)%mod;
	int64_t ans=0;
	for(auto&&i:a){
		base=(mod+base-i)%mod;
		ans+=base*i%mod;
		ans%=mod;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll N;
    cin >> N;
    vector<ll> Ans(N+10,0);
    
    for(ll x=1;x<=N;x++){
        for(ll y=1;y<=N;y++){
            if((x+y)*(x+y)>2*N)break;
            for(ll z=1;z<=N;z++){
                if((x+z)*(x+z)>2*N)break;
                if((z+y)*(z+y)>2*N)break;
                
                ll R = (x+y)*(x+y)+(z+y)*(z+y)+(x+z)*(x+z);
                if(R%2==1)continue;
                if(R/2 > N+5)continue;
                Ans[R/2]++;
            }
        }
    }
    
    REP(i,N){
        cout << Ans[i+1] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3628
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = np.array(list(sr()))
length = len(S)
answer = np.count_nonzero(S[:length//2] != S[::-1][:length//2])
print(answer)


Measured memory_bytes: 13712
#include <cstdio>
int students[100001];
int main() {
  	int N, A;
 	scanf("%d", &N);
  
  	for (int i = 0; i < N; ++i) {
    	scanf("%d", &A);
      	students[A - 1] = i + 1;

    }

  	for (int i = 0; i < N; ++i) {
    	printf("%d%c", students[i], i == N - 1 ? '\n' : ' ');
    }
  	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    ll cnt = 0;
    for(int i = min(a,b);i>0;i--){
        if(a%i == 0 && b%i == 0)cnt++;
        if(cnt == k){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i,n[5];
	for(i=0;i<5;i++) {
		scanf("%d",&n[i]);
		if(n[i]<39)n[i]=40;
	}
	for(i=0;i<4;i++) {
		n[i+1]+=n[i];
	}
	printf("%d\n",n[4]/5);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll x,y,k,val,val1;
    cin>>x>>y>>k;
    vector<ll>a;
    for(int i=1;i<=min(x,y);i++)
    {
        if(x%i==0 && y%i==0)
        {
            a.pb(i);
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    cout<<a[k-1]<<endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int mod=1e9+7;
struct Combin{
	#define N 8005
	int fac[N],rv[N],facrv[N];
	Combin(){
		fac[0]=rv[1]=facrv[0]=1;
		for(int i=2;i<N;i++) rv[i]=((-(LL)(mod/i)*rv[mod%i]%mod)+mod)%mod;
		for(int i=1;i<N;i++) fac[i]=(LL)fac[i-1]*i%mod;
		for(int i=1;i<N;i++) facrv[i]=(LL)facrv[i-1]*rv[i]%mod;
	}
	int C(int r1,int n1){
		if(r1>n1) return 0;
		return fac[n1]*(LL)facrv[r1]%mod*facrv[n1-r1]%mod;
	}
	#undef N
}C;
#define N 2005
int n;
int mp[N+N][N+N];
int main(){
	scanf("%d",&n);
	long long ans=0;
	for(int i=1,x,y;i<=n;i++){
		scanf("%d%d",&x,&y);
		mp[N-x][N-y]++;
		mp[N+x][N+y]--;//mark it
		ans=ans-C.C(2*x,2*x+2*y);
	}
	ans%=mod;
	for(int i=1;i<N+N;i++)
		for(int j=1;j<N+N;j++){
			int v=(mp[i-1][j]+mp[i][j-1])%mod;
			if(mp[i][j]<0) ans=(ans-v*1LL*mp[i][j])%mod,mp[i][j]=0;
			mp[i][j]+=v;
		}
	cout<<((ans*((mod+1)/2)%mod)+mod)%mod<<endl;
	return 0;
} 

Measured memory_bytes: 63232
#include <iostream>
#include <list>
#include <queue>

using namespace std;
typedef long long Long;

int main()
{
	int k;
	Long ans=0;

	queue<Long> lun;
	
	cin>>k;

	for(int i=1 ; i<10 ; i++) {
		lun.push(i);
	}

	for(int i=0 ; i<k ; i++) {
		ans = lun.front();
		if(ans%10!=0) {
			lun.push(ans*10+ans%10-1);
		}
		lun.push(ans*10+ans%10);
		if(ans%10!=9) {
			lun.push(ans*10+ans%10+1);
		}
		lun.pop();
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
#define pll pair<long long,long long>
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int n,d[105],dep[105],maxd[105];
vector<int> G[105];
pll ans;
void add(int x,int y)
{
	G[x].push_back(y);G[y].push_back(x);
	d[x]++,d[y]++;
}
int bfs(int x,int y)
{
	int maxx=0;
	memset(dep,0,sizeof(dep));
	memset(maxd,0,sizeof(maxd));
	queue<int> q;
	dep[x]=1,dep[y]=1;
	q.push(x);if(y) q.push(y);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		maxd[dep[u]]=max(maxd[dep[u]],d[u]);
		maxx=max(maxx,dep[u]);
		int sz=G[u].size();
		for(int i=0;i<sz;i++)
		{
			int nx=G[u][i];
			if(!dep[nx]) dep[nx]=dep[u]+1,q.push(nx);
		}
	}
	return maxx;
}
void Solve(int x,int y)
{
	pll s;
	s.first=bfs(x,y);s.second=maxd[1]-(y!=0);
	for(int i=2;i<=n;i++)
	{
		if(maxd[i]==1) break;
		s.second=s.second*(maxd[i]-1);
	}
	if(y) s.second*=2;
	ans=min(ans,s);
}
int main()
{
	n=read();
	if(n==2)
	{
		puts("1 2");
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		add(x,y);
	}
	ans=pll(1e18,1e18);
	for(int i=1;i<=n;i++)
	{
		Solve(i,0);
		int sz=G[i].size();
		for(int j=0;j<sz;j++) Solve(i,G[i][j]);
	}
	printf("%lld %lld\n",ans.first,ans.second);
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

string s, t;

string Position(int from){
  string res = s;
  for(int i = 0;i < sz(t);++i){
    if(res[from + i] != '?' && res[from + i] != t[i])
      return "";
    res[from + i] = t[i];
  }
  for(int i = 0;i < sz(res);++i)
    if(res[i] == '?') res[i] = 'a';
  return res;
}

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

  string ans = "";

  for(int i = 0;i + sz(t) <= sz(s);++i){
    auto use = Position(i);
    if(use.empty()) continue;
    if(ans.empty()) ans = use;
    relaxMin(ans, use);
  }

  if(ans.empty()) cout << "UNRESTORABLE\n";
  else cout << ans << '\n';

  return 0;
}


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

int main(void){
    int n, k;
    string str;
    cin >> n >> k >> str;

    if(str[k-1] == 'A'){
        str[k-1] = 'a';
    } else if(str[k-1] == 'B'){
        str[k-1] = 'b';
    } else {
        str[k-1] = 'c';
    }

    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void asumikana(int* minaseinori, int horieyui) {
	if (*minaseinori < horieyui) *minaseinori = horieyui;
}

int main(void) {
	int A, B;
	int mizukinana = 0;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	asumikana(&mizukinana, A + B);
	asumikana(&mizukinana, A + (A - 1));
	asumikana(&mizukinana, B + (B - 1));
	asumikana(&mizukinana, B + A);
	printf("%d\n", mizukinana);
	return 0;
}


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

ll point[MAX];

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

  for (int i = 0; i < n; ++i) {
    int d;
    cin >> d;

    ++point[d];
  }

  for (int i = 0; i < MAX; ++i) point[i+1] += point[i];

  int ans = 0;
  for (int i = 1; i < MAX; ++i) {
    ll l = point[i];
    ll r = point[MAX-1] - point[i];

    if (l == r) ++ans;
  }

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return g * (x / g) * (y / g);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll ans = b-a+1;
  ans -= (b/c-(a+c-1)/c+1);
  ans -= (b/d-(a+d-1)/d+1);
  ll l = lcm(c, d);
  ans += (b/l-(a+l-1)/l+1);
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



int main() {
	
	int d, n;
	cin >> d >> n;
	ll ans;

	if (d == 0) {
		ans = n;
		if (n == 100)ans = 101;
	}
	else if (d == 1) {
		ans = n * 100;
		if (n == 100)ans = 10100;
	}
	else {
		ans = n * 10000;
		if (n == 100)ans = 1010000;
	}

	cout << ans << endl;

	return 0;
}

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

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

    int n;cin>>n;
    vector<string> s(n);
    for(int i=0;i<n;i++) cin>>s[i];
    int res=0;
    for(int b=0;b<n;b++){
        bool f=true;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(s[i][(j+b)%n]!=s[j][(i+b)%n]) f=false;
            }
        }
        if(f) res++;
    }
    cout<<res*n<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


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

	int adl=0, adr=0;

	for (int i = 0; i < n; i++) {
		if (str[i] == '(') {
			adr++;
		}
		else {
			adr--;
			if (adr < 0) {
				adr = 0;
				adl++;
			}
		}
	}

	
	string ans = str;
	for (int i = 0; i < adl; i++) ans = '(' + ans;
	for (int i = 0; i < adr; i++)ans = ans + ')';

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N;
int h[100001];
int cost[100001];
int main() {
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&h[i]);
	}
	cost[1]=abs(h[1]-h[0]);
	for(int i=2;i<N;i++){
		cost[i]=min(cost[i-1]+abs(h[i-1]-h[i]),cost[i-2]+abs(h[i-2]-h[i]));
	}
	printf("%d",cost[N-1]);
	
	return 0;
}
//cost[i]=min((cost[i-1]+abs(hi-hi-1)),(cost[i-2]+abs(hi-hi-2));

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	int n,m;
	while(true){
	cin>>n>>m;
	if(n==0&&m==0)break;
	double ans=0.0;
	int ta[110]={0};
	int a=0,b=m-1,ma=0,ku=0;
	for(int i=1;i<=n;i++){
		int tmp;
		cin>>tmp;
		for(int j=0;j<110;j++){
		if(a+m*j<=tmp&&b+m*j>=tmp){
		ta[j]++;
		break;
		}//endif
		}//endfor
	}//endfor
	for(int i=0;i<110;i++){ma=max(ma,ta[i]);if(ta[i]!=0)ku=i;}
	//cout<<ku<<" :";
	//for(int i=0;i<20;i++)cout<<ta[i]<<" ";cout<<endl;
	for(int i=0;i<=ku;i++){

	//cout<<ta[i]<<" "<<ku-i<<" "<<ku<<" "<<endl;
	ans+=((double)ta[i]/(double)ma*(((double)ku-(double)i)/(double)ku));
	//printf("%f\n",((double)ta[i]/(double)ma*(((double)ku-(double)i)/(double)ku)));
	}
	ans+=0.01;
	printf("%.20f\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct node
{
	int cnt, xx;
}_1[maxn], _2[maxn];
bool cmp(const node &a, const node &b)
{
    return a.cnt > b.cnt;
}
int n;
void slove()
{
    scanf("%d", &n);
	for (int x, i = 1; i <= n; ++ i)
    {
		scanf("%d", &x);
		if (i & 1) _1[x].cnt++, _1[x].xx = x;
		else _2[x].cnt++, _2[x].xx = x;
	}
	sort(_1 + 1, _1 + 100000 + 1, cmp);
	sort(_2 + 1, _2 + 100000 + 1, cmp);
	if (_1[1].xx != _2[1].xx)
        printf("%d\n", n - _1[1].cnt - _2[1].cnt);
	else
        printf("%d\n", n - max(_1[1].cnt + _2[2].cnt, _1[2].cnt + _2[1].cnt));
    return ;
}
signed main()
{
	slove();
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int n, m;
	scanf("%d %d", &n, &m);

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

	int T[n + 1];
	for (int i = 1; i <= n; ++i) {
		T[i] = 50000;
	}
	T[0] = 0;
	for (int i = 0; i < m; ++i) {
		for (int j = M[i]; j <= n; ++j) {
			T[j] = min(T[j], T[j - M[i]] + 1);
		}
	}
	cout << T[n] << endl;

	return 0;
}

Measured memory_bytes: 3388
// C - A x B + C
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(ll i=(ll)(s);i<(ll)(e);++i)

int main(){
	ll n; cin>>n;
	ll cnt = 0;
	rp(a, 1, n){
		ll bn = (n-1) / a;
		rp(b, 1, bn+1){
			ll c = n - a*b;
			if(c <= 0) break;
			cnt++;
		}
	}
	cout<< cnt <<endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

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

    vector<long long> A(N);

    for(long long i = 0;i < N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    long long cnt = 0;
    for(long long i = 0;i < N; i++){
        long long tmp = A[i];
        long long j = i;
        long long numcnt = 0;
        while(tmp == A[j]){
            numcnt++;
            j++;
        }
        i = i + 2 <= j ? j - 1 : i;
        cnt += numcnt % 2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll L,R;
  cin >> L >> R;
  if (R - L > 2500) {
    cout << 0 << endl;
  } else {
    ll ans = 2050;
    for (ll i = L; i < R; i++) {
      for (ll j = i + 1LL; j <= R; j++) {
        ans = min(ans,(i * j) % 2019);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int X,Y,input;

  scanf("%d",&input);

  X = input / 100;
  Y = input - X * 100;

  if (1 <= X && X <= 12 && 1 <= Y && Y <= 12) {
    printf("AMBIGUOUS\n");
  } else if (1 <= Y && Y <= 12) {
    printf("YYMM\n");
  } else if (1 <= X && X <= 12) {
    printf("MMYY\n");
  } else {
    printf("NA\n");
  }
  
  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int  ans=(s.size()-1)*9,tmp,sum=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!='0')
        {
            tmp=sum+s[i]-'0'-1+(s.size()-1-i)*9;
            ans=max(ans,tmp);
        }
        sum+=s[i]-'0';
    }
    ans=max(ans,sum);
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
# coding: utf-8
lines = $stdin.read
array = lines.split("\n")

a = array[0].split(" ")[0].to_i
b = array[0].split(" ")[1].to_i
c = array[0].split(" ")[2].to_i

ab = a+b
bc = b+c
ca = c+a

arr = [ab, bc, ca].sort

puts arr[0]


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
typedef long long int ll;
const int maxn = 100100100;
int n;
ll a[maxn];
ll sum = 0,result = 0;
int main(){
    // freopen("input.in", "r", stdin);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }

    for(int i = 1; i <= n; i++){
      if(a[i] != 0){
        sum += a[i];
      }
      else{
        result += sum / 2;
        sum = 0;
      }
    }

    cout << result + sum / 2 << endl;
  return 0;
}



Measured memory_bytes: 1024
n = int(input())
ary = [int(_) for _ in input().split()]
q = int(input())
qs = [int(_) for _ in input().split()]


def search_rec(ind, s, q):
    if ind == n:
        return False
    else:
        tmp = ary[ind]
        if s + tmp == q:
            return True
        else:
            return search(ind + 1, s, q) or search(ind + 1, s + tmp, q)


def search(q):
    sum_ary = [0]

    for i in ary:
        for s in sum_ary:
            if s + i == q:
                return True
        sum_ary += [i + _ for _ in sum_ary]

    else:
        return False


for q in qs:
    if search(q):
        print('yes')
    else:
        print('no')



Measured memory_bytes: 55232
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

struct mint {
    int x;
    mint(int 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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    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;
    }
};
mint F[2100010];
void fact(void) {
	F[0] = mint(1);
	F[1] = mint(1);
	for (int i = 2; i <= 2100000; i++) {
        mint x(i);
		F[i] = x * F[i - 1];
	}
}
 
mint square(mint x) {
    return x * x;
}
 
mint power(mint x, int y) {
    if (y == 0) return mint(1);
    else if (y == 1) return x;
    else if (y % 2 == 0) return square(power(x, y / 2));
    else return square(power(x, y / 2)) * x;
}
 
mint P(int n, int r) {
	if (n < r || n < 0 || r < 0) return mint(0);
	return F[n]/F[n - r];
}
mint C(int n, int r) {
	if (n < r || n < 0 || r < 0) return mint(0);
	mint ret;
	ret = F[n]/(F[n - r] * F[r]);
	return ret;
}
mint H(int n, int r) {
	if (n == 0 && r == 0) return mint(1);
	return C(n + r - 1, r);
}
 
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact();
    int n, k;
    cin >> n >> k;
    k = min(k, n - 1);
    mint ans = 0;
    rep(i, k + 1) {
        int remain = n - i;
        ans += C(n, i) * H(remain, i);
        //cout << C(n, i).x << " " << H(remain, i).x << endl;
    }
    cout << ans.x << endl;

    return 0;
}
// oo|o|

Measured memory_bytes: 20020
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)

ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
int main(){
	ll n;
	cin>>n;
	ll a[100010]={0};
	ll m=0;
	rep(i,0,n){
		ll x;
		cin>>x;
		a[x]++;
		if(x>m)m=x;
	}
	ll ans=0;
	rep(i,0,m+1){
		ll res=a[i-1]+a[i]+a[i+1];
		if(i==0)res=a[i]+a[i+1];
		ans=max(ans,res);
	}
	cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD


int main() {
    int n;
    cin>>n;
    int ans = 0;

    REP(i,n)
        REP(j,n)
            REP(k,n)
                ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))

sort_p = sorted(p)
dict_p = {}
isOk = True
for i in range(N):
    if p[i] == sort_p[i]:
        continue
    elif len(dict_p) == 0:
        dict_p[sort_p[i]] = p[i]
    elif p[i] in dict_p:
        continue
    else:
        isOk = False
        break

if isOk:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string S; cin >> S;
    int N; cin >> N;
    ll res = 0;
    for(int i = 0; i < N;i++){
        string R; cin >> R;
        R += R;
        if(R.find(S) == string::npos)continue;
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main()
{
	int height, width;
	cin >> height >> width;
	vector<string> grid(height);
	vector<int> pass_number;

	for (int i = 0; i < height; i++) {
		cin >> grid[i];
	}
	for (int x = 0; x < width; x++) {
		int counter = 0;
		for (int y = 0; y < grid.size(); y++) {
			if (grid[y][x] == '.') {
				counter++;
			}
			else {
				break;
			}
		}
		if (counter == height) {
			pass_number.push_back(x);

		}
	}
	
	for (int y = 0; y < grid.size(); y++) {
		
		if (any_of(grid[y].begin(), grid[y].end(), [](char c) {return c == '#'; }))
		{
			for (int x = 0; x < width; x++) {
				if (count(pass_number.begin(), pass_number.end(), x) == 0) {
					cout << grid[y][x];
				}
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>

int n;
int solve(){
	if(n >= 400 && n < 600) return 8;
	if(n >= 600 && n < 800) return 7;
	if(n >= 800 && n < 1000) return 6;
	if(n >= 1000 && n < 1200) return 5;
	if(n >= 1200 && n < 1400) return 4;
	if(n >= 1400 && n < 1600) return 3;
	if(n >= 1600 && n < 1800) return 2;
	if(n >= 1800 && n < 2000) return 1;
	return -1;
}
int main(){ fast;
	cin>>n;
	cout<<solve()<<endl;
	
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define mod 1000000007
using namespace std;

int main(){
	int q;
	cin >> q;
	string X[q],Y[q];
	rep(i,0,q){
		cin >> X[i];
		cin >> Y[i];
	}

	rep(i,0,q){
		int m = X[i].length();
		int n = Y[i].length();
		int dp[m+1][n+1] = {};
		int maxl=0;
		rep(j,0,m){
			rep(k,0,n){
				if(X[i][j] == Y[i][k]) dp[j+1][k+1] = dp[j][k]+1;
				else dp[j+1][k+1] = max(dp[j][k+1],dp[j+1][k]);
			}
		}
		cout << dp[m][n] << endl;
	}
	return 0;
}



Measured memory_bytes: 7100
#include <stdio.h>

char a[150],b[150],c[150];

main() {
    int i,j;
    scanf("%s %s %s", a, b, c);
    for(i=0;a[i]!='\0';i++) {}
    int la=i;
    for(i=0;b[i]!='\0';i++) {}
    int lb=i;
    if(a[la-1]==b[0] && b[lb-1]==c[0]) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

signed main()
{
std::string st;
std::cin >> st;
int d = INT_MAX;
for(int i = 0; i < st.length() - 2; i++){
    int f = 100 * (int)(st[i] - '0');
    int s = 10 * (int)(st[i + 1] - '0');
    int t = (int)(st[i + 2] - '0');
    if(abs(753 - (f + s + t)) < d){
        d = abs(753 - f - s - t);
    }
}
std::cout << d << std::endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
int arr[26];
int main() {
	char c;
	while(scanf("%c",&c)!=EOF) {
		if(c>='A'&&c<='Z')
			arr[c-65]++;
		else if(c>='a'&&c<='z')
			arr[c-97]++;
	}
	for(int i =0;i<26;i++)
	{
		cout<<char(i+97)<<" : "<<arr[i]<<endl;
	}

	return 0;
}


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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

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

    vector<int> alphabet(26, 0);
    
    for(auto i = w.begin(); i != w.end(); i++){
        alphabet[*i - 'a']++;
    }
    
    for(auto x : alphabet){
        if(x % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }

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


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

char str[200];

int is_balanced(int start,int end) {
	int i,j;
	int kakko_nest;
	for(i=start;i<end;i++) {
		if(str[i]==')' || str[i]==']')return 0;
		if(str[i]=='(') {
			kakko_nest=1;
			for(j=i+1;j<end;j++) {
				if(str[j]=='(')kakko_nest++;
				else if(str[j]==')')kakko_nest--;
				if(kakko_nest<=0)break;
			}
			if(j>=end)return 0;
			if(!is_balanced(i+1,j))return 0;
			i=j;
		} else if(str[i]=='[') {
			kakko_nest=1;
			for(j=i+1;j<end;j++) {
				if(str[j]=='[')kakko_nest++;
				else if(str[j]==']')kakko_nest--;
				if(kakko_nest<=0)break;
			}
			if(j>=end)return 0;
			if(!is_balanced(i+1,j))return 0;
			i=j;
		}
	}
	return 1;
}

int main(void) {
	char* cptr;
	while(1) {
		fgets(str,sizeof(str),stdin);
		cptr=strchr(str,'\n');
		if(cptr)*cptr=0;
		if(strcmp(str,".")==0)break;
		puts(is_balanced(0,strlen(str))?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 0
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const input = next()
    if("ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").includes(input)){
        console.log("A")
    }else{
        console.log("a")
    }
}
Main()


Measured memory_bytes: 29676
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
#define endl '\n'
#define int int64_t
#define double long double
// mt19937 rnd(time(0));
// const double TIME_LIMIT = 1.8;
// Heuristic TL: clock() < TIME_LIMIT * CLOCKS_PER_SEC
const int MAXN = 1000001;
const int INF = numeric_limits<int>::max() >> 3;
const int MOD = (int)998244353;

signed main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0); 
	// freopen("FDT.txt","r",stdin);
	int a[2], b[2];
	cin >> a[0] >> b[0] >> a[1] >> b[1];
	int turn = 0;
	while(true){
		a[turn^1] -= b[turn];
		if(a[turn^1] <= 0){
			cout << (turn ? "No" : "Yes");
			return 0;
		} 
		turn ^= 1;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

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

  if (N * A < B) { ANS(N*A); } 
  else { ANS(B); }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int Y = Integer.parseInt(scanner.next());
        scanner.close();

        for (int x = 0; x <= N; x++) {
            for (int y = 0; y <= N; y++) {
                int z = N - x - y;
                if (z < 0) continue;

                if ((x * 10000 + y * 5000 + z * 1000) == Y) {
                    System.out.println(String.format("%d %d %d", x, y, z));
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const int MAX = 1001;
ll x[MAX], y[MAX], z[MAX];
vector<ll> v;
int main() {
   

    int n,m;
    cin >> n >> m;

    for (int i=1;i<=n;i++){
        cin >> x[i] >> y[i] >> z[i];
    }

    ll  ans = 0;
    for (int p=0;p<=7;p++) {
        if(p%4 == 0){
            for (int i=1;i<=n;i++){
                x[i] *= -1;
            }
        }
        if (p%2 == 0){
            for(int i=1;i<=n;i++){
                y[i] *= -1;
            }
        }
        for(int i=1;i<=n;i++){
            z[i] *= -1;
        }
        v.clear();
        for (int i=1;i<=n;i++){
            v.push_back(x[i]+y[i]+z[i]);
        }
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
        ll part = 0;
        for (int i=0;i<m;i++){
            part += v[i];
        }
        if(ans < part){
            ans = part;
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import defaultdict
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

D = defaultdict(int)
for _ in range(int(input())):
    D[input()] += 1
for _ in range(int(input())):
    D[input()] -= 1

print(max(0, max(D.values())))

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

int main() {
  int A;
  int B;
  cin >> A;
  cin >> B;
  int ans;
  ans = A - B * 2;
  if(ans < 0 ){
  ans = 0;
  }
  
  cout << ans;
  /*
  vector<int> suujivec(10);
  int suuji = std::stoi(S);
  int c =0;
   for(int i=10-S.size();i<10;i++){
    int a = int(S.at(c)- '0');
      suujivec.at(i)=a; 
     c++;
   }
  
  vector<vector<int>> data(512, vector<int>(9,0));
 
  int ccc=0;
  long int answer =0;
  for(int i=0;i<data.size();i++){
  for(int j=0;j<data.at(0).size();j++){
    ccc++;
    if(data.at(i).at(j) == 1){ ccc=0; }
    if(j==0){ answer += suujivec.at(9); }
    cout << kaijou(ccc) << endl;
    answer += suujivec.at(8-j) * kaijou(ccc); 
    
  }
  }
   
   for(int i=0;i<data.size();i++){
     for(int j=0;j<data.at(0).size();j++){
     if(j==data.at(0).size()-1){cout << data.at(i).at(j) <<endl;}else{
     cout << data.at(i).at(j);
     }
   }
   }
  */

}

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


int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (s == u) {
        a -= 1;
    } else if (t == u) {
        b -= 1;
    }
    cout << a << " " << b << endl;
    return 0;
}


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

using namespace std;

int main() {
	vector <int> max;
	int maxsize;
	cin >> maxsize;
	max.resize(maxsize);
	
	for (int &i:max) {
		i = 0;
	}
	
	int firstmax;
	cin >> firstmax;
	max.at(0) = firstmax;
	max.at(1) = firstmax;
	
	for (int i = 2; i < maxsize; i++) {
		int maxv;
		cin >> maxv;
		max.at(i) = maxv;
		if (max.at(i-1) > maxv) {
			max.at(i-1) = maxv;
		}
	}
	
	int c = 0;
	for (int &i: max) {
		c += i;
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<cstdlib>
#include<string>
#include <utility>
#include<queue>
#include<algorithm>

using namespace std;
#define MAX 500000
#define SENTI 2000000000
int cnt;

void merge(vector<int>&S, int left, int mid, int right) {

	int i = 0;
	int j = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> R;
	vector<int> L;

	for (int i = 0; i<n1; i++) {
		L.push_back( S[left+i]);
	}
	for (int i = 0; i<n2; i++) {
		R.push_back ( S[mid+i]);
	}

	L.push_back(SENTI);
	R.push_back(SENTI);

	for (int k = left; k<right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			S[k] = L[i];
			i++;
		}
		else {
			S[k] = R[j];
			j++;
		}
	}
	//for (int i = 0; i<S.size(); i++) {
		//cout << S[i]<<" ";
	//}
	//cout << endl;
	

}

void mergesort(vector<int>&S, int left, int right) {
	int mid = 0;
	if (left + 1<right) {
		mid = (right + left) / 2;
		mergesort(S, left, mid);
		mergesort(S, mid, right);
		merge(S, left, mid, right);
	}

}

int main() {

	int n = 0;
	int num = 0;
	cin >> n;
	vector<int> S;

	for (int i = 0; i<n; i++) {
		cin >> num;
		S.push_back(num);
	}

	mergesort(S, 0, n);

	for (int i = 0; i<n; i++) {
		if (i != 0)cout << " ";
		cout << S[i]  ;
	}
	cout << endl;

	cout << cnt;

	cout << endl;
	return 0;
}


Measured memory_bytes: 7868
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int h,  w; cin >> h >> w;
    vector<vector<char>> stage(h, vector<char> (w));
    queue<pair<int, int>> q;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> stage[i][j];
            if(stage[i][j] == '#') q.push(pair<int, int> (i, j));
        }
    }

    vector<vector<int>> dist(h, vector<int> (w, 0));
    while(!q.empty()) {
        pair<int, int> yx = q.front(); q.pop();
        int y = yx.first;
        int x = yx.second;
        int dy[] = {1, 0, -1, 0};
        int dx[] = {0, 1, 0, -1};
        for(int i = 0; i < 4; i++) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(0 <= ny && ny < h && 0 <= nx && nx < w && stage[ny][nx] == '.' && dist[ny][nx] == 0) {
                dist[ny][nx] = dist[y][x] + 1;
                q.push(pair<int, int> (ny, nx));
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25524
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	long long int a1, x, y;
	vector<long long int> a;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%lld", &a1);
		a.push_back(a1);
	}
	sort(a.begin(), a.end());
	auto itr=lower_bound(a.begin(), a.end(), (a[n-1]+1)/2);
	x=*itr;
	if(itr!=a.begin()){
		itr--;
		y=*itr;
		if(x+y>=a[n-1]){
			printf("%lld %lld\n", a[n-1], y);
		}else{
			printf("%lld %lld\n", a[n-1], x);
		}
	}else{
		printf("%lld %lld\n", a[n-1], x);
	}
	
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>

using namespace std;

#define MMAX 1000
#define NMAX 1000

int main(){

	int n,m,a;
	int h,p,q;
	int amida[MMAX+2][NMAX+2];

	while(1){
		cin>>n>>m>>a;
		if(n==0&&m==0&&a==0) break;

		for(int i=0;i<=MMAX+1;i++){
			for(int j=0;j<=NMAX+1;j++){
				amida[i][j]=0;
			}
		}

		for(int i=0;i<m;i++){
			cin>>h>>q>>p;
			amida[h][q]=1;
		}

		for(int i=NMAX+1;i>=0;i--){
			if(amida[i][a]==1) a+=1;
			else if(amida[i][a-1]==1) a-=1;
		}

		cout<<a<<endl;
	}

}

Measured memory_bytes: 5080
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int count = scan.nextInt();
		long sum = 1;
		long max = (long) Math.pow(10, 18);

		if (count >= 2) {
			for (int i = 0 ; i < count ; i++) {
				long value = scan.nextLong();
				if (value == 0) {
					sum = 0;
					break;
				}
				if (sum != -1 && sum <= max / value) {
					sum *= value;
				}
				else sum = -1;
			}
		}
			scan.close();
			System.out.println(sum);
	}
}

Measured memory_bytes: 59632