akhauriyash/Code-Regression huggingface dataset:
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);

void solve(){
  int n; cin>>n;
  int x=0;
  f(i,0,n){
    int l; cin>>l; 
    if(l&1) ++x;
  }
  if(x%2==0) cout<<"YES";
  else cout<<"NO";

}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    using pii=pair<int,int>;
    vector<pii> ba(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        a*=-1;
        ba[i]=make_pair(b,a);
    }
    sort(ba.begin(),ba.end());
    ll t=0;
    rep(i,n){
        t+=-ba[i].second;
        if(t>ba[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}




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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(Math.Max(ab.Sum(), Math.Max(ab[0]-ab[1], ab[0]*ab[1])));
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,c,d,e;
cin >> a >> b;
c = a + b;
d = a - b;
e = a * b;
int ans = max(mINF,c);
ans = max(ans,d);
ans = max(ans,e);
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
import numpy as np

N, T = map(int, input().split())
pl = [[int(i) for i in input().split()] for _ in range(N)]

c_min = np.inf
for p in pl:
    if p[1] <= T:
        if p[0] <= c_min:
            c_min = p[0]

if c_min == np.inf:
    print("TLE")
else:
    print(c_min)

Measured memory_bytes: 12468
#include<stdio.h>
 
int main(){
    int d, i, s;

    while(scanf("%d", &d) != EOF){

        s = 0;

        for(i=0; i<600; i+=d){
            s += d*i*i;
        }
        printf("%d\n", s);
    }
    return 0;
}

Measured memory_bytes: 596
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
  int n, sum = 0;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    sum += m;
    a.push_back(m);
  }
  int l = sum / n, u = (sum / n) + ((sum % n) > 0);
  int lsum = 0, usum = 0;
  for (int i = 0; i < n; i++){
    lsum += ((a[i] - l) * (a[i] - l));
    usum += ((a[i] - u) * (a[i] - u));
  }
  cout << min(lsum, usum) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long i,j,k,a,b,c=0,d,n,m,t=1,x;
cin>>n>>d>>x;
long long A[n];
for(i=0;i<n;i++)
cin>>A[i];
for(i=0;i<n;i++)
{
  t=1;
  while(t<=d)
  {
    x++;
    t+=A[i];
  }
}
cout<<x<<endl;
return 0;
}


Measured memory_bytes: 3588
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut s = 0;
    let mut x = n;
    while x > 0 {
    	s += x % 10;
        x /= 10;
    }
    if n % s == 0 {
    	println!("Yes");
    } else {
    	println!("No");
    }
}

