akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <math.h>
#include <deque>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  ll n;
  cin >>n;
  vl a(n);
  rep(i,n) {
cin >>a.at(i);
  }
 deque<ll> data;
  rep(i,n) {
    ll nn=n%2;
    ll mm=(i+1)%2;
    if(nn==mm) {
      data.push_front(a.at(i));
    }
     if(nn!=mm) {
      data.push_back(a.at(i));
    }
  }
  
  
  rep(i,n) {
    cout<<data.at(i)<<" ";
  }
  cout<<endl;
}
  
 

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  string s;
  cin >> s;
  if(s[0] == '7' || s[1] ==  '7' || s[2] == '7')cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main()
{
  int a,b;
  cin>>a>>b;
  if((a<1 || a>9)||(b<1 || b>9))
  {
    cout<<-1;
  }
  else{
    cout<<a*b;
  }
  return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,m;
int head[N],ver[N],nxt[N],tot;
void add(int a,int b)
{
	tot++;nxt[tot]=head[a];head[a]=tot;ver[tot]=b;return ;
}
int v[N],flag,tt1,tt2;
void dfs(int x,int c)
{
	if(c)tt1++;
	else tt2++;
	v[x]=c;
	for(int i=head[x];i;i=nxt[i])
	{
		if(v[ver[i]]==-1)dfs(ver[i],c^1);
		else if(v[ver[i]]!=(c^1))
		{
			flag=1;
		}
	}
}
int main()
{
	cin>>n>>m;
	int t1,t2;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&t1,&t2);
		add(t1,t2);add(t2,t1);
	}
	memset(v,-1,sizeof(v));
	dfs(1,1);long long  ans;
	if(flag)
	{
		ans=1LL*n*(n-1)/2-m;
	}
	else
	{
		ans=1LL*tt1*tt2-m;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	string S;
	cin >> S;
	int cnt = 15 - S.size();
	rep(i, S.size())if (S[i] == 'o')cnt++;
	if (cnt >= 8)cout << "YES";
	else cout << "NO";
}

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

int main(){
  int N;
  string s,x,y;
  int kind = 0;

  cin >> N;
  cin >> s;

  for(int i=1;i<s.size();++i){
    x = s.substr(0,i);
    y = s.substr(i);

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    for(int k=0;k<x.size()-1;++k){
	if(x[k] == x[k+1]){
	  x.erase(k+1,1);
	  --k;
	}
    }
    
    for(int k=0;k<y.size()-1;++k){
	if(y[k] == y[k+1]){
	  y.erase(k+1,1);
	  --k;
	}
    }
    
    int counter = 0;
    for(int k=0;k<x.size();++k){
      for(int xi=0;xi<y.size();++xi){
	if(x[k] == y[xi]){
	  ++counter;
	}
      }
      kind = max(kind, counter);
    }
  }

  cout << kind << endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 505;
int a[MX][MX];
int ans[MX][MX];

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n,m,Q; cin >> n >> m >> Q;
    FOR(i,1,m) {
        int l,r; cin >> l >> r;
        a[l][r]++;
    }
    FOR(i,1,n) {
        FOR(j,2,n) {
            a[i][j] += a[i][j-1];
        }
    }
    FOR(i,1,n) {
        for(int j=n-1; j>=1; j--) {
            a[j][i] += a[j+1][i];
        }
    }
    while(Q--) {
        int p,q; cin >> p >> q;
        cout << a[p][q] << endl;
    }
    return 0;
}


Measured memory_bytes: 4616
x,X,y,Y;main(a,b,c){for(;~scanf("%d%d%d",&a,&b,&c);)X?c-1||(x=x<a?a:x),c-2||(X=X<a?X:a),c-3||(y=y<b?b:y),c-4||(Y=Y<b?Y:b):(X=a,Y=b);printf("%.f",fdim(X,x)*fdim(Y,y));}

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


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

    ll n; cin >> n;

    if(n == 2){
        cout << 1 << endl;
        return 0;
    }
    map<ll, int> memo;
    memo[n]++; memo[n-1]++;
    for(ll i = 2LL; i*i <= n; ++i){
        if(n%i == 0){
            ll tmp = n/i;
            while(tmp%i == 0) tmp /= i;
            if(tmp%i == 1) memo[i]++;
        }
        if((n-1)%i == 0){
            memo[i]++;
            memo[(n-1)/i]++;
        }
    }
    ll ans = 0LL;
    for(auto i:memo) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint n, k;

