akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll n,m;
  cin >> n >> m;
  if(n<2){
    n=0;
  }else{
    n=n*(n-1)/2;
  }
  if(m<2){
    m=0;
  }else{
    m=m*(m-1)/2;
  }
    cout << n+m << endl;


  return 0;
}


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

int mx[3000000],nm[3000000];

int main() {
    int n,q,s,k,id;
	cin >> n >> q;
	for (q;q>0;q--) {
		cin >> s >> k;
         id=1048574+s;
		 nm[id]=s; mx[id]+=k;
		 do {
			 id=(id-1)/2;
			 if (mx[id*2+1]>=mx[id*2+2]) { mx[id]=mx[id*2+1]; if (nm[id*2+1]>0) nm[id]=nm[id*2+1]; }
			 else { mx[id]=mx[id*2+2]; nm[id]=nm[id*2+2];}
		 } while (id>0);
		 cout << nm[0] << " " <<  mx[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 19516
#include<iostream>
using namespace std;
const int maxn=100005;
const int inf=0x3f3f3f3f;
long long n,k,dp[maxn],a[maxn];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=2;i<=n;i++)
	{
		dp[i]=inf;
	}
	dp[0]=0;
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		for(int t=1;t<=k&&i-t>=1;t++)
		dp[i]=min(dp[i-t]+abs(a[i]-a[i-t]),dp[i]);
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 5164
function Main (data) {
  data = data.split("\n");
  var kusi =  data[1].split(" ");
  for(var b = 0; b < kusi.length; b++){
    kusi[b] = Number(kusi[b]);
  }
  kusi.sort(function(a,b){
    if(a < b){return -1};
    if(a > b){return 1};
    return 0;
  });
  var a = 0;
  for(var i = 0; i < kusi.length; i++) {
    a += kusi[i];
    i++;
  }
  console.log(a);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 20980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  cout << min(c,b/a) << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n;
    cin >> n;
    int arr[n + 5];
    for(int i = 0; i < n; i++) cin >> arr[i];
    int search = 1, cntr = 0;
    for(int i = 0; i < n; i++){
        if(arr[i] == search) search ++;
        else cntr++;
    }
    if(search == 1 && cntr) cout << -1;
    else cout << cntr;
    return 0;
}

Measured memory_bytes: 4216
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int A, P;


int main() {

    while (cin >> A >> P) {
        cout << (A * 3 + P) / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

signed main(){
    gok
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b &&a!=c || a==c&&a!=b || b==c&&b!=a)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

using namespace std;
/*int gcd(int a, int b) {
	int temp;
	if (a < b) swap(a, b);
	if (b < 1)return -1;
	if (a%b == 0)return b;
	return gcd(b, a%b);
}*/
ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int main() {
	speed;
	ll a, b;
	int c, d;
	cin >> a >> b >> c >> d;
	ll G = lcm(c, d);
	ll R = b / c;
	ll S = b / d;
	ll T = b / G;
	ll r = (a - 1) / c;
	ll s = (a - 1) / d;
	ll t = (a - 1) / G;

	ll ans = (b - (a - 1)) - ((R + S - T) - (r + s - t));
	cout << ans;
	ed;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    scanf("%d", &n);
    std::vector<int> a(1 << n);
    for (auto &e : a) scanf("%d", &e);
    std::vector<std::pair<int, int>> dp(1 << n, std::make_pair(-1, -1));
    for (int i = 0; i < (1 << n); i++) {
        dp[i].first = i;
    }
    for (int i = 0; i < n; i++) for (int j = 0; j < (1 << n); j++) {
        if (j & (1 << i)) {
            int k = j ^ (1 << i);
            if (a[dp[j].first] < a[dp[k].first]) {
                dp[j].second = dp[j].first;
                dp[j].first = dp[k].first;
            } else if (dp[j].second < 0 || a[dp[j].second] < a[dp[k].first]) {
                dp[j].second = dp[k].first;
            }

            if (dp[k].second >= 0 && a[dp[j].second] < a[dp[k].second]) {
                dp[j].second = dp[k].second;
            }
        }
    }

    int max = 0;
    for (int i = 1; i < (1 << n); i++) {
        max = std::max(max, a[dp[i].first] + a[dp[i].second]);
        printf("%d\n", max);
    }

    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<cmath>

using namespace std;

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

    int n = (int)log10(N);
    int c = 0;
    int ans = 0;
    while(c < n){
        ans += 9*pow(10,c);
        c+=2;
    }
    if(n%2 == 0){
        ans += N +1 -pow(10,n);
    }
    cout << ans <<endl;
    return 0;

}

Measured memory_bytes: 640
<?php

fscanf(STDIN, '%d %d', $N, $M);

$person = [];
for ($i = 1; $i <= $N; ++$i) {
    $person[$i] = explode(' ', fgets(STDIN));
}

$like = [];

for ($j = 1; $j <= $person[1][0]; ++$j) {
    $like[] =  str_replace(["\r\n", "\r", "\n"], '', $person[1][$j]);
}

for ($k = 2; $k <= $N; ++$k) {
    $new_like = [];
    for ($l = 1; $l <= $person[$k][0]; ++$l) {
        if (in_array(str_replace(["\r\n", "\r", "\n"], '', $person[$k][$l]), $like)) {
            $new_like[] = str_replace(["\r\n", "\r", "\n"], '', $person[$k][$l]);
        }
    }
    $like = $new_like;
}

echo count($like);


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
const int maxn=300005;
struct tree {
	int l,r,sum;
} t[maxn*4];
int a[maxn],f[maxn],n,m,ans;
void build(int id,int l,int r) {
	t[id].l=l,t[id].r=r;
	if(l==r) {
		return;
	}
	int mid=(l+r)/2;
	build(id*2,l,mid);
	build(id*2+1,mid+1,r);
}
void pushup(int id) {
	t[id].sum=max(t[id*2].sum,t[id*2+1].sum);
}
void add(int id,int v,int k) {
	if(t[id].l>v||t[id].r<v) {
		return;
	}
	if(t[id].l==t[id].r) {
		t[id].sum=max(t[id].sum,k);
		return;
	}
	add(id*2,v,k);
	add(id*2+1,v,k);
	pushup(id);
}
int ask(int id,int l,int r) {
	if(t[id].l>r||t[id].r<l) {
		return 0;
	}
	if(t[id].l>=l&&t[id].r<=r) {
		return t[id].sum;
	}
	int ans=max(ask(id*2,l,r),ask(id*2+1,l,r));
	pushup(id);
	return ans;
}
int main() {
	scanf("%d%d",&n,&m);
	build(1,0,maxn-5);
	for(register int i=1; i<=n; i++) {
		scanf("%d",&a[i]);
		f[i]=ask(1,max(a[i]-m,0),min(a[i]+m,maxn-5))+1;
		add(1,a[i],f[i]);
		ans=max(ans,f[i]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 18444
def e_neq(MOD=10**9 + 7):
    N, M = [int(i) for i in input().split()]

    class Combination(object):
        """素数 mod に対する二項係数の計算"""
        __slots__ = ['mod', 'fact', 'factinv']

        def __init__(self, argmax: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, argmax + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], -1, mod))
            for i in range(argmax, 0, -1):
                inv_append((inv[-1] * i) % mod)

            self.mod, self.fact, self.factinv = mod, fac, inv[::-1]

        def combination(self, n, r):
            return (0 if n < 0 or r < 0 or n < r else
                    self.fact[n] * self.factinv[r] * self.factinv[n - r] % self.mod)

        def permutation(self, n, r):
            return self.combination(n, r) * self.fact[r] % self.mod

    c = Combination(M)
    comb, perm = c.combination, c.permutation
    return sum(comb(N, k) * (-1)**k * perm(M, k) * perm(M - k, N - k)**2 for k in range(N + 1)) % MOD

print(e_neq())

Measured memory_bytes: 52348
W,H,N=list(map(int,input().split()))
ten=[list(map(int,input().split())) for _ in range(N)]
base=[[0,0,1],[0,0,3],[W,H,2],[W,H,4]]
ten.extend(base)
onemax=max(i[0] for i in ten if i[2]==1)
twomin=min(i[0] for i in ten if i[2]==2)
thrmax=max(i[1] for i in ten if i[2]==3)
foumin=min(i[1] for i in ten if i[2]==4)
if (twomin-onemax)>0 and (foumin-thrmax) >0:
    print((twomin-onemax)*(foumin-thrmax))
else:print(0)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int k;
    cin >> k;

    deque<Pii> que;
    que.push_front(Pii(1, 1));
    int used[k];
    fill(used, used+k, 0);
    while(!que.empty()){
        Pii p = que.front(); que.pop_front();
        if(p.second == 0){
            cout << p.first << endl;
            return 0;
        }
        used[p.second] = 1;
        if(!used[(p.second*10)%k]) que.push_front(Pii(p.first, (p.second*10)%k));
        if(!used[(p.second+1)%k]) que.push_back(Pii(p.first+1, (p.second+1)%k));
    }
    return 0;
}

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

using namespace std;

const int N = 15;
const int S = 1 << N;
inline void upd( int & a , int b ) { if( a < b ) a = b; }
int _w;

int f[N][S] , g[S] , G[N][N] , n , m , sum;

int main( void ) {
  _w = scanf("%d%d",&n,&m);
  for( int i = 1 , u , v , w ; i <= m ; ++i ) {
    _w = scanf("%d%d%d",&u,&v,&w); --u , --v;
    G[u][v] = G[v][u] = w;
    sum += w;
  }
  memset( g , 0xc0 , sizeof g );
  for( int i = 0 ; i < n ; ++i ) g[( 1 << i )] = 0;
  for( int s = 1 , tmp ; s < ( 1 << n ) ; ++s )
    if( g[s] >= 0 ) 
      for( int i = 0 ; i < n ; ++i ) 
        if( ( ~s >> i ) & 1 ) {
          tmp = 0;
          for( int j = 0 ; j < n ; ++j )
            if( ( ( s >> j ) ) & 1 && G[i][j] >= 0 )
              tmp += G[i][j];
          upd( g[s | ( 1 << i )] , g[s] + tmp );
        }
  memset( f , 0xc0 , sizeof f );
  f[0][1] = 0;
  for( int i = 0 ; i < n ; ++i )
    for( int j = 0 ; j < n ; ++j )
      if( !G[i][j] ) G[i][j] = -0x3f3f3f3f;
  for( int s = 0 ; s < ( 1 << n ) ; ++s )
    for( int i = 0 ; i < n ; ++i )
      if( f[i][s] >= 0 ) {
        for( int j = 0 ; j < n ; ++j )
          if( ( ( ~s >> j ) & 1 ) )
            upd( f[j][s | ( 1 << j )] , f[i][s] + G[i][j] );
        for( int cs = ( ( 1 << n ) - 1 ) ^ s , t = cs ; t ; t = ( t - 1 ) & cs )
          upd( f[i][s | t] , f[i][s] + g[t | ( 1 << i )] );
      }
  printf("%d\n",sum - f[n - 1][( 1 << n ) - 1] );
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
 
int dp[1111];
 
int main() {
  int n;
  cin >> n;
  P a[n];
  for(int i=0; i<n; i++) cin >> a[i].S >> a[i].F;
  sort(a,a+n);
  fill(dp,dp+n+1,1<<30);
  dp[0]=0;
  for(int i=0; i<n; i++) {
    for(int j=n-1; j>=0; j--) {
      if(dp[j]+a[i].S<=a[i].F) dp[j+1]=min(dp[j+1],dp[j]+a[i].S);
    }
  }
  int ans=0;
  for(int i=0; i<=n; i++) if(dp[i]!=1<<30) ans=i;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll x,money=100,year=0;
    cin>>x;
    while(money<x){
        year++;
        money+=money/100;
    }
    cout<<year<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define Maxn 110

int n, k, p, x, Rep[Maxn];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i=1; i<=k; i++)
	{
		scanf("%d", &p);
		for (int j=1; j<=p; j++) { scanf("%d", &x); Rep[x] = 1; }
	}
	int Count = 0; for (int i=1; i<=n; i++) if (!Rep[i]) Count++;
	printf("%d\n", Count);
}

Measured memory_bytes: 3800
//***********************
//*** writer : Alan Hu **
//***********************
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include<cstring>
#include<cmath>
using namespace std;
     
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
#define sz(a) a.size()
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
     
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int a,b;
	cin>>a>>b;
	if (a+b==15) cout<<"+";
	else if (a*b==15) cout<<"*";
	else cout<<"x";
    return 0;
}

Measured memory_bytes: 256
n=int(input())
L=[]
for i in range(n):
      a,b=map(int,input().split())
      L+=[[a,b]]
L.sort(key=lambda x:x[1])

sm=0
for i in range(n):
      sm+=L[i][0]
      if L[i][1]<sm:
            print("No")
            exit()
print("Yes")
      

Measured memory_bytes: 38040
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll a[100010];
int main()
{
	int N; ll X;
	cin >> N >> X;
	for (int i = 0; i < N; i++) cin >> a[i];
	ll ans = 0;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] + a[i + 1] > X) {
			ans += a[i] + a[i + 1] - X;
			a[i + 1] = max(0ll, a[i + 1] - (a[i] + a[i + 1] - X));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()[::-1]
    L = len(S)
    dp = [0] * 2019
    wk = 0
    r = 1
    for i in range(L):
        wk += int(S[i])*r
        wk %= 2019
        r *= 10
        r %= 2019
        dp[wk] += 1
    ret = dp[0]
    for i in range(2019):
        ret += dp[i]*(dp[i]-1)//2
    print(ret)


if __name__ == '__main__':
    main()

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

ll gcf(ll a, ll b){
    if(b == 0) return a;
    return gcf(b,a%b);
}
ll lcm(ll a, ll b){
    ll g = gcf(a,b);
    return a/g*b;
}

int main(){
    ll A,B,C,D; cin >> A >> B >> C >> D;
    ll CD;
    ll nC,nD,nCD;
    CD = lcm(C,D);
    
    ll ans = (B-A+1) - ( (B / C) - ((A-1)/C) + (B / D) - ((A-1)/D) - (B / CD) + ((A-1)/CD));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    char t;cin >> t;
    for(char c='a';c<='z';c++){
        if(c==t){
            cout << 'a' << endl;
            return 0;
        }
    }
    cout << 'A' << endl;
}//https://atcoder.jp/contests/abc171/tasks/abc171_a

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

long long C(long long n,long long r){
    if(r<0 || n<r) return 0;
    if(r==0||r==n) return 1;
    if(r==1) return n;

    return C(n,r-1)*(n-r+1)/r;
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    long long v[50];
    for(int i=0;i<N;i++) cin >> v[i];
    sort(v,v+N,greater<long long>());

    double ave=0;
    long long val;
    for(int i=0;i<A;i++) ave+=v[i];
    ave/=0.0+A;

    cout << fixed << setprecision(6) << ave << endl;
    val=v[A-1];

    int cnt=0,icnt=0;
    for(int i=0;i<A || v[i]==val;i++){
        if(v[i]==val) cnt++;
        if(v[i]==val && i<A) icnt++;
    }
    if(v[0]==val){
        long long r=0;
        for(int i=A;i<=B && v[i-1]==val;i++)r+=C(cnt,i);
        cout << r << endl;
    }else{
        cout << C(cnt,icnt) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int x,y,a,b,ans;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(i%2==0) 
		{
			if(s[i]=='0') x++;
			else y++;
		}
		else
		{
			if(s[i]=='0') a++;
			else b++;
		}
	}
	ans=max(a+y,b+x);
	cout<<s.size()-ans;
	return 0;
}

Measured memory_bytes: 512
def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))
    s, e = 0, 0
    ans = 0
    for i in range(N):
        if t[i] <= e:
            e = t[i] + T
        else:
            ans += e - s
            s = t[i]
            e = t[i] + T
    ans += e - s
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25196
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	vector<string> s(3);
	int a, b, c;
	cin >> a >> b >> c;
	if(b-a == c-b) puts("YES");
	else puts("NO");
 	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

void solve(){
  int N,X,T; cin>>N>>X>>T;
  int ans = ((N/X)+(N%X>0))*T; 
  cout << ans << "\n";
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S / 3600;
		int tmp = S % 3600;
		int m = tmp / 60;
		int s = tmp - m * 60;
		System.out.printf("%d:%d:%d\n", h, m, s);
	}
}



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