Measured memory_bytes: 4352
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[] Ai = new int[n];
        double totalVotes = 0;
        for (int i = 0; i < n; i++) {
            Ai[i] = sc.nextInt();
            totalVotes += Ai[i];
        }
        int changeValue;
        int max;
        for (int i = 0; i < n; i++) {
            max = Ai[n - 1];
            for (int j = n - 2; j >= i; j--) {
                if (max > Ai[j]) {
                    changeValue = Ai[j];
                    Ai[j] = Ai[j + 1];
                    Ai[j + 1] = changeValue;
                } else {
                    max = Ai[j];
                }
            }
        }

        totalVotes = totalVotes / 4 / m;
        boolean flag = true;
        for (int i = 0; i < m; i++) {
            if ((double)Ai[i] < totalVotes) {
                flag = false;
            }
        }

        if (flag == true) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    scanf("%d",&a);
    char s[10];
    cin>>s;
    if(a>=3200){
            cout<< s<<endl;
    }
    else if(a<3200){
        printf("red\n");

    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main(){
  ld a,b,c;
  cin>>a>>b>>c;
  ld ans1=a+b+2*sqrt(a)*sqrt(b);
  ld ans2=c;
  if(ans1<ans2)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6+5;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int main(){
    ios;
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 10948
#include <algorithm>
#include <cstdio>
#include <cstring>

const int Maxv = 100010; 
int cnt; 
bool vis[Maxv]; 
char s[Maxv]; 

inline void DFS(int u, int v) {
    if (u == 0)
        return; 

    printf("%d %d\n", u, v); 
    if (vis[u])
        DFS(u - 1, u); 
    else 
        DFS(u - 1, v); 
}

int main() {
    scanf("%s", s + 1); 
    int n = strlen(s + 1); 
    for (int i = 1; i <= n; i++) {
        if (s[i] == '1')
            vis[i] = true; 
    }

    for (int i = 0; i <= n; i++)
        if (vis[i] != vis[n - i]) {
            puts("-1"); 
            return 0; 
        }

    if (vis[1] == 0) {
        puts("-1"); 
        return 0; 
    }

    DFS(n - 1, n); 
    return 0; 
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 
vi ans;
struct edge {
  int to, id;
};
vector<vector<edge> > g;

void dfs(int v,int c=-1, int from=-1) {
  int k = 1;
  rep(i, g[v].size()) {
    int u = g[v][i].to;
    if (u==from) continue;
    int ei=g[v][i].id;
    if (k==c) k++;
    ans[ei] = k; k++;
    dfs(u,ans[ei], v);
  }
}

int main() {
  int N; cin>>N;
  ans.resize(N-1);
  g.resize(N);
  rep(i,N-1) {
    int a,b; cin>>a>>b;
    a--;b--;
    g[a].push_back((edge){b, i});
    g[b].push_back((edge){a, i});
  }
  dfs(0);
  int mx = 0;
  rep(i,N) mx = max(mx, (int) g[i].size());
  cout << mx << endl;
  rep(i, N-1) cout << ans[i] << endl;
  return 0;
}

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

int main(){
    long T, N;
    cin >> T >> N;
    vector<pair<long double, long double>> tapi, tapu, tape;
    {
        long x, l, h;
        auto alpha = static_cast<long double>(1) / T;
        for (int i = 0; i < N; ++i) {
            cin >> x >> l >> h;
            auto a = l / static_cast<long double>((T - x) * x), b = h / static_cast<long double>((T - x) * x);
            if(alpha < a)tape.emplace_back(a, b);
            if(a <= alpha && alpha <= b)tapi.emplace_back(a, b);
            if(alpha > b)tapu.emplace_back(b, a);
        }
        sort(tapu.begin(), tapu.end());
        sort(tapi.begin(), tapi.end());
        sort(tape.rbegin(), tape.rend());
    }

    vector<long double> hoge;
    long double now1 = -1000000000000;
    for(auto i : tapu){
        if(i.first < now1 || i.second > now1){
            hoge.push_back(i.first);
            now1 = i.first;
        }
    }
    long double now2 = -1000000000000;
    for(auto i : tape){
        if(i.first > now2 || i.second < now2){
            hoge.push_back(i.first);
            now2 = i.first;
        }
    }
    for(auto i : tapi){
        if(!((i.first <= now1 && now1 <= i.second) || (i.first <= now2 && now2 <= i.second))){
            hoge.push_back(static_cast<long double>(1) / T);
            break;
        }
    }
    auto S = [&T](long double k){
        return sqrt(1 / (2 * k) + (T * T * k) / 2);
    };
    long double ans = 0;
    for(auto i : hoge)ans += S(i);
    printf("%.12Lf\n", ans);
    return 0;
}


Measured memory_bytes: 8864
#include <stdio.h>
#include <stdlib.h>

int compar(const void *a, const void *b);

int main(void) {
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if (((x - r) >= 0) && ((x + r) <= W)
      && ((y - r) >=0) && ((y + r) <= H))
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;
using LP = pair<ll,ll>;
using P = pair<ll,int>;
ll inf = 1e18;

int di[4] = {-1, 0, 1, 0};
int dj[4] = {0, 1, 0, -1};
int main()
{
    ll n;
    ll k; 
    ll mod = 1e9+7;
    cin >> n >> k;
    vector<ll> a(n),total(n,0), right(n,0);
    rep(i, n) cin >> a[i];
    rep(i, n){
        rep(j, n){
            if(a[i] > a[j]) total[i]++;
            if (i < j and a[i] > a[j]) right[i]++;
        }
    }
    ll rightsum = 0, totalsum = 0;
    rep(i, n){
        rightsum += right[i];
        totalsum += total[i];
    }
    ll ans = 0;
    ans = rightsum*k%mod;
    ans += (k*(k-1)/2%mod)*totalsum;
    ans %= mod;
    cout << ans << endl;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
const int MAX_M = 100005;

int N;
int T, A;
int H[MAX_N];

signed main()
{
  cin >> N;
  cin >> T >> A;

  int ans = -1;
  double aa = 1e9;

  REP(i,N) {
    cin >> H[i];
    if(aa > abs(A - (T - H[i]*0.006))) {
      aa = abs(A - (T - H[i]*0.006));
      ans = i+1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,x,a[100010];
 
int main(){
	cin >> n >> x;
	REP(i,0,n) cin >> a[i];
	
	ll s=0;
	REP(i,0,n-1){
		if(a[i]+a[i+1]>x){
			s+=(a[i]+a[i+1])-x;
			a[i+1]-=(a[i]+a[i+1])-x;
			if(a[i+1]<0) a[i+1]=0;
		}
	}
	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 640
//AtCoder ABC067 A - Sharing Cookies
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll A,B;
    cin>>A>>B;
    cout<<((A%3==0 || B%3==0 || (A+B)%3==0)?"Possible":"Impossible")<<endl;
    return 0;
}

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

using namespace std;

int a, b;

bool check(int val) {
    return a * val - (val - 1) >= b;
}

int main() {
    cin >> a >> b;
    int lo = 0, ri = 10000, ans = 0;
    for (int i = 0; i <= 10000; ++i) {
        if (check(i) > 0) {
            ans = i;
            break;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple


class DisjointSet(object):
    def __init__(self, size):
        self.rank = []
        self.p = []
        for i in range(size):
            self.makeSet(i)

    def makeSet(self, x):
        self.p.insert(x, x)
        self.rank.insert(x, 0)

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

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]



def kruskal(V, E, es):
    es.sort(key=lambda x: x.c)
    uf = DisjointSet(V)
    res = 0

    for i in range(E):
        e = es[i]
        if not uf.same(e.u, e.v):
            uf.unite(e.u, e.v)
            res += e.c
    return res

edge = namedtuple('edge', ['u', 'v', 'c'])
def main(args):
    V, E = map(int, input().split())
    es = []
    for _ in range(E):
        s, t, w = map(int, input().split())
        es.append(edge(s, t, w))

    result = kruskal(V, E, es)
    print(result)



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

Measured memory_bytes: 27652
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int L,n,X[N];ll ans;
ll num;
ll nwl,nwr,cntl,cntr;
int main()
{
	scanf("%d%d",&L,&n);for (int i=1;i<=n;i++)scanf("%d",&X[i]);
	ans=X[n];
	nwl=n;nwr=n+1;
	for (int i=n;i;i--)
	{
		num=min(i-1,n-i);
		cntr-=X[i];
		while (i-nwr<num&&nwr>1) nwr--,cntr+=X[nwr];
		while (nwl-i>num&&nwl>0) cntl-=(L-X[nwl]),nwl--;
		ll lstl,lstr;
		if (nwl==n) lstl=0;else lstl=(L-X[nwl+1])*2;
		if (!nwr) lstr=0;else lstr=X[nwr-1]*2;
		ans=max(ans,(ll)(cntl+cntr)*2+max(X[i]+lstl,L-X[i]+lstr));
		cntl+=L-X[i];
	}
	cout<<ans;
}

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

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

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll now = 0;
  unordered_map<ll, ll> unmp;
  unmp[0]++;//
  rep(i, n) {
    now += a[i];
    unmp[now]++;
  }

  ll ans = 0;
  for(auto elem : unmp) {
    ans += elem.second*(elem.second-1)/2;
  }

  cout << ans << '\n';
  return 0;
}


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

int main() {
    int N, L;
    cin >> N >> L;
    int sum = 0, minv = 100100;
    for (int i = L; i < L + N; i++) {
        sum += i;
        if (abs(i) < abs(minv)) minv = i;
    }
    cout << sum - minv << endl;
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> C;
  for (int i = 0; i < h; i++)
  {
    string s;
    cin >> s;
    C.push_back(s);
  }
  for (int i = 0; i < h; i++)
  {
    cout << C[i] << endl
         << C[i] << endl;
  }
}


Measured memory_bytes: 3624
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0:
        break
    a = "#" * W
    b = "#" + "." * (W - 2) + "#"
    print(a)
    for i in range(H - 2):
      print(b)    
    print(a)
    print()

Measured memory_bytes: 7596
def chess(h,w):
  if (h+w) % 2 == 0:
    return '#'
  return '.'
 
while True:
  H, W = map(int,input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    for j in range(W):
      print(chess(i,j), end='')
    print()
  print()


Measured memory_bytes: 7012
#include <stdio.h>

int binarysearch(int[],int,int);

int main(){
    int i,n,m,k,res=0,num[100000];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&num[i]);
    }
    
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d",&k);
        if(binarysearch(num,n,k)){
            res++;
        }
    }
    printf("%d\n",res);
    
    return 0;
}
int binarysearch(int A[],int n,int key){
    int left = 0,right = n,mid;
    
    while(left < right){
    mid = (left+right)/2;
    if(key == A[mid]){
        return 1;
    }
    if(key > A[mid]){
        left = mid+1;
    }
    else if(key < A[mid]){
        right = mid;
    }
    }
    return 0;
}


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

bool check(char which, string board) {
    //水平
    for(int r = 0; r < board.length(); r+=3)
        if(board[r]==which&&board[r+1]==which&&board[r+2]==which)return(true);
    //垂直
    for(int r = 0; r < 3; r++)
        if(board[r]==which&&board[r+3]==which&&board[r+6]==which)return(true);
    //斜め
    if((board[0]==which&&board[4]==which&&board[8]==which) ||
       (board[2]==which&&board[4]==which&&board[6]==which))return(true);
    return(false);
}

int main(void) {
    string input;
    while(cin >> input) {
        if(check('o', input)) cout << "o" << endl;
        else if(check('x', input)) cout << "x" << endl;
        else cout << "d" << endl;
    }
    return(0);
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
static const int64_t INF = 1000000000;


int main(){
	int64_t a, b, x;
	cin >> a >> b >> x;
	
	int64_t lower = a == 0 ? 0 : (a - 1) / x + 1;
	int64_t upper = b / x + 1;
	int64_t ans = upper - lower;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int m;
vector<int> g[100003];
vector<ll> vv1[100003], vv2[100003];

ll dfs1(int fr, int cu) {
    int i;
    ll res;
    res = 1;
    for (i = 0; i < g[cu].size(); i++) {
        if (g[cu][i] != fr) {
            vv1[cu][i] = dfs1(cu, g[cu][i]);
            res = res * vv1[cu][i] % m;
        }
    }
    return (res + 1) % m;
}

void dfs2(int fr, int cu, ll va) {
    int i;
    ll l, r;
    for (i = 0; i < g[cu].size(); i++) {
        if (g[cu][i] == fr) {
            vv1[cu][i] = va;
        }
    }
    for (i = 0; i < g[cu].size(); i++) {
        vv2[cu][i] = vv1[cu][i];
    }
    for (i = 1; i < g[cu].size(); i++) {
        vv1[cu][i] = vv1[cu][i] * vv1[cu][i - 1] % m;
    }
    for (i = g[cu].size() - 2; i >= 0; i--) {
        vv2[cu][i] = vv2[cu][i] * vv2[cu][i + 1] % m;
    }
    for (i = 0; i < g[cu].size(); i++) {
        if (g[cu][i] != fr) {
            l = r = 1;
            if (i > 0) l = vv1[cu][i - 1];
            if (i < g[cu].size() - 1) r = vv2[cu][i + 1];
            dfs2(cu, g[cu][i], (l * r % m + 1) % m);
        }
    }
}

int main(void) {
    int n, i, a, b;

    scanf("%d%d", &n, &m);
    for (i = 0; i < n - 1; i++) {
        scanf("%d%d", &a, &b);
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
        vv1[a - 1].push_back(1);
        vv2[a - 1].push_back(1);
        vv1[b - 1].push_back(1);
        vv2[b - 1].push_back(1);
    }

    if (n == 1) {
        printf("1\n");
        return 0;
    }

    dfs1(-1, 0);

    dfs2(-1, 0, 0);

    for (i = 0; i < n; i++) {
        printf("%lld\n", vv2[i][0]);
    }

    return 0;
}

Measured memory_bytes: 23424
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
ll A,B,C,ans;
bool go()
{
    if(A&1||B&1||C&1) return false;
    ans++;
    ll sum=A+B+C;
    A=(sum-A)/2;
    B=(sum-B)/2;
    C=(sum-C)/2;
    return true;
}
int main()
{
    scanf("%lld%lld%lld",&A,&B,&C);
    if(A==B&&B==C&&(A%2==0)) {puts("-1"); return 0;}
    while(go());
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 256
class Array
def insert k
x,l,r=self
x ?(k<x ?l:r).insert(k):self<<k<<[]<<[]
end
def find k
puts f(k) ?:yes: :no
end
def f k
x,l,r=self
x&&(k==x||(k<x ?l:r).f(k))
end
def delete k
x,l,r=self
x&&(k==x ?d: (k<x ?l:r).delete(k))
end
def d
k,l,r=self
l[0]&&r[0]?self[0]=r.s : (clear
a,b,c=l+r
a&&self<<a<<b<<c)
end
def s
k,l=self
l[0]?(l.s):(clear
k)
end
def print
$x,$y=[p],[p]
w
puts $y*" ",$x*" "
end
def w
x,l,r=self
x&&($x<<x
l.w
$y<<x
r.w)
end
end
t=[]
gets
eval"t.#$_"while gets

Measured memory_bytes: 94540
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cassert>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 1000
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef VVI matrix;

const int diff = 100;
int dx[] = { 0,1,1,0,-1,-1};
int dy[] = {-1,0,1,1, 0,-1};
int N,L,min_x,min_y,max_x,max_y;
int Index[MAX][MAX];
ll M;

matrix identity(int n)
{
  matrix A(n,vector<ll>(n));
  for(int i=0;i<n;i++) A[i][i] = 1;
  return A;
}

vector<ll> multi(const matrix& A,const vector<ll>& B)
{
  vector<ll> ret(A.size());
  for(int i=0;i<A.size();++i)
    for(int j=0;j<A[0].size();++j)
      ret[i] += (A[i][j]*B[j])%M;
  return ret;
}

matrix multi(const matrix& A,const matrix& B)
{
  matrix C(A.size(),vector<ll>(B[0].size()));
  for(int i=0;i<C.size();++i)
    for(int j=0;j<C[i].size();++j)
      for(int k=0;k<A[i].size();++k)
	C[i][j] = (C[i][j]+(A[i][k]*B[k][j])%M)%M;
  return C;
}

matrix pow(const matrix& A,int e)
{
  return !e?identity(A.size()):
    (e%2?multi(A,pow(A,e-1)):pow(multi(A,A),e/2));
}


int main()
{
  int CNT = 1;
  while(cin >> N >> M >> L,N|M|L)
    {
      min_x = min_y = 999;
      max_x = max_y = 0;
      rep(i,MAX)rep(j,MAX)Index[i][j] = inf;

      int x = diff;
      int y = diff;
      int add = 0;
      int size = 0;
      vector<ll> b;

      rep(i,2*N-1)
	{
	  int nx = x,ny = y;
	  rep(j,N+add)
	    {
	      int value;
	      cin >> value;
	      b.push_back(value);
	      Index[ny][nx] = size;
	      size++;
	      nx += dx[1];
	      ny += dy[1];
	    }
	  if(i < N-1)add++;
	  else       add--;
	  if(i < N-1)
	    {
	      x += dx[3], y += dy[3];
	    }
	  else 
	    {
	      x += dx[2], y += dy[2];
	    }
	}

      matrix A = identity(size);

      REP(i,diff,diff+2*N)
	{
	  REP(j,diff,diff+2*N)
	    {
	      if(Index[i][j] == inf)continue;
	      int cur = Index[i][j];
	      rep(k,6)
		{
		  int nx = j + dx[k];
		  int ny = i + dy[k];
		  if(Index[ny][nx] == inf)continue;
		  int next = Index[ny][nx];
		  A[cur][next] = 1;
		}
	    }
	}
  
      A = pow(A,L);
 
      vector<ll> c = multi(A,b);
      ll ans = 0;
      rep(i,c.size())ans += c[i]%M;

      cout << "Case " << CNT++ << ": " << ans << endl;

    }
  return 0;
}

Measured memory_bytes: 7292
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long num = sc.nextLong();
		String st = sc.next();
		System.out.println(st.replace("B", "").length() > st.replace("R", "").length() ? "Yes" : "No");
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define PI atan(1) * 4
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sol() {
  int a, b, h, m;
  double ans;
  cin >> a >> b >> h >> m;
  double th = 0.5 * (60*h + m);
  double tm = 6 * m;
  double theta = abs(th - tm);
  if(theta > 180) {
    theta = 360 - theta;
  }
  double radians = theta * (PI);
  radians /= 180;
  ans = sqrt(a*a + b*b - 2*a*b*cos(radians));
  cout << setprecision(20) << fixed << ans << '\n';
  //cout << ans << "\n";
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; 
  for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
    sol();
  }
  return 0;
}


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

int main(){
  int64_t l,r,ans=2019;
  cin >> l >> r;
  if(r>=(l+2018))ans=0;
  else 
    for(int64_t i=l;i<r;i++){
      for(int64_t j=i+1;j<=r;j++){
        ans = min(ans,(i*j)%2019);
      }
    }
  cout <<ans;
}
        
        

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

using namespace std;

int main(void) {
    int N, Q;
    string S;
    cin >> N >> S >> Q;

    vector< set<int> > vst(26);
    for(int i=0; i<N; i++) {
        vst[S[i] - 'a'].insert(i);
    }

    while(Q--) {
        int q;
        cin >> q;
        if(q == 1) {
            int i;
            char c;
            cin >> i >> c;
            --i;
            vst[S[i] - 'a'].erase(i);
            S[i] = c;
            vst[S[i] - 'a'].insert(i);
        } else if(q == 2) {
            int l, r;
            cin >> l >> r;
            --l; --r;
            int ans = 0;
            for(int i=0; i<26; i++) {
                if(vst[i].upper_bound(r) != vst[i].lower_bound(l)){
                    ++ans;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24196
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] hp = new int[n][];
        for(int i=0;i<n;i++) hp[i]=new int[]{sc.nextInt(),sc.nextInt()};
        Arrays.sort(hp,new myC());
        int inf = Integer.MAX_VALUE;
        int[][] dp = new int[n+1][n+1];
        // dp[i][j] the minimum height when choosing j people from the first i people (1-base);
        for(int i=0;i<n+1;i++) Arrays.fill(dp[i],inf);
        for(int i=0;i<n+1;i++) dp[i][0]=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=i;j++){
                dp[i][j] = Math.min(dp[i][j],dp[i-1][j]);
                if(dp[i-1][j-1]<=hp[i-1][0]) dp[i][j] = Math.min(dp[i][j],dp[i-1][j-1]+hp[i-1][1]);
            }
        }
        int ans = 0;
        for(int i=1;i<=n;i++){
            if(dp[n][i]<inf) ans = Math.max(ans,i);
        }
        System.out.println(ans);
    }
    static class myC implements Comparator<int[]>{
        public int compare(int[] a, int[] b){
            if(a[0]+a[1]-b[0]-b[1]!=0) return a[0]+a[1]-b[0]-b[1];
            else return a[0]-b[0];
        }
    }
}


Measured memory_bytes: 161756
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    int A[N];
    for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
    for (int i = K; i < N; ++i) {
        if (A[i] > A[i - K]) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2440
#include <bits/stdc++.h>
#define fir first
#define sec second
#define mp std::make_pair

typedef long long ll;

const int N = 2005;
const int MOD = 1e9 + 7;

int n, k;
ll c[N][N];

inline void init() {
    for (int i = 0; i <= 2000; i++) c[i][0] = 1;
    for (int i = 1; i <= 2000; i++) {
        for (int j = 1; j <= i; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
        }
    }
}

int main() {
    init();
    std::cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        printf("%lld\n", c[k - 1][i - 1] * c[n - k + 1][i] % MOD);
    }
    return 0;
}

Measured memory_bytes: 30080
#include <stdio.h>

int main(){

    int N,T;
    scanf("%d %d",&N,&T);
    int time,cost;
    int min_cost=1001;
    int flag=0;

    for(int i=0;i<N;i++){
        scanf("%d %d",&cost,&time);
        if(time <= T){
            if(cost<min_cost){
                min_cost=cost;
                flag++;
            }
        }
    }

    if(flag==0)printf("TLE");
    else printf("%d",min_cost);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;
    int V, C;
    vector<int> vs;
    vector<int> cs;
    for (int i = 0; i < N; ++i) {
        cin >> V;
        vs.push_back(V);
    }
    for (int i = 0; i < N; ++i) {
        cin >> C;
        cs.push_back(C);
    }

    int sum = 0;
    for (int i = 0; i < N; ++i) {
        if (vs[i] > cs[i]) {
            sum += (vs[i] - cs[i]);
        }
    }

    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner stdIn=new Scanner(System.in);

        long x=stdIn.nextLong();
        int count=0;

        long a=100;
        while(true){
            if(a>=x){
                break;
            }
            a=a+a/100;
            count++;
        }
        System.out.println(count);
        
    }

}

Measured memory_bytes: 35792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n;
    cin >> n;
    ll a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    ll s = 0;
    for (i = 0; i < n; i++) s += a[i];
    s %= mod;
    s = s * s % mod;
    for (i = 0; i < n; i++) {
        s += mod - a[i] * a[i] % mod;
        s %= mod;
    }
    cout << s * (mod + 1) / 2 % mod << endl;
}

Measured memory_bytes: 5248
N = int(input())
A = list(map(int,input().split()))

check = set()
free = 0
for a in A:
  x = (a-a%400)//400
  if(x < 8):
    check.add(x)
  else:
    free += 1
c = len(check) 
if(c == 0):
  print(1, free)
else:
  print(c, c+free)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll n;
    cin>>n;
    char s[110];
    rep(i,n) cin>>s[i];
    ll cnt[5]={};
    rep(i,n){
        if(s[i]=='P') cnt[0]=1;
        else if(s[i]=='W') cnt[1]=1;
        else if(s[i]=='G') cnt[2]=1;
        else if(s[i]=='Y') cnt[3]=1;
    }
    ll ans=0;
    rep(i,4){
        if(cnt[i]>0) ans++;
    }
    if(ans==3) cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
//
//  atcoder.cpp
//  
//
//  Created by 中川阿津志 on 2018/12/05.
//
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

//#include "atcoder.hpp"

long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}
int main() {
    vector<int> w(1, 1);
    int N;
    vector<pair<int,int>> AB;
    cin >> N;
    
    REP(i,N){
        int a,b;
        cin>>a>>b;
        
        AB.emplace_back(a,b);
    }
    
    sort(AB.begin(),AB.end(), [](pair<int,int>& a, pair<int,int>& b){return (a.first+a.second) > (b.first+b.second);});
    
    long long r = 0L;
    AB.emplace_back(0,0);
    for (int i = 0; i+1 < AB.size();i+=2) {
        r+= AB[i].first;
        r-= AB[i+1].second;
    }
    cout << r << endl;

    return 0;
}



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

int main() {
    string s;
    cin >> s;
    int ans;
    if(s=="SUN") ans = 7;
    if(s=="MON") ans = 6;
    if(s=="TUE") ans = 5;
    if(s=="WED") ans = 4;
    if(s=="THU") ans = 3;
    if(s=="FRI") ans = 2;
    if(s=="SAT") ans = 1;
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 764
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<int> A(in());
	for (int &x :A)
		x = in();
	auto s = A.begin();
	for (int q = in(); q; q--) {
		int b = in(), e = in();
		outl(count(s + b, s + e, in()));
	}
}


Measured memory_bytes: 2636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x;
    cin>>x;
    int a=x%10;
    int b=(x%100)/10;
    int c=(x%1000)/100;
    int d=(x%10000)/1000;
    int e=(x%100000)/10000;
    int f=(x%1000000)/100000;
    int g=(x%10000000)/1000000;
    int h=(x%100000000)/10000000;
    int i=(x%1000000000)/100000000;
    int j=(x%10000000000)/1000000000;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j;
    int y=a+b+c+d+e+f+g+h+i+j;
    cin>>y;
    if(x%y==0)cout<<"Yes"<<endl;
    if(x%y!=0)cout<<"No"<<endl;
    
    
}


Measured memory_bytes: 256
#include<iostream>
int cnt=0;
void merge(int A[],int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	int L[500000],R[500000];
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	L[n1]=10000000000;
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	R[n2]=10000000000;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
			cnt++;
		}else{
			A[k]=R[j];
			j++;
			cnt++;
		}
	}
}
void mergeSort(int A[],int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}
int main(){
	int n,A[500000];
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>A[i];
	}
	mergeSort(A,0,n);
	for(int i=0;i<n;i++){
		if(i!=n-1){
			std::cout<<A[i]<<" ";
		}else{
			std::cout<<A[i]<<"\n";
		}
	}
	std::cout<<cnt<<"\n";
	return 0;
}


Measured memory_bytes: 6948
#include<iostream>

using namespace std;

typedef long long ll;

int main() {
	ll H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
		return 0;
	}

	ll u, l;
	u = (W + 1) / 2;
	l = W - u;
	cout << (u * ((H + 1) / 2) + l * (H - ((H + 1) / 2))) << endl;
	return 0;
}

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

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

  vector<ll> x(N);
  vector<ll> y(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
    cin >> y.at(i);
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    ll px = x.at(i);
    ll py = y.at(i);

    double z = sqrt(px * px + py * py);
    if (z <= D) {
      sum++;
    }
  }

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

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

ll inv(ll a, ll b){
    return (a > 1 ? b - inv(b%a, a)*b/a : 1);
}

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
#define N 510

const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC

int n, ans = 1, a[N], k, b[N], sum, mx;

int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //ifstream cin ("test.in");
    cin >> n >> k;
    for (int i=1; i<=n; i++) cin >> a[i], sum += a[i];
    sort(a+1, a+1+n);
    if (sum - mx <= k) rc(sum);
    for (int i=2; i<=sum; i++){
        if (sum % i) continue;
        int s = 0;
        for (int j=1; j<=n; j++) b[j] = a[j] % i, s += b[j];
        sort(b+1, b+1+n);
        int lol = s / i, cnt = 0;
        for (int j=n; j && lol; j--, lol--) cnt += i - b[j];
        if (cnt <= k) ans = i;
    }
    cout << ans;
    return 0;
}


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

//const long long INF = 1000000001;
const int INF = 2147483647;

const long long MOD = 1000000009;

typedef long long ll;

const int max = 100000; //配列の最大長

int main(void){
  int N,W;
  std::cin >> N >> W;

  int value[N],weight[N];
  for(int i=0; i<N; i++) std::cin >> value[i] >> weight[i];

  int dp[N+1][W+1] = {};

  for(int i=0; i<N; i++){
    for(int sum_w = 0; sum_w <= W; sum_w++){
      if(sum_w - weight[i] >= 0) dp[i+1][sum_w] = dp[i][sum_w - weight[i]] + value[i];
      dp[i+1][sum_w] = std::max(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }

  std::cout << dp[N][W] << std::endl;
  return 0;
}



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

using namespace std;

int selectionSort(vector<int> &x, int n){
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i; j < n; j++){
            if(x[j] < x[minj]){
                minj = j;
            }
        }
        swap(x[i], x[minj]);
        if(i != minj) cnt++;
    }
    return cnt;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    int ans = selectionSort(A, N);
    for(int i = 0; i < N; i++) cout << A[i] << (i < N-1 ? " " : "");
    cout << "\n";
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

typedef class Item {
  public:
    ll a, b;
    int id;
  
    Item() {  }
    Item(ll a, ll b, int id) : a(a), b(b), id(id) { }

    void read() {
      scanf("%lld%lld", &a, &b);
      a = max(a, b);
    }
    bool operator < (Item x) const {
      return a - b < x.a - x.b;
    }
} Item;

typedef class dp_t {
  public:
    ll f, b;

    dp_t() {  }
    dp_t(ll f, ll b) : f(f), b(b) {  }
    dp_t(Item x) : f(x.a), b(x.b) { }

    dp_t operator + (dp_t t) const {
      return dp_t(max(f, b + t.f), b + t.b);
    }
} dp_t;

#define ll long long

const int N = 1e5 + 5;
const ll llf = (signed ll) (~0ull >> 3);

int n, m;
Item it[N], oit[N];
vector<int> G[N];
vector<int> Tr[N];

int uf[N];
int find(int x) {
  return uf[x] == x ? x : (uf[x] = find(uf[x]));
} 

ll f[N], sb[N];
void dfs(int p) {
  sb[p] = oit[p].b;
  for (auto e : Tr[p]) {
    dfs(e);
    sb[p] += sb[e];
  }
  if (Tr[p].empty()) {
    f[p] = oit[p].a;
  } else {
    f[p] = llf;
    vector<Item> a;
    vector<dp_t> pr, sf;
    for (auto e : Tr[p]) {
      a.emplace_back(f[e], sb[e], e);
    }
    sort(a.begin(), a.end());
    pr.emplace_back(-llf, 0);
    for (auto x : a) {
      pr.push_back(pr.back() + x);
    }
    reverse(a.begin(), a.end());
    sf.emplace_back(-llf, 0);
    for (auto x : a) {
      sf.push_back(dp_t(x) + sf.back());
    }
    reverse(a.begin(), a.end());
    reverse(sf.begin(), sf.end());
    int deg = Tr[p].size();
    for (int i = 0; i < deg; i++) {
      int e = a[i].id;
      auto t = pr[i] + sf[i + 1] + oit[p] + dp_t(f[e], sb[e]);
      f[p] = min(f[p], t.f);
    }
  }
}


int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    it[i].read();
    it[i].id = i;
    oit[i] = it[i];
  }
  sort(it + 1, it + n + 1);
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    int p = it[i].id;
    uf[p] = p;
    for (auto e : G[p]) {
      if (find(e) && (find(p) ^ find(e))) {
        e = find(e);
        Tr[p].push_back(e);
        uf[e] = p;
      }
    }
  }
  int rt = find(1);
  dfs(rt);
  printf("%lld\n", f[rt]);
  return 0;
}