int main(void)
{
	cin >> n >> k;
	llint x = n / k;	
	llint ans = x*x*x;
	
	if(k % 2 == 0){
		llint y = (n+k/2) / k;
		ans += y*y*y;
	}
	cout << ans << endl;
}

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

using namespace std;
using p=pair<int,int>;
typedef long long ll;
const ll mod = 1000000007;

ll modul(ll x, ll y){
  ll k = 1;
  rep(i,y){
    k = k*x%mod;
  }
  return k;
}

int main(){
  ll n, a;
  cin >> n;
  a = modul(9, n);
  ll ans = (modul(10, n) - a - a + modul(8, n)) % mod;
  cout << (ans + mod) % mod << endl;
}



Measured memory_bytes: 3624
//AtCoder B - Shift only
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    vector<ll> atbl(N);
    for(auto&& a:atbl){
        cin>>a;
    }
    ll ans=0;
    bool okflag=true;
    while(okflag){
        for(auto&& a:atbl){
            if(a%2==0) a/=2;
            else {
                okflag=false;
                break;
            }
        }
        if(okflag)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d,e,f;cin >> a >> b >> c >> d >> e >> f;
	vector<int> x;
	vector<int> y;
	for(int i=0;i*100*a<=f;++i){
		for(int j=0;j*100*b+i*100*a<=f;++j){
			x.pb(i*100*a+j*100*b);
		}
	}
	for(int i=0;i*c<=f;++i){
		for(int j=0;j*d+i*c<=f;++j){
			y.pb(i*c+j*d);
		}
	}
	int ansx=0,ansy=0;
	double m=0;
	rep(i,x.size()){
		rep(j,y.size()){
			if(x.at(i)+y.at(j)<=f){
				if((100*(double)y.at(j))/((double)x.at(i)+(double)y.at(j))>m && x.at(i)/100*e>=y.at(j) && x.at(i)+y.at(j)<=f){
					m=(100*(double)y.at(j))/((double)x.at(i)+(double)y.at(j));
					ansx=x.at(i)+y.at(j);
					ansy=y.at(j);
				}
			}
		}
	}
	if(ansx==0) cout << a*100 << " " << 0 << endl;
	else cout << ansx << " " << ansy << endl;
}

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