using namespace std;
typedef long long ll;

const int N = 2e6;
int t[N][2], lz[N][2];
ll n, q, a, w;

void build(int v, int l, int r) {
    t[v][0] = lz[v][0] = n;
    t[v][1] = lz[v][1] = n;
    if (l == r) {
        return;
    }
    int m = (l + r) >> 1;
    build(2 * v, l, m);
    build(2 * v + 1, m + 1, r);
}
void push(int v) {
    for (int i = 0; i < 2; i++) {
        t[v][i] = min(t[v][i], lz[v][i]);
        lz[2 * v][i] = min(lz[2 * v][i], t[v][i]);
        lz[2 * v + 1][i] = min(lz[2 * v + 1][i], t[v][i]);
    }
}
void upd(int v, int l, int r, int L, int R, int x) {
    if (R < l || r < L) {
        return;
    }
    if (L <= l && r <= R) {
        lz[v][w] = min(lz[v][w], x);
        push(v); return;
    }
    int m = (l + r) >> 1;
    upd(2 * v, l, m, L, R, x);
    upd(2 * v + 1, m + 1, r, L, R, x);
}
int find_min(int v, int l, int r, int L, int R) {
    push(v);
    if (L <= l && r <= R) {
        return t[v][w];
    }
    if (r < L || R < l) {
        return 1e9;
    }
    int m = (l + r) >> 1;
    return min(find_min(2 * v, l, m, L, R),
               find_min(2 * v + 1, m + 1, r, L, R));
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    ll r = (n - 2) * (n - 2);
    build(1, 1, n);
    while (q--) {
        cin >> w >> a; w--;
        int b = find_min(1, 1, n, a, a);
        r -= max(0, b - 2);
        w = 1 - w; upd(1, 1, n, 1, b - 1, a);
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 15952
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,X = mint()
x = lint()
x = [abs(i-X) for i in x]
D = x[0]
for i in x[1:]:
    D = gcd(D,i)
    if D==1:
        break
print(D)

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

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

  int64_t nFact = 1;
  for (int n = 1; n <= nNum; n++)
  {
    nFact *= n;
    nFact %= 1000000007;
  }

  cout << nFact << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

lint gcd(lint m,lint n){
  if(n==0)return m;
  else return gcd(n,m%n);
}

int main(){
  lint K;
  cin>>K;
  lint S=0;
  FOR(a,1,K+1)FOR(b,1,K+1)FOR(c,1,K+1){
    S+=gcd(a,gcd(b,c));
  }
  cout<<S<<endl;
  return 0;
}


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

int main (void){
	
	int p;
	char buff[256];
	char buff1[256];
	char buff2[256];
	
	scanf("%s",buff1);
	scanf("%s",buff2);
	strcpy(buff,buff1);
	strcat(buff,buff1);
		
	//printf("%s\n",buff);
	
	
	
	if(strstr(buff,buff2) == 0){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
return 0;
}

Measured memory_bytes: 540
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    X, N, *P = map(int, read().split())
    P = set(P)
    Q = [i for i in range(-10, 110) if i not in P]
    Q.sort()
    error = INF
    for q in Q:
        if abs(X-q) < error:
            ans = q
            error = abs(X-q)
    
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61768
#include <iostream>
using namespace std;
#define ll long long
int main()
{
   ll n;
   cin>>n;
   ll a[n+1];
   for(ll i=0;i<=n;i++){
       a[i]=i;
   }
   ll facnt[n+1]={0};
   for(ll i=1;i<=n;i++){
       for(ll j=i;j<=n;j+=i){
          facnt[j]++;
       }
   }
   ll ans=0;
   for(ll i=1;i<=n;i++){
       ans+=i*facnt[i];
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 159804
N, M = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

if N >= M:
    print(0)
elif N == 1:
    print(abs(max(X) - min(X)))
else:
    X.sort()
    X_ = [((j - i), c) for c, (i, j) in enumerate(zip(X, X[1:]))]
    X_s = sorted(X_, reverse=True)
    koma_c = sorted([t[1] for t in X_s[:N-1]])

    if koma_c[-1] != M-1:
        koma_c.append(M-1)

    p = 0
    c = 0
    for i in koma_c:
        c += X[i] - X[p]
        p = i + 1

    print(c)

Measured memory_bytes: 19728
#include<stdio.h>
#include<math.h>

int main(void)
{
	double x1,y1,x2,y2,r;
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	r=hypot((x2-x1),(y2-y1));
	printf("%8lf",r);
    return 0;
}

Measured memory_bytes: 2816
N = int(input())
S = input()
now = [0]
newS = ""
for s in S:
    if s == "(":
        now.append(now[-1] + 1)
    else:
        now.append(now[-1] - 1)
        
if min(now) < 0:
    newS += "(" * abs(min(now))
newS += S
if now[-1]+abs(min(now)) > 0:
    newS += ")" * (now[-1]+abs(min(now)))
print(newS)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

bool canput(const vvi& grid,int x,int y,int bw,int bh,int index)
{
	int h=grid.size(),w=grid[0].size();
	if(x<0 || w<x+bw || y<0 || h<y+bh)
		return false;
	bool flg=false;
	rep(i,bh) rep(j,bw){
		int cell=grid[y+i][x+j];
		if(cell!=-1 && cell!=index)
			return false;
		flg|=cell==index;
	}
	return flg;
}

void put(vvi& grid,int x,int y,int bw,int bh,int index)
{
	rep(i,bh) rep(j,bw)
		grid[y+i][x+j]=index;
}

vvi res;
int solve(vvi& grid,const vi& bs,const vi& ks,const vector<pii>& ps,int index)
{
	if(index==bs.size()){
		if(res.empty())
			res=grid;
		return 1;
	}
	
	int x=ps[index].first,y=ps[index].second;
	int area=ks[index];
	int res=0;
	repi(bh,1,area+1) if(area%bh==0){
		int bw=area/bh;
		rep(i,bh) rep(j,bw){
			int left=x-j,top=y-i;
			if(canput(grid,left,top,bw,bh,index)){
				put(grid,left,top,bw,bh,index);
				res+=solve(grid,bs,ks,ps,index+1);
				put(grid,left,top,bw,bh,-1);
				grid[y][x]=index;
			}
		}
	}
	return res;
}

int main()
{
	for(int w,h,n;scanf("%d%d%d",&w,&h,&n),w|h|n;){
		vi bs(n),ks(n);
		rep(i,n) scanf("%d%d",&bs[i],&ks[i]);
		
		vvi grid(h,vi(w));
		rep(i,h) rep(j,w) scanf("%d",&grid[i][j]);
		
		if(accumulate(all(ks),0)!=w*h){
			puts("NA");
			continue;
		}
		
		vector<pii> ps(n);
		rep(i,h) rep(j,w){
			if(grid[i][j]==0)
				grid[i][j]=-1;
			else{
				grid[i][j]=find(all(bs),grid[i][j])-bs.begin();
				ps[grid[i][j]]=mp(j,i);
			}
		}
		
		res.clear();
		int cnt=solve(grid,bs,ks,ps,0);
		if(cnt!=1)
			puts("NA");
		else
			rep(i,h) rep(j,w)
				printf("%d%c",bs[res[i][j]],j==w-1?'\n':' ');
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int main() {
    ll n, m;
    cin >> n >> m;
    ll a[m];
    ll sum = 0;
    rep(i, m, 0) {
        cin >> a[i];
        sum += a[i];
    }

    ll ans = n - sum;
    if (ans < 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#python3
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
md = len(bin(max(a)))-2
ans = 0
for d in range(md):
    cnt1 = sum([1 for i in a if ((i>>d)&1)]) 
    ans += cnt1 * (n-cnt1) * (1<<d)          
    ans %= mod                              
    
print(ans%mod)


Measured memory_bytes: 42156
s = input()
dp = [[0]*13 for _ in range(len(s))]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for k in range(len(s)-1):
    if s[k+1] == '?':
        for i in range(13):
            for j in range(10):
                dp[k+1][((i*10%13)+j)%13] += dp[k][i]
                dp[k+1][((i*10%13)+j)%13] %= (10**9+7)
    else:
        for i in range(13):
            dp[k+1][((i*10%13)+int(s[k+1]))%13] += dp[k][i]
            dp[k+1][((i*10%13)+int(s[k+1]))%13] %= (10**9+7)
print(dp[-1][5])


Measured memory_bytes: 61916
from itertools import permutations
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append(i+1)
dic= sorted(list(permutations(l,n)))
r=len(dic)
dicp=0
dicq=0
for x in range(r):
    dic[x]=list(dic[x])
    if dic[x]==p:
        dicp=x+1
    if dic[x]==q:
        dicq=x+1
print(max(dicp-dicq,dicq-dicp))


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main() {
        while (1) {
        int n, l;
        vector<int> a[2][2], b[2];
        map<int,int> mp;
        cin >> n >> l;
        if (n == 0) break;
        REP(i,2)a[i][0].push_back(0);
        REP(i,n){
            string d;
            int p;
            cin >> d >> p;
            a[p%2][d=="L"?0:1].push_back(p);
            b[p%2].push_back(p);
            mp[p] = i+1;
        }
        REP(i,2)a[i][1].push_back(l);
        int tmax[2]{}, pi[2], L=0, R=1;
        bool f[2]{};
        REP(i,2){
            if(b[i].size()==0)continue;
            if(l - a[i][R][0] > *--a[i][L].end()){
                tmax[i] = l - a[i][R][0];
                pi[i] = b[i][b[i].size()-a[i][R].size()+1];
            }
            else{
                tmax[i] = *--a[i][L].end();
                pi[i] = b[i][a[i][L].size()-2];
                f[i] = true;
            }
        }
        if(tmax[0] > tmax[1]){
            cout << tmax[0] << " " << mp[pi[0]] << endl;
        }
        else if(tmax[0] < tmax[1]){
            cout << tmax[1] << " " << mp[pi[1]] << endl;
        }
        else if(f[0]){
            cout << tmax[0] << " " << mp[pi[0]] << endl;
        }
        else {
            cout << tmax[1] << " " << mp[pi[1]] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3156
A,B,C,D,E,F=map(int,input().split())

ans=0
Wit=A*100
Cnc=0

for a in range(30):
    if a*A>30:
        break
    for b in range(31):
        if b*B>30:
            break
        for c in range(3000):
            if a*A*100+b*B*100+c*C>F:
                break
            for d in range(3000):
                if 0<a*A*100+b*B*100+c*C+d*D>F:
                    break
                else:
                    if a==0 and b==0:
                        pass
                    else:
                        if (c*C*100+d*D*100)<=E*(a*A*100+b*B*100):
                            if ans<((c*C*100+d*D*100)/(a*A*100+b*B*100)):
                                ans=((c*C*100+d*D*100)/(a*A*100+b*B*100))
                                Wit=(a*A*100+b*B*100+c*C+d*D)
                                Cnc=(c*C+d*D)
                  #print(c,d)
print(Wit,Cnc)

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,k;cin>>n>>k;
  vector<int> a(n);
  vector<ll> s(n + 1);
  for(int i=0;i<n;i++){
    cin>>a[i];
    s[i + 1] = (s[i] + a[i] - 1 + k) % k;
  }
  ll ans=0;
  map<ll,ll> mp;
  for(int i=0;i<=n;i++){
    if(i-k>=0)mp[s[i-k]]--;
    ans += mp[s[i]];
    mp[s[i]]++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 15104
def main():
    a,b,k = list(map(int,input().split(' ')))
    cnt = 0
    for i in range(min(a,b),0,-1):
        if a%i ==0 and b %i ==0:
            cnt += 1
        if cnt ==k:
            print(i)
            break

if __name__ == '__main__':
    main()

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

main() {
  int n,k;
  cin >> n >>k;
  int sum;
  
  for(int i =0;i < n;i++) {
    int x;
    cin >> x;
    sum += min(x,k-x);
  }
  cout << sum*2 <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

#define	mp	make_pair

using namespace std;

typedef	pair<int,bool>	pib;

int main(){
	for(int n;scanf("%d",&n),n;){
		static pib event[20000];
		for(int i=0;i<n;i++){
			for(int j=0;j<2;j++){
				int h,m,s;	scanf("%d%*c%d%*c%d",&h,&m,&s);
				event[2*i+j]=mp(3600*h+60*m+s,!j);	// departure: 1, arrival: 0
			}
		}

		sort(event,event+2*n);

		int train=0,maxtrain=0;
		for(int i=0;i<2*n;i++){
			if(event[i].second)	train++;
			else	train--;
			maxtrain=max(maxtrain,train);
		}

		printf("%d\n",maxtrain);
	}

	return 0;
}

Measured memory_bytes: 928
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <tuple>

using namespace std;

typedef vector<vector<char> > Field;
typedef vector<vector<bool> > LocationMap;
typedef pair<int, int> Location;
typedef pair<Location, int> LocationLevel;
typedef queue<LocationLevel> LocationQueue;

inline int solve(int h, int w, Field &field, LocationQueue &que, LocationMap& visited) {
  /*
  cout << h << " " <<  w << " " << endl;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << field[i][j];
    }
    cout << endl;
  }
  */
  LocationLevel loc_lev;
  Location loc;
  Location nloc;
  int i, j, level;
  int max_level = 0;
  int dx[4] = {-1, 1, 0, 0};
  int dy[4] = { 0, 0, 1,-1};

  while(que.size()){
    loc_lev = que.front(); que.pop();
    loc = loc_lev.first;
    level = loc_lev.second;

    for(int n = 0; n < 4; n++){
        i = loc.first  + dx[n];
        j = loc.second + dy[n];

        if (i >= 0 && i <= h - 1 && j >= 0 && j <= w -1) {
          nloc = make_pair(i,j);
          if( !visited[i][j] && (field[i][j] == '.') ){
            field[i][j] = '#';
            visited[i][j] = true;
            que.push(make_pair(nloc, level + 1));
            if( level + 1 > max_level ){ max_level = level + 1; }
          }
        }
    }
  }

  return max_level;
}

int main(int argc, char const *argv[]) {
  int h, w;
  char c;
  Field field;
  LocationQueue que;
  LocationMap visited;

  cin >> h;
  cin >> w;

  for (int i = 0; i < h; i++) {
    vector<char> row;
    vector<bool> brow;
    for (int j = 0; j < w; j++) {
      cin >> c;
      row.push_back(c);
      if (c == '#') {
        que.push(make_pair(make_pair(i, j), 0));
        brow.push_back(true);
      } else {
        brow.push_back(false);
      }
    }
    field.push_back(row);
    visited.push_back(brow);
  }

  cout << solve(h, w, field, que, visited);

  return 0;
}


Measured memory_bytes: 13312
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var a = int.Parse(ReadLine());
            var b = int.Parse(ReadLine());

            WriteLine((n - a) % b);
        }
    }
}



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

int main(){
    int W,H,x,y,r;
    
    cin >> W >> H >> x >> y >> r;
    
    if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<P> a(n);
    rep(i,n) cin>>a[i].second>>a[i].first;
    sort(begin(a),end(a));
    ll now=0;
    rep(i,n){
      now+=a[i].second;
      if(now>a[i].first){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

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

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int q;
	cin >> q;
	vll ans;
	rep(i, q) {
		ll a, b;
		cin >> a >> b;
		ll c = sqrt(a * b);
		ll _ans = 2 * c - 1;
		if(c * (c + 1) >= a * b) _ans--;
		if(c * c == a * b && a != b) _ans--;
		ans.push_back(_ans);
	}
	for(auto i: ans) cout << i << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		ArrayList<Integer> primes = primes(110000);
		while (true) {
			int N = sc.nextInt();
			int P = sc.nextInt();
			if (N == -1) break;
			int pos = 0;
			while (primes.get(pos) <= N) {
				++pos;
			}
			ArrayList<Integer> sum = new ArrayList<Integer>();
			for (int i = 0; i < 100; ++i) {
				for (int j = 0; j <= i; ++j) {
					sum.add(primes.get(pos + i) + primes.get(pos + j));
				}
			}
			Collections.sort(sum);
			System.out.println(sum.get(P - 1));
		}
	}

	static ArrayList<Integer> primes(int max) {
		if (max < 2) {
			return new ArrayList<Integer>();
		}
		BitSet primeSet = new BitSet(max / 2);
		primeSet.set(1, max / 2);
		int limit = (int) Math.sqrt(max);
		for (int i = 3; i <= limit; i += 2) {
			if (!primeSet.get(i / 2)) {
				continue;
			}
			for (int j = i * i; j < max; j += i * 2) {
				primeSet.clear(j / 2);
			}
		}
		ArrayList<Integer> list = new ArrayList<Integer>();
		list.add(2);
		for (int i = primeSet.nextSetBit(0); i >= 0; i = primeSet.nextSetBit(i + 1)) {
			list.add(i * 2 + 1);
		}
		return list;
	}

}

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

int main() {
  char num[5];
  cin >> num;
  char tmp = '0';
  int cnt = 1;
  for(int i = 0; i < 4; i++) {
    if(num[i] == tmp) {
      cnt += 1;
      if(cnt >= 3)
        break;
    }
    else {
      cnt = 1;
      tmp = num[i];
    }
  }
  if(cnt >= 3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
h = list(map(int, input().split()))
observatories = [[] for i in range(n)]
ans = 0
for i in range(m):
  ab = list(map(int, input().split()))
  a = ab[0] - 1
  b = ab[1] - 1
  observatories[a].append(b)
  observatories[b].append(a)
for j in range(len(observatories)):
  ans = ans + 1
  h_j = h[j]
  for k in observatories[j]:
    if h[k] >= h_j:
      ans = ans - 1
      break
print(ans)

Measured memory_bytes: 94644
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main() {
    long[] ans = new long[31];
    ans[0] = 1;
    foreach(i; 1..31) {
        ans[i] += ans[i-1];
        if (i>1) ans[i] += ans[i-2];
        if (i>2) ans[i] += ans[i-3];
    }
    while(true) {
        int n = readln.chomp.to!int;
        if (n==0) break;
        writeln(((ans[n]+1)/10+1)/365+1);
    }
}

Measured memory_bytes: 2436
A = [list(map(int, input().split())) for i in range(3)]
B = [[0]*3 for i in range(3)]
n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = 1
if any([all([B[i][j] == 1 for j in range(3)]) for i in range(3)]):
    print('Yes')
    exit()
if any([all([B[i][j] == 1 for i in range(3)]) for j in range(3)]):
    print('Yes')
    exit()
if B[0][0]*B[1][1]*B[2][2] == 1:
    print('Yes')
    exit()
if B[0][2]*B[1][1]*B[2][0] == 1:
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 3064
#C問題
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

count = 0
for i in range(N):
    if A[i] <= B[i]:
        count+=A[i]
        if B[i]-A[i] >= A[i+1]:
            count+=A[i+1]
            A[i+1] = 0
        else:
            A[i+1]-=(B[i]-A[i])
            count+=(B[i]-A[i])
        A[i] = 0
        
    else:
        A[i]-=(B[i])
        count+=B[i]
        
print(count)

Measured memory_bytes: 18476
#![allow(non_snake_case)]
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        N: usize,
        mut As: [usize; N-1],
    }

    // 0-origin
    for a in As.iter_mut() {
        *a -= 1;
    }

    // 直属の部下の人数
    let mut members_cnt_map: HashMap<usize, i64> = HashMap::new();

    for a in As.iter() {
        if members_cnt_map.contains_key(&a) {
            let cnt: &mut i64 = members_cnt_map.get_mut(a).unwrap();
            *cnt += 1;
        } else {
            members_cnt_map.insert(*a, 1);
        }
    }

    for i in 0..N {
        println!("{}", members_cnt_map.get(&i).unwrap_or(&0));
    }
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int N = 0;  // 青いカードの枚数
	int M = 0;  // 赤いカードの枚数
	int answer = 0;

	cin >> N;
	string cur_n;
	map<string, int> blue_cards_map;
	for (int i = 0; i < N; i++) {
		cin >> cur_n;
		if (blue_cards_map.find(cur_n) == blue_cards_map.end()) {
			blue_cards_map[cur_n] = 1;
		} else {
			blue_cards_map[cur_n] += 1;
		}
	}

	cin >> M;
	for (int j = 0; j < M; j++) {
		cin >> cur_n;
		if (blue_cards_map.find(cur_n) != blue_cards_map.end()) {
			blue_cards_map[cur_n] -= 1;
		}
	}

	int max_score = INT_MIN;
	for (auto p: blue_cards_map) {
		if (max_score <= p.second) {
			max_score = p.second;
		}
	}
	cout << ((max_score >= 0) ? max_score : 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
   
int main(void){
   
    int a, b;
  
    scanf("%d %d", &a, &b);
   
    if(a >= -1000, b <= 1000){
   
        if(a < b){
           
            printf("a < b\n");
        }
        else if(a > b){
   
            printf("a > b\n");
        }
        else{

            printf("a == b\n");
        }

    }

    return 0;
}

Measured memory_bytes: 2612
def main():
    from sys import stdin, stdout

    def read():
        return stdin.readline().rstrip('\n')

    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)

    def read_int():
        return int(read())

    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]

    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)

    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)

    N = read_int()
    citites = []
    for i in range(N):
        name, score = read_array()
        score = int(score)
        citites.append((name, -score, i))
    citites.sort()
    for _, _, i in citites:
        write(i+1)


main()


Measured memory_bytes: 38384