Measured memory_bytes: 29308
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

#include <vector>
#include <queue>
using namespace std;


struct dijkstra
{
  using P=pair<int,int>;
  priority_queue<P,vector<P>,greater<P>> q;
  vector<vector<P>>edge;
  vector<int>dist;
  int sz;
  dijkstra(int size){
    sz=size;
    edge.resize(size);
  }
  inline void reset(){
    dist.assign(sz,-1);
    q=priority_queue<P,vector<P>,greater<P>>();
  }
  void ae(int to,int from,int cost){
    edge[to].push_back({cost,from});
  }
  int cal(int start,int end){
    reset();
    q.push({0,start});
    while(!q.empty()){
      P tp=q.top();q.pop();
      if(dist[tp.second]!=-1)continue;
      dist[tp.second]=tp.first;
      for(P nn:edge[tp.second])
      {
        if(dist[nn.second]!=-1)continue;
        q.push({nn.first+tp.first,nn.second});
      }
    }
    return dist[end];
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<map<int, int>>num(n);
  vector<ed>es(m);
  int cnt=0;
  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    if(num[a].count(c)==0)num[a][c]=cnt++;
    if(num[b].count(c)==0)num[b][c]=cnt++;
  }
  rep(i,n)num[i][-1]=cnt++;
  dijkstra dj(cnt);
  rep(i,n)
  {
    int t=num[i][-1];
    for(auto p:num[i])
    {
      if(p.first==-1)continue;
      int tn=p.second;
      dj.ae(t,tn,1);
      dj.ae(tn,t,0);
    }
  }
  rep(i,m)
  {
    int to=num[es[i].a][es[i].c],from=num[es[i].b][es[i].c];
    dj.ae(to,from,0);
    dj.ae(from,to,0);
  }
  int start=num[0][-1],end=num[n-1][-1];
  cout<<dj.cal(start,end)<<endl;

  return 0;

}


Measured memory_bytes: 63612