akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int x;cin>>x;
  if(x == 1)
    cout<<0<<endl;
  else
    cout<<1<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main(){
  int V,M,R;
  cin>>V>>M>>R;
  int r[10];
  rep(i,R){
    cin>>r[i];
    r[i]--;
  }
  const int MAX_V=205;
  int d[MAX_V][MAX_V];
  rep(i,V) rep(j,V) {
    d[i][j]=1e9;
    if (i==j) d[i][j]=0;
  }
  rep(i,M){
    int a,b,c;
    cin>>a>>b>>c;
    a--; b--;
    d[a][b]=c;
    d[b][a]=c;
  }

  for (int k=0; k<V; k++) {
    for (int i=0; i<V; i++) {
      for (int j=0; j<V; j++) {
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  sort(r,r+R);
  int ans=1e9;
  do{
    int sum=0;
    bool f=true;
    rep(i,R-1){
      int p1=r[i],p2=r[i+1];
      if(d[p1][p2]==1e9){
	f=false;
	break;
      }
      sum+=d[p1][p2];
    }
    if(f) chmin(ans,sum);
  }while(next_permutation(r,r+R));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3764
from sys import stdin

ans = 0


def dfs(cnt, current, path):
    if cnt == N:
        global ans
        ans += 1
        # print(cnt, current, path)
        return
    for i in range(N):
        # print(path)
        if s[current-1][i] == 1 and i+1 not in path:
            # print(i)
            # global path
            path.append(i+1)
            dfs(cnt+1, i+1, path)
            for i in range(cnt, len(path)):
                path.pop()


N, M = [int(x) for x in stdin.readline().rstrip().split()]
s = [[0 for i in range(N)] for j in range(N)]
cnt = 1
for i in range(M):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    s[a-1][b-1] = 1
    s[b-1][a-1] = 1
path = [1]
dfs(cnt, 1, path)
# print(s)
print(ans)


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


int main(){
   string s,t;
   cin>>s>>t;
   
   int dp[s.size()+1][t.size()+1];
   
   for(int i=0;i<=s.size();i++){
       for(int j=0;j<=t.size();j++){
           
           dp[i][j] = 0;
       }
   }
   
   for(int i=1;i<=s.size();i++){
       for(int j=1;j<=t.size();j++){
           
           if(s[i-1]==t[j-1]){
               dp[i][j] = 1+dp[i-1][j-1];
           }
           
           else
           dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
       }
   }
   char lcs[dp[s.size()][t.size()]+1];
   int cnt = dp[s.size()][t.size()];
   
   int i=s.size(),j=t.size(),x=0;
   
   while(i>0 && j>0){
       if(s[i-1]==t[j-1]){
           lcs[x++] = s[i-1];
           i--;
           j--;
       }
       else if(dp[i-1][j]>dp[i][j-1]){
           i--;
       }
       else 
       j--;
   }
   for(int h=cnt-1;h>=0;h--)
   cout<<lcs[h];
}

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

int main()
{
    ll n;
    cin>>n;
    ll arr[n],i,ans=0,temp,f;
    for(i=0;i<n;i++)
        cin>>arr[i];

    ll mi,ma;
    mi=arr[0];
    ans=1000;

    for(i=1;i<n;i++)
    {
      if(arr[i]>mi)
      {
        ma=arr[i];
        temp=ans/mi;
     //   cout<<"temp: "<<temp<<endl;
        f=ans-temp*mi;
       // cout<<"f:  "<<f<<endl;
        ans=f+ma*temp;
        mi=ma;
      }
      else if(arr[i]<mi)
        mi=arr[i];
      //cout<<"mi:  ma:  ans:  "<<mi<<" "<<ma<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	if(b - a + 1 > k * 2){
		for(int i=a; i<a+k; i++){
			cout << i << endl;
		}
		for(int i=b-k+1; i<=b; i++){
			cout << i << endl;
		}
	} else {
		for(int i=a; i<=b; i++){
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

int main() {
  int h, a;
  cin >> h >> a;

  int ans = h / a + (h % a > 0 ? 1 : 0);

  cout << ans << endl;
}


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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int inf = 2147483647;
const int N = 1e5 + 1;
const int mod = 1e9 + 7;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg 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 ^ 48), ch = getchar();
	return x * f;
}
I void ptt(cr x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(cr x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(cr x) {put(x), putchar(' ');}
I void pr2(cr x) {put(x), puts("");}

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

int a[N], jc[N], inv[N];

I int C(cr n, cr m) {if(n < m) return 0; return (LL)jc[n] * inv[m] % mod * inv[n - m] % mod;}

int main() {
	reg n = read(), k = read();
	jc[0] = 1; fo(i, 1, n) jc[i] = (LL)jc[i - 1] * i % mod;
	inv[n] = pow_mod(jc[n], mod - 2); fd(i, n, 1) inv[i - 1] = (LL)inv[i] * i % mod;
	fo(i, 1, n) a[i] = read();
	sort(a + 1, a + n + 1);
	reg ans = 0;
	fo(i, 1, n) {
		if(a[i] < 0) a[i] += mod;
		ans = (ans + (LL)C(i - 1, k - 1) * a[i]) % mod;
		ans = (ans - (LL)C(n - i, k - 1) * a[i]) % mod;
	} pr2((ans + mod) % mod);
	return 0;
}



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

int main(){
    ll a, b;    cin >> a >> b;
    string ans = "Positive";
    if(a<=0 && 0<=b) ans = "Zero";
    else if(b<0 && (b-a+1)%2==1) ans = "Negative"; 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    int num[] = {2,5,5,4,5,6,3,7,6};
    string ans;
    vector<P> vec;
    rep(i,0,M){
        int a;
        cin >> a;
        vec.emplace_back(a, num[a-1]);
    }
    sort(vec.rbegin(), vec.rend());
    vector<int> dp(N+1, -1);
    dp[0] = 0;
    for(auto p:vec){
        rep(i,0,N){
            if(p.second + i > N)break;
            dp[i + p.second] = max(dp[i + p.second], dp[i] + 1);
        }
    }
    /*
    rep(i,0,N+1)cout << dp[i] << " ";
    cout << endl;
    cout << dp[N] << endl;
    */
    for(int i = N;i > 0;){
        for(auto p:vec){
            if(i >= p.second && dp[i] == dp[i - p.second] + 1){
                ans.push_back('0' + p.first);
                i -= p.second;
                break;
            }
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b; cin >> a >> b;
    if(a == 0 || b == 0 || (a<0 && b>0)) cout << "Zero" << endl;
    else if(a>0 && b>0) cout << "Positive" << endl;
    else if((abs(b-a)+1)%2 == 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, k;
	cin >>n >>k;
	
	ll s = n /k;
	ll ans = s * s * s;
	if(k%2==0){
		ll ss = n /(k/2);
		ss -= s;
		ans += ss * ss *ss;
	}
	cout << ans <<"\n";
	

	
	return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j,k;
  int n;
  cin>>n;
  pair<int,int> a[100];
  for(i=0;i<n;++i)
    cin>>a[i].first>>a[i].second;
  int b[100][100];
  fill(b[0],b[0]+100*100,1<<30);
  for(i=0;i<n;++i)
    b[i][i]=0;
  for(i=1;i<n;++i){
    for(j=0;j<n-i;++j){
      for(k=j;k<i+j;++k){
	b[j][i+j]=min(b[j][i+j],b[j][k]+b[k+1][i+j]+a[j].first*a[k].second*a[k+1].first*a[i+j].second);
      }
    }
  }
  cout<<b[0][n-1]<<endl;
  return 0;
}

Measured memory_bytes: 0
from itertools import accumulate
import sys
input = lambda: sys.stdin.readline().rstrip()


def eratosthenes(n):
    is_prime = [1] * (n + 1)

    is_prime[0] = 0
    is_prime[1] = 0

    ans = [0] * (n+1)

    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = 0

    return is_prime


MAX = 10 ** 5


is_prime = eratosthenes(MAX)

a = [0] * (MAX+1)
for i in range(MAX+1):
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] = 1

s = list(accumulate(a))


Q = int(input())

for i in range(Q):
    l,r = map(int, input().split())
    print(s[r]-s[l-1])

Measured memory_bytes: 53024
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    
    double area = double(W) * double(H) / 2;
    
    bool flag = false; 
    if(x+x==W && y + y == H) flag = true;
    if(flag) printf("%1f %c", area, '1');
    else printf("%1f %c", area, '0');
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

string str;
int n,i,cnt;
int a[26];
int l,r,sum,ans,flag;
int main()
{
	cin>>str;
	n=str.length();
	for(i=0;i<n;i++)
	{
		a[str[i]-'a']++;
	}
	cnt=0;
	for(i=0;i<26;i++)
	{
		if(a[i]%2!=0&&i+'a'!='x')
		{
			cnt++;
		}
	}
	if(cnt>1)
	{
		cout<<-1<<endl;
		return 0;
	}
	flag=0;
	sum=0;
	l=0;
	r=n-1;
	while(l<r)
	{
		if(str[l]!=str[r])
		{
			if(str[l]=='x')
			{
				sum++;
				l++;
			}
			else if(str[r]=='x')
			{
				sum++;
				r--;
			}
			else
			{
				flag=1;
				break;
			}
		}
		else
		{
			l++;
			r--;
		}
	}
	if(flag)
		cout<<-1<<endl;
	else
		cout<<sum<<endl;
}

Measured memory_bytes: 512
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 10000000000000007
#define int long long

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

int N;

struct Edge
{
    int dst, cost;
    Edge(int dst, int cost) : dst(dst), cost(cost) {}
};

vector<Edge> Edges[100000];

int d[100000];
void dijkstra(int start)
{
    fill(d, d + 100000, INF);
    priority_queue<pint, vector<pint>, greater<pint>> q;
    q.push(pint(0, start));
    d[start] = 0;
    while (q.size())
    {
        pint p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        rep(i, Edges[v].size())
        {
            Edge e = Edges[v][i];
            if (d[e.dst] > d[v] + e.cost)
            {
                d[e.dst] = d[v] + e.cost;
                q.push(pint(d[e.dst], e.dst));
            }
        }
    }
}

signed main()
{
    cin >> N;
    rep(i, N - 1)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        Edges[a].push_back(Edge(b, c));
        Edges[b].push_back(Edge(a, c));
    }

    int Q, K;
    cin >> Q >> K;
    dijkstra(K - 1);
    int x[Q], y[Q];
    rep(i, Q)
    {
        cin >> x[i] >> y[i];
    }
    rep(i, Q)
    {
        cout << d[x[i] - 1] + d[y[i] - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 11520
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

const long long mod=1e9+7;

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

    vector<vector<int> > G(n);
    vector<pair<int,int> > vp;

    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;

        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);

        vp.push_back(make_pair(a,b));
    }

    int k=0;
    map<pair<int,int>, int> I;
    vector<int> cs(n,0);

    vector<bool> used(n,false);
    queue<int> q;
    used[0]=true;
    q.push(0);
    while(!q.empty()){
        int v=q.front(); q.pop();
        if(k<G[v].size()) k=G[v].size();

        int cur=1;
        for(int u:G[v]){
            if(used[u]) continue;
            if(cur==cs[v]) cur++;

            cs[u]=I[make_pair(u,v)]=I[make_pair(v,u)]=cur;
            cur++;

            used[u]=true;
            q.push(u);
        }
    }

    cout<<k<<endl;
    for(auto p:vp) cout<<I[p]<<endl;

    return 0;
}

Measured memory_bytes: 19700
#include <stdio.h>

int main(void){
	int N,K;
	scanf("%d",&N);
	char S[N+1];
	scanf("%s",S);
	scanf("%d",&K);

	char e = S[K-1];
	for(int i=0; i<N; i++){
		if(S[i]!=e){ S[i]='*';}
	}

	printf("%s\n",S );
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N;
    cin >> N;
    ll a = N % 10;
    if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) _PR("hon");
    else if(a == 0 || a == 1 || a == 6 || a == 8) _PR("pon");
    else _PR("bon");

    return 0;
}

/*



*/

Measured memory_bytes: 3632
D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for _ in range(D)]

# 初期化
Ans = 0 # 満足度
last = [-1]*26

# 満足度を計算
for d in range(D):
    max_ans = 0
    max_i = 0
    # 開催するコンテストID
    for contest_id in range(26):
        ans = 0
        # 満足度をプラス
        ans += S[d][contest_id]
        # 開催されなかったコンテストの処理
        for i in range(26):
            if i != contest_id:
                ans -= C[i]*(d - last[i])
        # 大きい方をとる
        if ans > max_ans:
            max_ans = ans
            max_i = contest_id
    # 最終開催日を更新
    last[max_i] = d
    # 出力
    print(max_i + 1)
#    Ans += max_ans
#    print(Ans)

Measured memory_bytes: 9388
/*
* Author: Jony Roy
* Date: 16-07-2016
* Contact: jonyroyice@gmail.com
*/
#include <bits/stdc++.h>
#define PI              3.1415926535897932384
#define EulerConstant   0.5772156649015328606
#define CountBit(a)     __builtin_popcount(a)
#define pb(x)          push_back(x)
#define mp(x,y)          make_pair(x,y)
#define ft              first
#define sd              second
#define deb(x) cerr << #x << " = " << x << endl;

using namespace std;
typedef double                   ddd;
typedef long long int            llint;
typedef unsigned long long int   ullint;
typedef long int                 lint;
typedef unsigned int             uint;
typedef unsigned long int        ulint;
typedef pair<int,int>            pint;
typedef pair<lint,lint>          plint;
typedef pair<llint,llint>        pllint;
int main()
{
    int n,a[205];
    cin>>n;
    for(int i=1;i<=2*n;i++)
        cin>>a[i];
    sort(a+1,a+2*n+1);
    int sum=0;
    //for(int i=1;i<=2*n;i++)
      //  cout<<a[i]<<" ";
    for(int i=1;i<=2*n;i+=2)
        sum+=a[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	//入力
	int n, m; cin >> n >> m;

	vector<vector<int>> d(n, vector<int>(m));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> d[i][j];
		}
	}

	//平方数をつくる

	set<int> s;
	for (int i = 0; i < 10000; i++) {
		s.insert(i*i);
	}

	//探索
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int val = 0;
			for (int k = 0; k < m; k++) {
				int diff = abs(d[i][k] - d[j][k]);
				val += diff * diff;
			}

			if (s.count(val))ans++;
		}
	}

	//出力
	cout << ans << endl;
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, M; cin >> N >> M;
    vector<i64> A(N);

    i64 s = 0;
    REP(i, N) {
        cin >> A[i];
        s += A[i];
    }

    i64 cnt = 0;
    REP(i, N) {
        if (4 * M * A[i] >= s) cnt++;
    }
    if (cnt >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int w,sum,i;
	while(1){
		scanf("%d",&w);
		if(w==-1) break;
		sum=3130;
		for(i=11;i<=w;i++){
			if(i<=20) sum-=125;
			else if(i<=30) sum-=140;
			else sum-=160;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 2612
// ABC077B - Around Square

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	ull ans = 1;

	while (1) {
		if (ans * ans > N) {
			cout << (ans - 1) * (ans - 1) << endl;
			return 0;
		}
		++ans;
	}

	return 0;
}


Measured memory_bytes: 256
import re
s=input()
c=''
for i in s:
    if i!='x':
        c+=i
if c!=c[::-1]:
    print(-1)
    exit()
n=len(s)
l,r=0,n-1
ans=0
while(r-l>0):
    if s[l]!=s[r]:
        if s[l]=='x':
            ans+=1
            l+=1
        elif s[r]=='x':
            ans+=1
            r-=1
    else:
        l+=1
        r-=1
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

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

	set<int32_t> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout << s.size() << 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 ll;

int main() {
	
	int a, p;
	cin >> a >> p;
	cout << (a*3 + p) / 2 << endl;
	
	return 0;
}

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

const int nax = 2e5;
vector<int> node[nax];
int ans[nax];
int a[nax];

vector<int> cur;
void dfs(int p, int par) {
  int j = lower_bound(cur.begin(), cur.end(), a[p])-cur.begin();
  int added = (j == (int)cur.size()), cp;
  if (added)
    cur.push_back(a[p]);
  else {
    cp = cur[j];
    cur[j] = a[p];
  }

  ans[p] = cur.size();
  for (int i : node[p]) {
    if (i == par) continue;
    dfs(i, p);
  }
  if (added) cur.pop_back();
  else cur[j] = cp;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  dfs(0, -1);
  for (int i = 0; i < n; i++)
    cout << ans[i] << '\n';
}


Measured memory_bytes: 30592
def kaibun(s):
  for n in range(len(s)//2):
    if s[n] == s[len(s)-n-1]:
      continue
    else:
      return False
  return True

s = input()
#print(s[:(len(s)-1)//2])
#print(s[(len(s)+3)//2-1:])
if kaibun(s) and kaibun(s[:(len(s)-1)//2]) and kaibun(s[(len(s)+3)//2-1:]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std; 
int main(){
	int n;
	cin >> n;
	int f=0,s=0;
	while (n--){
		int a1,a2;
		cin >>a1 >> a2;
		if (a1==a2){
			s++;
			if (s>f) f=s;
		}else{
			s=0;
		}
	}
	if (f>2){
		cout << "Yes";
	}else{
		cout << "No";
	}
} 

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int X, Y;
	int ans = 0;

	cin >> X >> Y;
	if (X == 1 && Y == 1) ans += 400000;
	if (X == 1) ans += 300000;
	else if (X == 2) ans += 200000;
	else if (X == 3) ans += 100000;
	if (Y == 1) ans += 300000;
	else if (Y == 2) ans += 200000;
	else if (Y == 3) ans += 100000;

	cout << ans << endl;

	return 0;
}


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

int main(void) {
    int N, K;
    std::cin >> N >> K;
    vector< int > p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += p[i];
    }
    printf("%d\n", ans);
    return 0;
}


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

ans = 0
for i in range(n):
  if b[i] <= a[i]: ans += b[i]
  else:
    ans += a[i]
    b[i] -= a[i]
    if b[i] >= a[i+1]:
      ans += a[i+1]
      a[i+1] = 0
    else:
      ans += b[i]
      a[i+1] -= b[i]
print(ans)

Measured memory_bytes: 24216
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M) cin >> A.at(i);

    ll workDays = 0;
    rep(i, M) {
        workDays += A.at(i);
    }

    ll ans = (N - workDays >= 0) ? N - workDays : -1;

    cout << ans << endl;

    return 0;
}


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

using namespace std;
const int N = 1e5 + 3;
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int x, k;
	cin >> x >> k;
	for (int i = k - x + 1; i < k + x; ++i)
		cout << i << " ";
	return 0;
}


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

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

fn main() {
    let n: u64 = read().unwrap();
    let mut i = 1;
    //    let mut ans = 1;
    while true {
        if i * i > n {
            break;
        }
        i += 1;
    }
    println!("{}", (i - 1) * (i - 1));

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> vi;

const int base = 12*60*60;
vi memo[60][60][60];

int main(){
  vi tick(3,-1), tmp(3);
  rep(sec,base){
    tick[0]++; if(tick[0]>=60)tick[0]-=60;
    if(sec%60 == 0){
      tick[1]++; if(tick[1]>=60)tick[1]-=60;
    }
    if(sec%720 == 0){
      tick[2]++; if(tick[2]>=60)tick[2]-=60;
    }
    
    rep(i,60){
      rep(j,3){
	tmp[j] = tick[j]+i;
	if(tmp[j]>=60)tmp[j]-=60;
      }
      sort(all(tmp));

      memo[tmp[0]][tmp[1]][tmp[2]].push_back(sec);
    }
  }

  int n;
  vi w(3);
  while(scanf("%d",&n),n){
    vector< pair<int,int> > event;
    rep(i,n){
      scanf("%d%d%d",&w[0],&w[1],&w[2]);
      sort(all(w));
      for(int a : memo[w[0]][w[1]][w[2]]){
	event.push_back( make_pair(a,i) );
	event.push_back( make_pair(a + base,i) );
      }
    }

    sort(all(event));

    int m = event.size()/2;
    int res_s = base, res_inv = base, nonzero = 0;
    vi cnt(n,0);

    int l = 0, r = 0;
    while(l<m){
      while(nonzero!=n){
	int id = event[r].second;
	if(cnt[id]==0)nonzero++;
	cnt[id]++; r++;
      }
      while(nonzero==n){
	int id = event[l].second;
	cnt[id]--;
	if(cnt[id]==0)nonzero--; l++;
      }

      int inv = event[r-1].first - event[l-1].first;
      if(res_inv>inv){
	res_s = event[l-1].first;
	res_inv = inv;
      }
    }
    res_inv += res_s;
    printf("%02d:%02d:%02d %02d:%02d:%02d\n",
	   res_s/3600, res_s/60%60, res_s%60,
	   res_inv/3600, res_inv/60%60, res_inv%60);
  }
}

Measured memory_bytes: 25268
#include<stdio.h>
#define MAX 100
#define INFTY 99999
#define WHITE 0
#define GRAY 1
#define BLACK 2
int i,j,n,M[MAX][MAX];

  int prim(){
    int u,minv,v;
  int d[MAX],p[MAX],color[MAX];
  for(i = 0 ; i < n ; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0 ; i < n ; i++){
      if(minv > d[i] && color[i]!=BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v = 0 ; v < n ; v++){
      if(color[v]!= BLACK && M[u][v] != INFTY){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i = 0 ; i < n ; i++){
    if(p[i] != -1)sum += M[i][p[i]];
  }

  return sum;
}

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

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      int e;
      scanf("%d",&e);
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }
  printf("%d\n",prim());
  return 0;

}



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

int main(){
  int k, x;
  cin >> k >> x;
  cout << (k*500 >= x ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,ans=0;
string a,b;
int32_t main(){
CODE_START;
cin>>a;
n=a.size();
b=a;
reverse(a.begin(),a.end());
for(ll i=0;i<n/2;i++)
if(a[i]!=b[i]){
    ans++;
}
cout<<ans;
}






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

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

	vector <int> vec(3);
	scanf("%d %d %d", &vec[0], &vec[1], &vec[2]);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0] + vec[1]);
	return 0;
}

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

int main() {
	int n;cin>>n;
	vector<int> a(n);
//	vector<int> p(n,1);
	int p=1;
	long long ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i){
			if(p+1==a[i]){
				p++;
			}else{
				ans+=(a[i]-1)/(p+1);
			}
		}else{
			ans+=a[i]-1;
		}
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 640
import sys


def binary_search(arr, key):
    left = 0
    right = len(arr)
    while left < right:
        mid = int((left + right) / 2)
        if arr[mid] == key:
            return mid
        elif key < arr[mid]:
            right = mid
        else:
            left = mid + 1
    return -1


input = sys.stdin.readline
n = int(input())
s_list = list(map(int, input().split()))
q = int(input())
t_list = list(map(int, input().split()))

cnt = 0
for t in t_list:
    if binary_search(s_list, t) >= 0:
        cnt += 1
print(cnt)



Measured memory_bytes: 16180
#include <stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	int e;
	e = a%b;
	int d;
	d = (a-e)/b;
	double f;
	f = 1.0*a/b;
	printf("%d %d %f\n",d,e,f);
	return 0;
}

Measured memory_bytes: 636
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

const int MAX_LIMIT = 102;


ll mat[MAX_LIMIT][MAX_LIMIT];
int nodes, edges;

//-----------------------------<BEGIN> FLOYD WARSHALL SNIPPET --------------------------
/*
	ll mat[NODES_LIMIT][NODES_LIMIT];
	ll dir[NODES_LIMIT][NODES_LIMIT];
	dir[][] is used to trace the path back
*/

void floyd_warshall()
{
	int i, j, k;
	fl(i,0,nodes)
	{
		fl(j,0,nodes)
		{
			fl(k,0,nodes)
			{
				if( mat[j][i] + mat[i][k] < mat[j][k] )
				{
					mat[j][k] = min(mat[j][i]+mat[i][k], mat[j][k]);
					// dir[j][k] = dir[j][i];
				}
			}
		}
	}
}

// std::vector<int> floyd_warshall_sol_path;

// void floyd_warshall_path(int src, int dest)
// {
// 	int i, u = dest, v = src;

// 	floyd_warshall_sol_path.PB(u);

// 	while(u!=v)
// 	{
// 		floyd_warshall_sol_path.PB(dir[u][v]);
// 		u = dir[u][v];
// 	}

// 	int limit = floyd_warshall_sol_path.SZ();

// 	//number of nodes visited
// 	//cout<<limit-2<<" ";

// 	fl(i,1,limit-1)
// 	{
// 		//0 based indexing here
// 		cout<<floyd_warshall_sol_path[i]+1<<" ";
// 	}
// 	nline; 
// }

//-----------------------------<END> FLOYD WARSHALL SNIPPET --------------------------

std::vector<pair<int, int> > edge;
std::vector<ll> cost;

int main()
{
	int i, j;

	si(nodes);	si(edges);

	fl(i,0,nodes)
		fl(j,0,nodes)
			if(i != j)
			mat[i][j] = 1000006;

	fl(i,0,edges)
	{
		int x, y; ll wt;
		si(x);	si(y);	sll(wt);
		x--;	y--;
		mat[x][y] = mat[y][x] = wt;

		edge.PB(MP(x, y));
		cost.PB(wt);
	}

	floyd_warshall();

	// fl(i,0,nodes)
	// {

	// 	fl(j,0,nodes)
	// 		cout << mat[i][j] << " ";
	// 	nline;
	// }


	int s = 0;

	fl(i,0,edges)
	{
		int x = edge[i].first;
		int y = edge[i].second;
		bool is = 0;
		fl(j,0,nodes)
		{
			int k;
			fl(k,0,nodes)
			{
				int thisMinDist = mat[j][k];
				if(mat[j][x] + mat[k][y] + cost[i] == thisMinDist || mat[j][y] + mat[k][x] + cost[i] == thisMinDist)
					is = 1;
			}
		}

		if(is)
			s++;

	}

	// cout << s << "\n";

	// is /= 2;

	printf("%d\n", edges - s);




	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

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

	int ans = 1;
	if( A == 1 ) {
		if( B == 2 ) ans = 3;
		else if( B == 3 ) ans = 2;
	}
	else if( A == 2 ) {
		if( B == 1 ) ans = 3;
		else if( B == 3 ) ans = 1;
	}
	else if( A == 3 ) {
		if( B == 1 ) ans = 2;
		else if( B == 2 ) ans = 1;
	}

	cout << ans << endl;
}


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

int tmp[200005] = {};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, m;
    cin >> n >> m;;
    int a, b;
    UnionFind uf = UnionFind(n);
    for (int i = 0;i < m;i++) {
        cin >> a >> b; a--; b--;
        uf.unite(a, b);
    }

    int ans = 0;
    for (int i = 0;i < n;i++) {
        int r = uf.root(i);
        tmp[r]++;
        ans = max(ans, tmp[r]);
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 10256
from collections import deque
n = int(input())
A = sorted(int(input())for _ in range(n))
L = 1
R = n-1
B = deque([A[0]])
prev_L = A[0]
prev_R = A[0]
while L <= R:
    x, y = A[L], A[R]
    if abs(min(prev_L, prev_R)-y) < abs(max(prev_L, prev_R)-x):
        if prev_L < prev_R:
            B.append(x)
            prev_R = x
        else:
            B.appendleft(x)
            prev_L = x
        L += 1
    else:
        if prev_L < prev_R:
            B.appendleft(y)
            prev_L = y
        else:
            B.append(y)
            prev_R = y
        R -= 1

B = list(B)
ans = 0
for x, y in zip(B, B[1:]):
    ans += abs(x-y)
print(ans)

Measured memory_bytes: 8888
def binary_search(v, arr, s, e):
  if s > e: return False
  m = (e - s) // 2 + s
  if arr[m] == v: return True
  elif arr[m] < v:
    return binary_search(v, arr, m + 1, e)
  else:
    return binary_search(v, arr, s, m - 1)

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

C = 0
for t in T:
  if binary_search(t, S, 0, len(S) - 1):
    C += 1
print(C)

Measured memory_bytes: 18776
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    bool flag;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int k1=ceil(1.0*c/b);
    int k2=ceil(1.0*a/d);

    if(k1<=k2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    int ans = 0;
    REP(a,N){
        LL B;cin >> B;
        while(B%2==0){
            B/=2;
            ans++;
        }
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll mod(ll val, ll m){
    ll res = val % m;
    if(res < 0) res += m;
    return res;
}

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

    ll A[N];
    ll sum = 0;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
        sum %= MOD;
    }

    ll ans = 0;

    for(ll i = 0; i < N; i++){
        sum -= A[i];
        sum = mod(sum,MOD);
        ans += A[i] * sum;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5192
N, MOD = int(input()), 10**9+7
memo = [{} for i in range(N+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('ACG') >= 1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur+1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))


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

int main(void)
{
    int N;
    static int a[2000000];
    static int b[2000000];

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    copy(a, a+N,b);
    sort(b,b+N,std::greater<int>());
    int max1 = b[0];
    int max2 = b[1];

    for(int i=0; i<N; i++){
        if(a[i] != b[0]){
            cout << b[0] << endl;
        }else{
            cout << b[1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6528
#include <array>
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int X;
    cin >> X;
    for (int i = 1; i <= X; ++i)
    {
        if ((i * (i + 1) / 2) >= X)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + 5;
int n, m;
int dp[maxn];
int main() {
	scanf("%d%d", &m, &n);
	memset(dp, 0x3f3f, sizeof(dp));
	dp[0] = 0;
	for(int i = 1; i <= n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		for(int j = a; j < maxn; ++j) {
			dp[j] = min(dp[j], dp[j - a] + b);
		}
	}
	int ans = 0x3f3f3f3f;
	for(int i = m; i < maxn; ++i) {
		ans = min(ans, dp[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N, K;

	cin >> N >> K;

	if(N % K == 0 ){
		cout << 0 << endl;
	} else {
		cout << 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s,t;
	cin>>s>>t; 
	int cnt = 0;
	for(int i=0;i<3;i++){
		if(s[i]==t[i])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


ll factorial(ll n) {
    ll ans = 1;
    for(ll i = 1; i <= n; i++){
        ans *= i;
    }
    return ans;
}

int main() {
    int n, p; cin >> n >> p;
    int od = 0, ev = 0;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        if(a & 1) od++;
        else ev++;
    }

    if(od == 0){
        ll ans = pow(2, n);
        if(p == 0) cout << ans<< endl;
        else cout << 0 << endl;
    }else{
        ll ans = pow(2, n - 1);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4100
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#define INT long long int
#define MOD 1000000007
using namespace std;
 
INT h, w, n, all, sum, ans[10];
int dx[9] = {-2,-2,-2,-1,-1,-1,0,0,0}, dy[9] = {-2,-1,0,-2,-1,0,-2,-1,0};
map<INT, map<INT, INT> > d;
 
int main()
{
    cin>>h>>w>>n;
    all = (h-2)*(w-2);
    while( n-- )
    {
        int x, y;
        scanf("%d%d", &x, &y);
        for(int i = 0 ; i < 9 ; i++ )
            if( x+dx[i] > 0 && y+dy[i] > 0 && x+dx[i]+2 <= h && y+dy[i]+2 <= w )
                d[x+dx[i]][y+dy[i]]++;
    }
    for(map<INT, map<INT, INT> >::iterator it = d.begin() ; it != d.end() ; it++ )
    {
       for(map<INT, INT>::iterator jt = d[it->first].begin() ; jt != d[it->first].end(); jt++ )
            ans[jt->second]++, sum++;
 
    }
    cout<<(all-sum)<<endl;
    for(int i = 1 ; i < 10 ; i++ )
        cout<<ans[i]<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 1000


using namespace std;

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


 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

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


int main() {

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

long long int a,b,c,k,res;

cin>>a>>b>>c>>k;


if(k<=a){
res=k;
//cout<<"1="<<endl;
}else if(k<a+b){
res=a;
//cout<<"2="<<endl;

}else if(k<a+b+c){
res=a-(k-a-b);
//cout<<"3="<<endl;

}else{
res=a-c;
//cout<<"4="<<endl;
}


cout<<res<<endl;

}

//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    string S;
    cin >> S;
    bool ans = true;
    int lower = 0;
    int C = 0;
    for(int i = 0; i < S.size(); i++) {
        if(i == 0) {
            if(S[i] != 'A') {
                ans = false;
                break;
            }
        } else {
            if(islower(S[i])) lower++;
            if(1 < i && i < S.size() - 1 && S[i] == 'C') {
                C++;
            }
        }
    }
    if(ans && (C != 1 || lower != S.size() - 2)) ans = false;
    cout << (ans ? "AC" : "WA") << endl;
    return 0;
}

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

int main() {
  int K, N;
  cin >> K >> N;
  
  vector<int> vec1(N);
  for(int i = 0; i < N; i++) {
    cin >> vec1.at(i);
  }
  
  vector<int> vec2(N);
  vec2.at(0) = (K - vec1.at(N -1)) + vec1.at(0);
  for(int i = 1; i < N; i++) {
    vec2.at(i) = vec1.at(i) - vec1.at(i - 1);
  }
  
  int maximum = vec2.at(0);
  for(int i = 0; i < N; i++) {
    if(vec2.at(i) > maximum) {
      maximum = vec2.at(i);
    }
  }
  
  cout << K - maximum << endl;
  
}

Measured memory_bytes: 1792