int main(){
    int N, X;
    std::cin >> N >> X;
    std::vector<int> L(N);
    for(auto i = 0; i < N; i++){
        std::cin >> L.at(i);
    }

    int D = 0, ans = 1;
    for(auto i = 0; i < N; i++){
        D += L.at(i);
        if(D <= X){
            ans++;
        }else{
            break;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n,sum=0;
	cin >> n;
	vector<ll>d(n);
	rep(i, n)cin >> d[i];
	for (ll i = 0; i < n; i++) {
		for (ll k = i+1; k < n; k++) {
			sum += d[i] * d[k];
		}
	}
	cout << sum << endl;
}



Measured memory_bytes: 256
d[999],c[999],f,l,t,T;main(i,w){for(;~scanf("%as",&w);t>T?T=t,l=i:0){for(i=-1;d[++i]&&strcmp(d[i],w););t=strlen(d[i]=w);++c[i]>c[f]?f=i:0;}exit(!printf("%s %s\n",d[f],d[l]));}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pf push_front
#define pii pair <int ,int>
#define all(s) s.begin (), s.end ()
#define int long long

using namespace std;

const int N = 1e5 + 5, mod = 1e9 + 7;

int n, a, b, dp[2][N], l = 1, ar[N], L[N];

main()
{
    cin >> n >> a >> b;

    if (a > b) swap(a, b);

    dp[0][1] = dp[1][1] = 1;

    for (int i = 1; i <= n; i++)
        scanf("%lld", &ar[i]);

    L[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        if ( ar[i] - ar[i - 1] >= a )
            L[i] = L[i - 1];
        else
            L[i] = i;
    }
    ar[0] = -1e18;

    for (int i = 2; i <= n; i++)
    {
        if (ar[i] - ar[i - 1] >= a)
            dp[0][i] = (dp[0][i - 1] + dp[1][i - 1]) % mod;

        else if (ar[i] - ar[i - 2] >= a)
            dp[0][i] = dp[1][i - 1];

        else if (i > 2)
        {
            puts("0");
            return 0;
        }

        while (ar[i] - ar[l] >= b) l++;

        if (l == i)
            dp[1][i] = (dp[0][i - 1] + dp[1][i - 1]) % mod;

        else if ( L[i - 1] <= l)
            dp[1][i] = dp[0][l];
    }
    cout << ( dp[1][n] + dp[0][n] ) % mod;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,k;
    cin >> n >> k;
    int ans=1;
    rep(i,n){
        if(ans<k)ans*=2;
        else ans+=k;
    }
    
    cout << ans;
    
	return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
#include<math.h>
int main()
{
    int num,i,j;
    scanf("%d",&num);
    long long s[num],sum=0,min,d[num-1],t;
    for(i=0,j=0;i<num;i++,j++)
        {
            scanf("%lld",&s[i]);
            sum=sum+s[i];
            if(j<num-1)
                d[j]=sum;
        }
    min=fabs(sum-2*d[0]);
    for(i=1;i<num-1;i++)
    {
        t=fabs(sum-2*d[i]);
        if(min>t)
            min=t;
    }
        printf("%lld",min);
}

Measured memory_bytes: 3328
n,m = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
sum_x = 0
sum_y = 0
for i in range(n):
    sum_x += x[i]*i
    sum_x -= x[i]*(n-1-i)
for i in range(m):
    sum_y += y[i]*i
    sum_y -= y[i]*(m-1-i)
mod = 10**9+7
print((sum_x%mod)*(sum_y%mod)%mod)


Measured memory_bytes: 18576
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }
};

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    const int maxN = MAX*2;
    int n;
    cin >> n;
    int a[maxN];
    int b[maxN];
    rep(i, n){
        cin >> a[i];
        b[i] = a[i];
    }

    sort(a, a+n);

    rep(i, n){
        if(b[i] <= a[n/2-1]){
            cout << a[n/2];
        }
        else{
            cout << a[n/2-1];
        }
        cout << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
int juli(int a, int b)
{
    return a>b?a-b:b-a;
}
int main(void)
{
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    if(juli(x,a)>juli(x,b))printf("B\n");
    else printf("A\n");
        return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
p = [int(i) for i in input().split()]

class Unionfind:
    def __init__(self, num):
        self.par = [i for i in range(num+1)]
        self.rank = [0] * (num+1)

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, u, v):
        ru = self.root(u)
        rv = self.root(v)
        if self.rank[ru] < self.rank[rv]:
            self.par[ru] = rv
        else:
            self.par[rv] = ru
            if self.rank[ru] == self.rank[rv]:
                self.rank[ru] += 1

    def same(self, u, v):
        return self.root(u) == self.root(v)

uni = Unionfind(N)
for i in range(M):
    x, y = map(int, input().split())
    uni.unite(x, y)

count = 0
for i in range(1, N+1):
    if uni.same(i, p[i-1]):
        count += 1

print(count)


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<tuple<int,int,int>> ans;
  for (int i = 0; i < n/2; i++) {
    ans.emplace_back(k+n/2-1-i, k+n+i*2+1, k+n*2+i);
  }
  for (int i = 0; i < (n+1)/2; i++) {
    ans.emplace_back(k+n-1-i, k+n+i*2, k+n*2+n/2+i);
  }
  for (auto t : ans) {
    int a, b, c;
    tie(a,b,c) = t;
    if (a+b > c) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (auto t : ans) {
    int a, b, c;
    tie(a,b,c) = t;
    cout << a << ' ' << b << ' ' << c << '\n';
  }
}


Measured memory_bytes: 3572
def k(n, a, p):
    x = 0
    c = 0
    for i in range(n):
        s = x + a[i]
        if p and s > 0 or not p and s < 0: x = s
        else:
            c += abs(s) + 1
            if p: x = 1
            else: x = -1
        p = not p
    return c

n = int(input())
a = [int(x) for x in input().split()]
print(min(k(n, a, True), k(n, a, False)))


Measured memory_bytes: 14332
# -*- coding: utf-8 -*-
import sys
import re
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    YESNO(re.match(r'^(dream(er)?|eraser?)+$',input()))

if __name__ == '__main__':
    main()


Measured memory_bytes: 44124
function Main(input) {
    input = input.split("\n");
    var people_num = Number(input[0]);
    var scores = input[1].split(' ');
    var ary = [];
    var pro = 0;
    var any = 0;
    for(var i = 0; i < scores.length; i++){
        scores[i] = Number(scores[i]);
        pro = Math.floor(scores[i] / 400);
        if(pro >= 8){
            any++;
        }else{
            ary.push(pro);
        }
    }
    var united = ary.filter(function(a,b,c){
        return c.indexOf(a) === b;
    });
    //console.log(united);
    if(united.length){
        console.log(united.length + ' ' + (united.length + any));
    } else {
        console.log(1 + ' ' + any);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 112 A "Programming Education"
 *   https://abc112.contest.atcoder.jp/tasks/abc112_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Task task = new Task();
		task.run(in, out);

		in.close();
		out.close();
	}

	static class Task {

		public void run(InputScanner in, PrintWriter out) {

			int N = in.nextInt();

			if (N == 1) {
				out.println("Hello World");
			} else {
				int A = in.nextInt();
				int B = in.nextInt();
				out.println(A + B);
			}
		}
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public boolean hasNext() {
			return scanner.hasNext();
		}

		public int nextInt() {
			return Integer.parseInt(scanner.next());
		}

		public long nextLong() {
			return Long.parseLong(scanner.next());
		}

		public double nextDouble() {
			return Double.parseDouble(scanner.next());
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 22740
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    while (true) {
        auto ab = readints;
        int a = ab[0], b = ab[1];
        if (a == 0 && b == 0)
            break;

        if (a % 2 == 1 && b % 2 == 1) {
            writeln("no");
        }
        else {
            writeln("yes");
        }
    }
}

Measured memory_bytes: 2420
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int ans=0;
		int b=0;
		int trueans=0;
		boolean flag=false;
		for(int baisu=M/N;baisu>0;baisu--){
		    b=M;
		    if(M%baisu==0&&M/baisu>=N){
		        ans=baisu;
		        break;
		    }
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : August 27, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof(arr))
#define finally(value) {cout << value << '\n'; return;}
#define ll    int64_t

const int oo = int(1e9);
const ll lloo  = (ll)(1e18);

template <typename T>
struct edge {
    int from;
    int to;
    T cost;
};

template <typename T>
struct link {
    int to;
    T cost;
    bool operator>(const link& other) const {return cost > other.cost;}
    bool operator<(const link& other) const {return cost < other.cost;}
};

template <typename T>
class graph {
public:
    vector<edge<T>> edges;
    vector<vector<link<T>>> adj;
    int n;
    graph(int sz) : n(sz) {
        adj.resize(n);
    }
    virtual void add(int from, int to, T cost) = 0;
};

template <typename T>
class digraph : public graph<T> {
public:
    using graph<T>::edges;
    using graph<T>::adj;
    using graph<T>::n;

    digraph(int sz) : graph<T>(sz) {}

    void add(int from, int to, T cost = 1) {
        assert(0 <= from && from < n && 0 <= to && to < n);
        edges.push_back({from, to, cost});
        adj[from].push_back({to, cost});
    }
    
    digraph<T> reverse() const {
        digraph<T> rev(n);
        for (auto &e : edges) {
            rev.add(e.to, e.from, e.cost);
        }
        return rev;
    }
};

class Task {
public:
    int n, m;
    
    vector<bool> visited;
    vector<int> max_depth;

    void dfs(const digraph<int> &g, int node) {
        visited[node] = true;
        for(link<int> neighbor: g.adj[node]) {
            max_depth[node] = max(max_depth[node], 1 + max_depth[neighbor.to]);
            if(visited[neighbor.to]) continue;
            dfs(g, neighbor.to);
            max_depth[node] = max(max_depth[node], 1 + max_depth[neighbor.to]);
        }
    }

    void solveOne(istream &in, ostream &out) {
        in >> n >> m;
        digraph<int> g(n);
        visited.resize(n, false);
        max_depth.resize(n, 0);
        int x, y;
        for(int i = 0; i < m; ++i){
            in >> x >> y, x--, y--;
            g.add(x, y);
        }

        for(int node = 0; node < n; ++node){
            if(!visited[node]) {
                dfs(g, node);
            }
        }
        out << *max_element(max_depth.begin(), max_depth.end()) << endl;
    }
    
    void solve(istream &in, ostream &out) {
        int t=1;
        while(t--) solveOne(in, out);
    }
};

auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 13656
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;
	vector<int> size;

	UnionFind(int N) :parent(N, 0), rank(N, 0), size(N, 1)
	{
		rep(i, 0, N)
		{
			parent[i] = i;
		}
	}

	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y)
		{
			return;
		}

		if (rank[x] < rank[y])
		{
			parent[x] = y;
			size[y] += size[x];
		}
		else
		{
			parent[y] = x;
			size[x] += size[y];
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

pair<int, int> P[100010];
int ans[100010];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M;
	cin >> N >> M;

	UnionFind uf(N);

	rep(i, 0, M)
	{
		cin >> P[i].first >> P[i].second;
		P[i].first--;
		P[i].second--;
	}

	rrep(i, 0, M)
	{
		if (!uf.same(P[i].first, P[i].second))
		{
			ans[i] = uf.size[uf.parent[P[i].first]] * uf.size[uf.parent[P[i].second]];
		}
		uf.unite(P[i].first, P[i].second);
	}

	rep(i, 0, M)
	{
		if (0 < i)ans[i] += ans[i - 1];
		cout << ans[i] << endl;
	}

	return 0;
}



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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int diff=0;
    diff = (a-b) ;
    if (c-diff >0 ) {
         cout << c- diff << endl;
    }else{
        cout << 0 << endl;
    }
   
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};

typedef struct node *Node;
void insert(int);
void inorder(Node);
void preorder(Node);

Node root;
int main(){
  int n,i,x;
  char c[20];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(c[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(c[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
void insert(int k){
  Node y=NULL;
  Node x=root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NULL;
  z->right=NULL;
  while(x!=NULL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NULL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}
void inorder(Node x){
  if(x!=NULL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}
void preorder(Node x){
  if(x!=NULL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}

Measured memory_bytes: 24040
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>
#define rep(i, n) for (int i=0; i<n; ++i)
using namespace std;
typedef long long ll;

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

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#define MAX 100000
int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}
int main()  {
  int i,q;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  q=partition(0,n-1);

  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
    printf("\n");
  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int find(int x,si s){
	int i=0;
	for(auto it=s.begin();it!=s.end();it++){
		if(*it==x){return i;}
		i++;
	}
	return(i);
}

int32_t main(){
	IOS;
	int n;
	cin>>n;
	int a[n],b[n];
	int fact[n];
	fact[0]=1;
	for(int i=1;i<n;i++){
		fact[i]=i*fact[i-1];
	}
	si s;
	for(int i=1;i<=n;i++) s.insert(i);
	int A=0,B=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		int x=find(a[i],s);
		A+=fact[n-i-1]*(x);
		s.erase(s.find(a[i]));
	}
	for(int i=1;i<=n;i++) s.insert(i);
	for(int i=0;i<n;i++){
		cin>>b[i];
		int x=find(b[i],s);
		B+=fact[n-i-1]*(x);
		s.erase(s.find(b[i]));
	}
	cout<<abs(A-B);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int color[10010];
int N;

int solve(int x, int cc){
  if(color[x] == cc) return N;
  int cnt = 1;
  int back, forward;
  
  for(back = x-1 ; back >= 0 ; back--){
    if(cc == color[back]) cnt++;
    else break;
  }
  for(forward = x+1 ; forward < N ; forward++){
    if(cc == color[forward]) cnt++;
    else break;
  }
  
  int res = N-cnt;
  
  if(cnt < 4) return N;
  else if(back < 0 || N <= forward) return res; // ツ端ツづーツ湘?つオツつスツ湘ェツ債?
  else if(color[back] != color[forward]) return res; // ツつュツづ?づつつ「ツづ?づ?ツ古つ暗按湘」ツづ可づ按づァツづ按つゥツづ?つスツ湘ェツ債?
  
    while(1){
      int tmp = 0;
      cc = color[back];
      for( ; back >= 0 ; back--){
	if(cc == color[back]) tmp++;
	else break;
      }
      for( ; forward < N ; forward++){
	if(cc == color[forward]) tmp++;
	else break;
      }
      if(tmp < 4) return res;
      else if(back < 0 || N <= forward) return res-tmp;
      else if(color[back] != color[forward]) return res-tmp;
    
      res -= tmp;
    }
    return res;
}


int main(){
  while(cin >> N, N){
    for(int i = 0 ; i < N ; i++) cin >> color[i];
    int ans = 10010;
    for(int i = 0 ; i < N ; i++){
      for(int c  = 1 ; c <= 3 ; c++){
	ans = min(ans, solve(i, c));   
      }
    }
    cout << ans << endl;
  }
  return 0;
}


    

Measured memory_bytes: 1200
object Main {

    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n = sc.nextInt
        while(sc.hasNext){
            val x1,y1,x2,y2,x3,y3,x4,y4 = sc.nextDouble
            if(Math.abs((x1-x2)*(y3-y4) - (x3-x4)*(y1-y2)) < 1e-10) println("YES") else println("NO")
        }
    }
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;




void one_case() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    vector<int> cnt(x + 1);
    cnt[0] = 1;
    for (int i = x; i > 0; --i) {
        for (int k = 1; k <= a; ++k) {
            if (k * 500 <= i) {
                cnt[i] += cnt[i - k * 500];
            }
        }
    }
    for (int i = x; i > 0; --i) {
        for (int k = 1; k <= b; ++k) {
            if (k * 100 <= i) {
                cnt[i] += cnt[i - k * 100];
            }
        }
    }
    for (int i = x; i > 0; --i) {
        for (int k = 1; k <= c; ++k) {
            if (k * 50 <= i) {
                cnt[i] += cnt[i - k * 50];
            }
        }
    }


    cout << cnt[x] << "\n";
}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 384
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a1,a2,a3 = inpm()

if a1 + a2 + a3 >= 22:
    ans = 'bust'
else:
    ans = 'win'
print(ans)

Measured memory_bytes: 31012
n = int(input())
vote_t = 1
vote_a = 1
    
for _ in range(n):
    t,a = list(map(int, input().split()))
    n = max((vote_t + t - 1) // t, (vote_a + a -1) // a)
    vote_t = n * t
    vote_a = n * a

print(vote_t + vote_a)

Measured memory_bytes: 9124
import math

n = int(input())
x, y = [0] * n, [0] * n
for i in range(n):
  x[i], y[i] = map(int, input().split())
s = 0
for i in range(n):
  for j in range(n):
    s += math.sqrt((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2)
print(s / n)

Measured memory_bytes: 3064
import sys
import collections
from collections import Counter
# from collections import deque
# from collections import defaultdict
import itertools
# from itertools import accumulate
# from itertools import permutations
# from itertools import combinations
# from itertools import takewhile
from itertools import compress
# import functools
# from functools import reduce
import math
# from math import gcd
# from math import inf
# from math import ceil
# from math import floor
# from math import log10
# from math import log2
# from math import log
from math import factorial

# import re

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

S = set()
for i in range(N):
    for j in range(i, N):
        b = A[i:j + 1]
        S.add(sum(b))

S = list(S)

ans = 0
for i in range(40, -1, -1):
    A = [s & (1 << i) for s in S]
    newS = list(compress(S, A))
    if len(newS) >= K:
        ans += (1 << i)
        S = newS

print(ans)


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

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

    int a = n / 100;
    int b = n % 100 / 10;
    int c = n % 10;

    if (a > b || (a == b && b >= c)) {
        cout << a * 111 << endl;
    } 
    else cout << (a+1) * 111 << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b,c,d;
  cin >> a >> b >> c >> d;
  if((a+b) < (c+d)) cout << "Right" <<endl;
  else if((a+b) > (c+d))cout << "Left"<<endl;
  else cout << "Balanced"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,flg[1000]={0};
	string s;
	char e[27]={"abcdefghijklmnopqrstuvwxyz"};
	cin>>s;
	for(i=0;i<s.size();i++) flg[s[i]-'a']=1;
	for(i=0;i<26;i++) {
		if(flg[i]==0) {
			cout<<e[i]<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
}

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

int main(){
  string op;
  int a, b;
  
  while(1){
    cin >> a >> op >> b;
    if(op == "?"){
      break;
    }
    if(op == "+"){
      cout << a + b << endl;
    }else if(op == "-"){
      cout << a - b << endl;
    }else if (op == "*"){
      cout << a * b << endl;
    }else{
      cout << a / b << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3168
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    j = min(i, k)

    dp[i] = min([dp[i-ji] + abs(h[i] - h[i-ji]) for ji in range(1,j+1)])

print(dp[-1])

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

int main(){
  string s,ans;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(ans == "" && s.at(i) == 'B') continue;
    if(s.at(i) == '0'){
      ans += '0';
    }
    else if(s.at(i) == '1'){
      ans += '1';
    }
    else{
      ans.pop_back();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999
#define eps 1e-9

int main(){
    int w,h;
    while(cin>>w>>h&&w&&h){
        int data[40][40]={};
        rep(i,h) rep(j,w) cin>>data[i][j];
        int c[5];
        rep(i,4)cin>>c[i];
        
        int d[40][40][4];
        bool used[40][40][4];
        rep(i,40)rep(j,40)rep(k,4){d[i][j][k]=INF;used[i][j][k]=false;}
        
        d[0][0][0]=0;
        
        int dy[]={0,1,0,-1};
        int dx[]={1,0,-1,0};
        while(1){
            int vx=-1,vy=-1,dir=-1;
            rep(i,h){
                rep(j,w){
                    rep(k,4){
                        if(!used[i][j][k]&&(vx==-1||d[i][j][k]<d[vy][vx][dir]))vy=i,vx=j,dir=k;
                    }
                }
            }

            if(vy==-1)break;
            used[vy][vx][dir]=true;
            if(data[vy][vx]!=4){
                int ddy=vy+dy[(dir+data[vy][vx])%4],ddx=vx+dx[(dir+data[vy][vx])%4];
                if(ddy<h && ddx<w && ddx>=0 && ddy>=0){
                    d[ddy][ddx][(dir+data[vy][vx])%4]=min(d[vy][vx][dir],d[ddy][ddx][(dir+data[vy][vx])%4]);
                }
            }
            rep(i,4){
                int ddy=vy+dy[(dir+i)%4],ddx=vx+dx[(dir+i)%4];
                if(ddy<h && ddx<w && ddx>=0 && ddy>=0){
                    d[ddy][ddx][(dir+i)%4]=min(d[vy][vx][dir]+c[i],d[ddy][ddx][(dir+i)%4]);
                }
            }
        }
        int ans=INF;
        rep(i,4)ans=min(d[h-1][w-1][i],ans);
        cout<<ans<<endl;   
    }
}

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

using namespace std;

const int N = 1005;
const int M = 200005;

vector<int> G[N];

int a[M], b[M], vis[N], w[N][N], p[N][N], q[N][N];

int n, m;

void dfs(int u, int x)
{
	vis[u] = 1, w[x][u] = 1;
	for (auto v : G[u])
		if (!vis[v])
			dfs(v, x);
}

void dfs2(int u, int x, bool ch)
{
	for (auto v : G[u])
		if (v != x && !vis[v])
		{
			vis[v] = vis[u];
			dfs2(v, x, ch);
		}
	if (!ch)
		p[x][u] = vis[u];
	else
		q[x][u] = vis[u];
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> a[i] >> b[i];
		G[a[i]].push_back(b[i]);
	}
	for (int i = 1; i <= n; i++)
	{
		memset(vis, 0, sizeof(vis));
		dfs(i, i);	
	}
	for (int i = 1; i <= n; i++)
	{
		memset(vis, 0, sizeof(vis));
		int SZ = G[i].size();
		for (int j = 0; j < SZ; j++)
		{
			int v = G[i][j];
			if (!vis[v])
				vis[v] = v, dfs2(v, i, 0);
		}
		memset(vis, 0, sizeof(vis));
		for (int j = SZ - 1; j >= 0; j--)
		{
			int v = G[i][j];
			if (!vis[v])
				vis[v] = v, dfs2(v, i, 1);	
		}
	}
	for (int i = 1; i <= m; i++)
	{
		int x = w[b[i]][a[i]];
		int y = (p[a[i]][b[i]] != b[i] || q[a[i]][b[i]] != b[i]);
		if (x == y)
			cout << "same" << endl;
		else
			cout << "diff" << endl;
	}
	return 0;	
}


Measured memory_bytes: 16256
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(M)))


class UFT:
    def __init__(self, n):
        self.sizes = [1] * n
        self.par = list(range(n))

    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.par[y] = x
        self.sizes[x] += self.sizes[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return self.sizes[self.find(x)]

u = UFT(N + 1)
ans = [0 for _ in range(M)]
z = N * (N - 1) // 2
for i in range(1, M + 1):
    ans[-i] = z
    if not u.same(A[-i], B[-i]):
        z -= u.size(A[-i]) * u.size(B[-i])
    u.unite(A[-i], B[-i])

for a in ans:
    print(a)

Measured memory_bytes: 57472
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,n = LI()
    a = LI()
    if sum(a) >= h:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 53392
def calc(A, b):
    retval = 0
    for a in A:
        retval += abs(a - b)
    return retval
 
 
def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] -= (i + 1)
 
    left = min(A)
    right = max(A)
 
    while left < right:
        c1 = (left + left + right) // 3       # floor
        c2 = -(-(left + right + right) // 3)  # ceil
        if calc(A, c1) <= calc(A, c2):
            right = c2 - 1
        else:
            left = c1 + 1
    print(calc(A, left))
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 86612
n=int(input())
s=[list(map(int,list(input().split()))) for i in range(n)]  # 二次元配列入力　二次元マップみたいな入力のとき

# print("n", n)
# print("s:", s)

import math

def calc_distance(a, b):
    tmp = (a[0]-b[0])**2 + (a[1]-b[1])**2
    return math.sqrt(tmp)

sum = 0
for i in s: 
    for j in s:
        dist = calc_distance(i, j)
        sum += dist

print(float(sum/n))

Measured memory_bytes: 3064
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (r[0] == r[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        
    }
}

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

int main()
{
    int N;
    cin >> N;
    bool flag = false;
    vector<long long> a(N);
    for (int i = 0; i < N; i++)
    {
        long long x;
        cin >> x;
        if (x == 0)
            flag = true;
        a[i] = x;
    }
    if (flag)
    {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 1LL;
    for (int i = 0; i < N; i++)
    {
        if (a[i] <= 1000000000000000000 / ans)
        {
            ans *= a[i];
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,a[100010];
bool used[100010]={};

int main(){
	cin >> n;
	REP(i,1,n+1) cin >> a[i];
	
	int now=1;
	REP(i,0,n){
		if(used[now]){cout << -1 << endl; break;}
		used[now]=true;
		now=a[now];
		if(now==2){cout << i+1 << endl; break;}
	}
	
	return 0;
}


Measured memory_bytes: 768
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

r = 0
for i in range(n):
    r += B[A[i] - 1]
#    print("B = ",B[A[i] - 1])
    
    if i > 0:
        if A[i] == A[i-1] + 1:
#            print("bonus", C[A[i-1] - 1])
            r += C[A[i-1] - 1]

print(r)
#print(r)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	YN((r * 100 + g * 10 + b) % 4 == 0);

	return 0;
}

Measured memory_bytes: 256