akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int N=300000;
const ll INF=LLONG_MAX/3;
ll pre[N];
ll suf[N];

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

    int m=3*n;
    vector<ll> a(m);
    rep(i,m) scanf(" %lld", &a[i]);

    fill(pre,pre+N,0);
    fill(suf,suf+N,INF);

    ll s=0;
    multiset<ll> x;
    rep(i,n)
    {
        s+=a[i];
        x.insert(a[i]);
    }

    pre[n-1] = s;
    for(int i=n; i<2*n; ++i)
    {
        ll min_x = *x.begin();
        if(a[i]>min_x)
        {
            s = s-min_x+a[i];

            auto itr = x.begin();
            x.erase(itr);
            x.insert(a[i]);
        }

        pre[i] = s;
    }

    s=0;
    x.clear();
    for(int i=2*n; i<m; ++i)
    {
        s+=a[i];
        x.insert(a[i]);
    }

    suf[2*n]=s;
    for(int i=2*n-1; i>=n; --i)
    {
        ll max_x = *x.rbegin();
        if(a[i]<max_x)
        {
            s = s-max_x+a[i];

            auto itr = x.find(max_x);
            x.erase(itr);
            x.insert(a[i]);
        }

        suf[i]=s;
    }

    ll ans=-INF;
    for(int i=n-1; i<2*n; ++i) ans = max(ans, pre[i] - suf[i+1]);
    printf("%lld\n", ans);
    return 0;
}


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

int main()
{
    int x, n;
    cin >> x >> n;
    set<int> s;
    int ans;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        s.insert(t);
    }
    for (int i = 0; 1; i++)
    {
        if (s.count(x - i) == 0)
        {
            ans = x - i;
            break;
        }
        if (s.count(x + i) == 0)
        {
            ans = x + i;
            break;
        }
    }
    cout << ans << endl;
}


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

int main(void)
{
  int n,m;
  int p;
  char s[3];
  char *buf_ac = NULL;
  int  *buf_wa = NULL;
  int  sum_ac =0;
  int  sum_wa =0;
  
  scanf("%d %d", &n, &m);

  buf_ac = (char *)calloc(n, sizeof(char));
  buf_wa = (int *)calloc(n, sizeof(int));
  
  for (int i=0; i<m; i++){
    scanf("%d %s", &p, s);
    
    if (s[0] == 'A') {
      buf_ac[p-1] = 1;
    } else {
      if (buf_ac[p-1] == 0) {
        buf_wa[p-1]++;
      }
    }
  }
  
  for (int i=0; i<n; i++) {
	if (buf_ac[i] == 1) {
		sum_ac++;
		sum_wa += buf_wa[i];
	}
  }
  
  printf("%d %d\n", sum_ac, sum_wa);
    
  
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

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

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, long long M) {
  ll t = M * 1900 + (N - M) * 100;
  ll n = pow(2, M);
  ll ans = t * n;
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long M;
  long long N;
  cin >> N;
  cin >> M;
  solve(N, M);
  return 0;
}


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

int main() {
	pair<pair<string, int>, int> p[110];
	int n; cin >> n;
	string name;
	int point;

	for (int i = 0; i < n; i++) {
		cin >> name >> point;
		p[i] = make_pair(make_pair(name, -point), i);
	}

	sort(p, p + n);

	for (int i = 0; i < n; i++) cout << p[i].second + 1 << endl;;

	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;

    cin>>n;
    int cnt=0;
    for(int i=1;i<=n/2;i++)
    {
        int x=i;
        int y=n-i;
        if(x!=y)cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    
    ll a,b,c,k; cin >> a >> b >> c >> k;
    ll ans = 0;
    if(a<=k){
        ans+=a;
        k-=a;
    }
    else{
        cout << k;
        return;
    }
    if(b<=k){
        k-=b;
    }
    else{
        cout << ans;
        return;
    }
    cout << ans - k;
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int R = scanner.nextInt();
		
		if((0 <= R)&&(R < 1200)) {
			System.out.println("ABC");
		}else if ((1200 <= R)&&(R < 2800)) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}

	}

}

Measured memory_bytes: 21844
from collections import defaultdict
N,Q = map(int,input().split())
d = defaultdict(list)

for _ in range(N-1):
    a,b = map(int,input().split())
    d[a].append(b)
    d[b].append(a)

c = defaultdict(int)

for _ in range(Q):
    p,x = map(int,input().split())
    c[p] += x

ans = [0 for i in range(N)]
que = [(1,0,-1)]
while len(que)>0:
    tmp = []
    for v,x,par in que:
        x += c[v]
        ans[v-1] = str(x)
        for w in d[v]:
            if w != par:
                tmp.append((w,x,v))
    que = tmp

print(' '.join(ans))


Measured memory_bytes: 104544
N = int(input())
h = list(map(int,input().split()))
cost = [10**9]*N
cost[0] = 0
cost[1] = abs(h[1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])

Measured memory_bytes: 20512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

struct Node{
    Node *to[2];
    Node(){to[0] = to[1] = NULL;}
};
int n, l;

void add(Node *t, string &s, int k){
    if(k == s.size()) return;
    int c = s[k] - '0';
    if(t -> to[c] == NULL) t ->  to[c] = new Node();
    add(t -> to[c], s, k + 1);
}

int dfs(Node *t, int k){
    int ret = 0, cnt = 0;
    rep(i, 0, 2){
        if(t -> to[i] != NULL){
            ret ^= dfs(t -> to[i], k + 1);
            cnt++;
        }
    }
    if(cnt == 1){
        int h = l - k;
        ret ^= h & -h;
    }
    return ret;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> l;
    Node *root = new Node();
    rep(i, 0, n){
        string s;
        cin >> s;
        add(root, s, 0);
    }
    if(dfs(root, 0)) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}

Measured memory_bytes: 8044
N=int(input())
A=list(map(int,input().split()))+[0]
A.insert(0,0)
cost=0
for i in range(N+1):
    cost+=abs(A[i+1]-A[i])
for i in range(1,N+1):
    print(cost-abs(A[i+1]-A[i])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 14048
use proconio::input;

fn main() {
    input!(n: usize, a: [u32; n], b: [u32; n]);
    let mut ans = 0;
    for k in 0..29 {
        let two_pow_k = 1 << k;
        let mut b: Vec<_> = b.iter().map(|&x| x % (2 * two_pow_k)).collect();
        b.sort();
        let lower_bound = |x: u32| {
            if x <= b[0] {
                0
            } else {
                let mut l = 0;
                let mut r = b.len();
                while 1 < r - l {
                    let c = (l + r) / 2;
                    if b[c] < x {
                        l = c;
                    } else {
                        r = c;
                    }
                }
                r
            }
        };
        let mut cnt = 0;
        for x in a.iter().map(|&x| x % (2 * two_pow_k)) {
            for ph in (1..=4).rev() {
                let l = lower_bound((ph * two_pow_k).saturating_sub(x));
                if ph % 2 == 0 {
                    cnt += l;
                } else {
                    cnt -= l;
                }
            }
        }
        ans += (1 << k) * (cnt % 2);
    }
    println!("{}", ans);
}


Measured memory_bytes: 8552
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

string S,T,SS,TT;
int main(){
    cin >> S >> T;
    vector<char> s,t;
    rep(i,sz(S)) s.pb(S[i]);
    rep(i,sz(T)) t.pb(T[i]);
    sort(ALL(s)), sort(ALL(t));
    
    rep(i,sz(s)) SS += s[i];
    rep(i,sz(t)) TT += t[sz(t)-1-i];
    
    if(TT <= SS) cout << "No" << endl;
    else cout << "Yes" << endl;
    
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/08/10.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int p;

ll modpow(ll x, ll a){
    ll ans=1;
    while(a){
        if(a&1) ans=ans*x%p;
        a>>=1;
        x=x*x%p;
    }
    return ans;
}

ll inv(ll x){
    return modpow(x,p-2);
}

void pls(vector<int> &a, vector<int> &b){
    for(int i=0;i<p;i++){
        a[i]=(a[i]+b[i])%p;
    }
}

void mul(vector<int> &a, int t){
    for(int i=0;i<p;i++) a[i]=a[i]*t%p;
}

void mulxt(vector<int> &a, int t){
    vector<int> b(p);
    b[0]=(p+t)*a[0]%p;
    for(int i=1;i<p;i++){
        b[i]=((p+t)*a[i]+a[i-1])%p;
    }
    a=b;
}

int main(){
    cin >> p;
    vector<int> a(p);
    for(int i=0;i<p;i++) cin >> a[i];
    vector<vector<int>> f(p,vector<int>(p,0));
    f[0][0]=1;
    for(int i=1;i<p;i++){
        f[i]=f[i-1];
        mulxt(f[i],-i+1);
    }
    for(int i=0;i<p;i++){
        int tmp=1;
        for(int j=0;j<p;j++){
            if(j!=i) tmp=tmp*(i-j+p)%p;
        }
        mul(f[i], a[i]*inv(tmp));
    }
    for(int i=1;i<p;i++){
        mulxt(f[i-1],-i);
        pls(f[i],f[i-1]);
    }
    for(int i=0;i<p;i++){
        cout << f[p-1][i] << " ";
    }
    cout << endl;
    return 0;
}


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

int main()
{
	double a,Max,Min;
	bool flag  = true;
	while(cin >> a)
	{
		if(flag)
		{
			Max = a;
			Min = a;
			flag = false;
		}
		else
		{
			Max = max(Max,a);
			Min = min(Min,a);
		}
	}

	cout << Max - Min << endl;
	return 0;
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict

H,W=map(int, sys.stdin.readline().split())
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(1,0),(-1,0),(0,1),(0,-1)]

def bfs(start):
    Visit={}
    q=deque()
    q.append(start)
    Visit[start]=1
    L=defaultdict(lambda: 0)    #距離

    while q:
        fro_x,fro_y=q.popleft()
        for dx,dy in D:
            to_x=fro_x+dx
            to_y=fro_y+dy
            if 0<=to_x<H and 0<=to_y<W:
                if S[to_x][to_y]=="." and (to_x,to_y) not in Visit:
                    Visit[to_x,to_y]=1
                    L[(to_x,to_y)]=L[(fro_x,fro_y)]+1
                    q.append((to_x,to_y))

    return max(L.values())

ans=0
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            ans=max(ans,bfs((h,w)))

print ans


Measured memory_bytes: 34024
#include <stdio.h>
int main(){

	float a,b,c,d,e,f;
	float x,y;

	for(;scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF;){
//printf("%f %f %f %f %f %f",a,b,c,d,e,f);
		x=(-e*c+b*f)/(-a*e+b*d);
		if(x<0.0005 && x>=-0.0005)x=0.0;
//printf("%.3f\n",x);
//printf("%.3f\n",x);
		y=(+d*c-a*f)/(-a*e+b*d);
		if(y<0.0005 && y>=-0.0005)y=0.0;
//printf("%.3f\n",y);
//		y=y/(-a*e+b*d);
//printf("%.3f\n",y);
		printf("%.3f %.3f\n",x,y);
	}

	return 0;
}

Measured memory_bytes: 648
/* ABC-A.c
   Yuta Takayanagi */

#include<stdio.h>
#define NUMBER 100
int main(void){
    int number, x, length[NUMBER], d, count, i;

    d = 0;
    count = 1;

    scanf( "%d %d" , &number, &x); /* 2つの値n,xを入力 */

    for(i=0; i < number; i++){

        scanf( "%d" , &length[i]); /* L_iを入力 */

        d += length[i];

        if(d<=x){

            count += 1;

        }

    }

    printf( "%d\n" , count);

    return 0;

}

Measured memory_bytes: 128
#include<stdio.h>

int shakkin(int);

int main(){
	int n,henkin;
	scanf("%d",&n);
	henkin=shakkin(n);
	printf("%d\n",henkin);
	return 0;
}

int shakkin(int n){
	int m=100000,i;
	double rishi=0.05;
	for(i=0;i<n;i++){
		m*=(1+rishi);
		if(m%1000>0){
			m=m-m%1000;
			m+=1000;
		}
	}
	return m;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

#define N 86410

int max(int a,int b){
	if(a>=b)return a;
	else return b;
}

int changeTime(int h,int m,int s){
	return 3600*h+60*m+s;
}

int main(){

	int n;

	int data[N];
	
	while(cin>>n){
		if(n==0)break;

		int h,m,s;
		char tmp;
		int ans=0;
		for(int i=0;i<N;i++)data[i]=0;
		for(int i=0;i<n;i++){
			cin>>h>>tmp>>m>>tmp>>s;

			data[changeTime(h,m,s)]++;

			cin>>h>>tmp>>m>>tmp>>s;
			data[changeTime(h,m,s)]--;
		}

		for(int i=1;i<N;i++){
			data[i] += data[i-1];
			ans = max(data[i],ans);
		}

		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1496
#include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<vector<int>> v(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> v[i][j];
    }
  }
  vector<vector<int>> con = {
  {0,0,0},
  {0,0,0},
  {0,0,0},
};
  int n;
  cin >> n;
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> b[i];
  }

  for(int a=0;a<n;a++){
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(b[a]==v[i][j]){
          con[i][j]=1;
        }
      }
    }
  }
  
int check=0;
  if(con[0][0]*con[0][1]*con[0][2]==1){check=1;}
  if(con[1][0]*con[1][1]*con[1][2]==1) {check=1;}
  if(con[2][0]*con[2][1]*con[2][2]==1) {check=1;}
  if(con[0][0]*con[1][0]*con[2][0]==1) {check=1;}
  if(con[0][1]*con[1][1]*con[2][1]==1) {check=1;}
  if(con[0][2]*con[1][2]*con[2][2]==1) {check=1;}
  if(con[0][0]*con[1][1]*con[2][2]==1) {check=1;}
  if(con[2][0]*con[1][1]*con[0][2]==1) {check=1;}
  if(check==1){cout << "Yes" << endl;}
  else{
    cout << "No" << endl;
  }
}


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

using namespace std;

bool next(vector<int>& orig) {
    for (int i = 0; i < orig.size(); ++i) {
        if (++orig[i] <= 3) {
            return true;
        }
        orig[i] = 0;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);

    int r, g, b, K;
    cin >> r >> g >> b >> K;

    vector<int> choice(K);
    while (next(choice)) {
        vector<int> cards {r, g, b};
        for (int c : choice) {
            cards[c - 1] *= 2;
            //cerr << cards[0] << "," << cards[1] << "," << cards[2] << endl;

            if (cards[1] > cards[0] && cards[2] > cards[1]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        //cerr << "--------" << endl;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3652
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.Char
import Data.IORef

toTriple :: B.ByteString -> (Int, Int, Int)
toTriple bs =
    let
        Just (a, bs') = B.readInt bs
        Just (b, bs'') = B.readInt $ B.dropWhile isSpace bs'
        Just (c, _) = B.readInt $ B.dropWhile isSpace bs''
    in
        (a, b, c)

f :: (Int, Int, Int) -> (Int, Int) -> (Int, Int)
f (x,y,h) (cx,cy) = (k,h)
    where
        k = (abs $ cx - x) + (abs $ cy - y) + h 

main = do
    n <- readLn :: IO Int
    xyh <- replicateM n (toTriple <$> B.getLine) :: IO [(Int, Int, Int)]
    forM_ [0..100] $ \i ->
        forM_ [0..100] $ \j -> do
            let xs = filter (\(_,h) -> h/=0) $ map (flip f (i,j)) xyh
            unless (null xs) $ do
                let (k,_) = head xs
                let res = and $ map (\(x,y,h) -> (max (k-(abs$i-x)-(abs$j-y)) 0) == h) xyh
                when res $ do
                    putStr $ show i ++ " "
                    putStr $ show j ++ " "
                    putStrLn $ show k 

Measured memory_bytes: 1020
var Point = (function () {
  function Point(input) {
    this.x = Number(input[0]);
    this.y = Number(input[1]);
  }
  Point.prototype.getMinManhattanDistance = function(points) {
    var _this = this;
    var minDistance;
    var mostMinIndex = 0;
    points.forEach(function(p, i) {
      var d = Math.abs(_this.x - p.x) + Math.abs(_this.y - p.y);
      if (minDistance === undefined || minDistance > d) {
        mostMinIndex = i;
        minDistance = d;
      }
    });
    return mostMinIndex + 1;
  };
  return Point;
}());

function main(input) {
  var lines = input.split("\n");
  var peopleCount = Number(lines[0].split(" ")[0]);
  var checkPointCount = Number(lines[0].split(" ")[1]);

  var students = [];
  for (var i = 1; i < peopleCount + 1; i++){
    students.push(new Point(lines[i].split(" ")));
  }

  var checkPoints = [];
  for (var i = 1 + peopleCount; i < peopleCount + checkPointCount + 1; i++){
    checkPoints.push(new Point(lines[i].split(" ")));
  }

  students.forEach(function(s) {
    console.log(s.getMinManhattanDistance(checkPoints));
  });
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int N = 0, A = 0; cin >> N >> A;
  
  if(N%500 <= A) {
    cout << "Yes" <<endl;
  }else if(N%500 == 0) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 3592
N = gets.to_i
H = []
HH = gets
for i in 0..N-1
  H[i] = HH.split(" ")[i].to_i
end

count = 1
for j in 1..N-1
  max_num = H.slice(0,j).max
  if H[j] >= max_num
    count += 1
  end
end

puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
vector<string>v;
vector<int>ansl;
string s;
int ary[100005] = {0};
int mp[51][51];
int cnt = 0;
int d_x[] = {0,1,0,-1};
int d_y[] = {1,0,-1,0};
int W,H;

void dfs(int x,int y){
  mp[y][x] = 0;
  for(int dx = -1;dx<2;dx++){
    for(int dy = -1;dy<2;dy++){
    int nx = x+dx,ny = y+dy;
    if((nx>=0)&&(ny>=0)&&(ny<H)&&(nx<W)&&(mp[ny][nx] == 1)){
      dfs(nx,ny);
    }
  }
}
}
int main(){
  int A,B;
  string ans = "Yay!";
  cin >>A>>B;

  if((max(A-B,B-A))>(16-A-B))ans = ":(";
  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

vector<vector<int>> G;
vector<ll> s;

void dfs(int v,int p=-1){
    if(v!=0) s[v]+=s[p];
    for(auto nv : G[v]){
        if(nv==p) continue;
        dfs(nv,v);
    }
}

int main() {
    int n,q;
    cin>>n>>q;
    G.resize(n);
    s.resize(n);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int p;
        ll x;
        cin>>p>>x;
        p--;
        s[p]+=x;
    }

    dfs(0);

    rep(i,n) cout<<s[i]<<" ";
    cout<<endl;

}




Measured memory_bytes: 24320
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int A[3];
	for (int i = 0; i < 3; ++i) scanf("%d", &A[i]);
	sort(A, A + 3);
	printf("%d\n", A[2] - A[0]);
	return 0;
}

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


int main() {

  long long int m, k;
  cin >> m >> k;

  if ( m == 0 ) {
    if ( k == 0 ) {
      cout << "0 0" << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  if ( m == 1 ) {
    if ( k == 0 ) {
      cout << "0 0 1 1" << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  long long int n = 1LL << m;

  if ( k >= n ) {
    cout << -1 << endl;
    return 0;
  }
  cout << k;
  for ( long long int i = 0; i < n; i++ ) {
    if ( i == k ) continue;
    cout << " " << i;
  }
  cout << " " << k;
  for ( long long int i = n - 1; i >= 0; i-- ) {
    if ( i == k ) continue;
    cout << " " << i;
  }

  return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;

int main(){

    double N;

    cin >> N;

    vector<double > a(N,0);
    double ans = 0;
    for(ll i = 0; i < N; i++){
        cin >> a[i];
        //cout << a[i] << endl;
        ans += 1/a[i];
    }
    
    cout << 1 / ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
int dp[3003][3003][2],n,m;
int main(){
    cin>>s>>t;
    n=s.length(),m=t.length();
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(!i||!j) dp[i][j][0]=0,dp[i][j][1]=-1;
            else if(s[i-1]==t[j-1]){
                dp[i][j][0]=1+dp[i-1][j-1][0];
                dp[i][j][1]=3;
            }
            else if(dp[i-1][j][0]>dp[i][j-1][0]){
                dp[i][j][0]=dp[i-1][j][0];
                dp[i][j][1]=1;
            }
            else{
                dp[i][j][0]=dp[i][j-1][0];
                dp[i][j][1]=2;
            }
        }
    }
    string k="";
    int i=n,j=m;
    while(i&&j){
        if(dp[i][j][1]==3){
            k+=s[i-1];
            i-=1,j-=1;
        }
        else if(dp[i][j][1]==1) i-=1;
        else j-=1;
    }
    reverse(k.begin(),k.end());
    if(k.length()==0) cout<<" ";
    else cout<<k;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    long long p[N];
    int cnt=1;
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    long long min=p[0]; 
    for (int i = 1; i < N; ++i) {
        if (min > p[i]) {
            min = p[i];
            cnt++;
        }
    }
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 1792
N,*S = `dd`.split
U = []; D = []
S.each{ |s|
  net = 0
  min = 0
  s.chomp.chars.each{ |c|
    net += c == ")" ? -1 : +1
    min = net if net < min
  }
  if net >= 0
    U << [min, net]
  else
    D << [min - net, -net]
  end
}

ua,da = [U,D].map{ |ss|
  ss.sort_by!{ |a,b| -a }
  x = 0
  ss.each{ |a,b|
    if x + a < 0
      puts "No"; exit
    end
    x += b
  }
  x
}
puts ua == da ? "Yes" : "No"



Measured memory_bytes: 153888
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	ll A, B;
	cin >> A >> B;
	ll num = 1;
	ll anum = 0;
	while (num < B) {
		num += -1 + A;
		anum++;
	}
	cout << anum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=0;i<max(a,b);i++)
	{
		cout<<min(a,b);
	}
	cout<<endl;
	return 0;
}

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

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

    if(a>b){
        cout << "a" << " > " << "b" << endl;
    }else if(a==b){
        cout << "a" << " == " << "b" << endl;
    }else {
        cout << "a" << " < " << "b" << endl;
    }
    return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
int a,b,c; cin>>a>>b>>c;
cout<<(a^b^c);
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll n,k,w[maxn],d[maxn];
bool check(ll MAX){
    ll k0 = k;
    for(int i = 0; i < n; i++){
        if(MAX < w[i])continue;
        ll c = (MAX - w[i]) / d[i] + 1;
        k0 -= c;
        if(k0 <= 0)return true;
    }
    return false;
}
ll dich(){
    ll l = 1, r = 5e18 + 1, m =(l + r) / 2;
    if(check(l))return l;
    while(l != m){
        if(check(m))r = m;
        else l = m;
        m = (l + r) / 2;
    }
    if(check(l))return l;
    return l + 1;
}
int main(){
//    freopen("e:\\in.txt","r",stdin);
    cin>>n>>k;
    for(int i = 0; i < n; i++){
        cin>>w[i]>>d[i];
    }
    cout<<dich()<<endl;
    return 0;
}


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

using namespace std;

using Weight = long long;
struct Edge
{
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};

auto operator<(const Edge &e, const Edge &f)
{
	if (e.weight != f.weight)
		return e.weight > f.weight;
	else if (e.src != f.src)
		return e.src < f.src;
	else
		return e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;

pair<Weight, int> sweep(int p, int v, const Graph &g)
{
	pair<Weight, int> r(0, v);
	for (auto e : g[v])
	{
		if (e.dst != p)
		{
			pair<Weight, int> t = sweep(v, e.dst, g);
			t.first += e.weight;
			if (r.first < t.first)
				r = t;
		}
	}
	return r;
}

Weight double_sweep(const Graph &g, int s)
{
	pair<Weight, int> r = sweep(-1, s, g);
	pair<Weight, int> t = sweep(-1, r.second, g);
	return t.first; // (r.second, t.second) is farthest pair.
}

int main()
{
	int n;
	cin >> n;
	Graph g(n);
	for (int i = 1; i < n; ++i)
	{
		int s, t;
		cin >> s >> t;
		s--, t--;
		g[s].emplace_back(s, t, 1);
		g[t].emplace_back(t, s, 1);
	}
	auto c = double_sweep(g, 0);
	if (c % 3 == 1)
	{
		cout << "Second" << endl;
	}
	else
	{
		cout << "First" << endl;
	}
	//cout << c << endl;
	return 0;
}
//be checked by AOJ(GRL-5-A)

Measured memory_bytes: 29952
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int main()
{
 int k;
 scanf("%d",&k);
 int flg=1,nw=0,rep=7%k;
 for(int i=1;i<=k;i++)
 {
	nw+=rep;
	nw=nw%k;
	rep=(rep*10)%k;
	if(nw==0){printf("%d",i); flg=0; break;}
 }
 if(flg==1){printf("-1");}
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll n,m,q;
vl a(50),b(50),c(50),d(50);
ll ans=0;

void bfs(vl A){
  if((ll)A.size()==n+1){
    ll now=0;
    rep(i,q){
      if(A[b[i]]-A[a[i]]==c[i]){
        now +=d[i];
      }
    }
    ans=max(ans,now);
    return;
  }
  A.push_back(A.back());
  bfs(A);
  while(A.back()<m){
    A.back()++;
    bfs(A);
  }
}
int main() {
  cin >> n >> m >> q;
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  ans=0;
  bfs(vl(1,1));
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    double a, b, C, rad, S, x, h;  
    double PI = acos(-1);
    cin >> a >> b >> C;

    rad = C * PI / 180;
    S = 0.5 * a * b * sin(rad);
    x = sqrt(a*a + b*b - 2*a*b*cos(rad));
    h = S * 2 / a;

    printf("%lf\n",S);
    printf("%lf\n",x + a + b);
    printf("%lf\n",h);

}


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

int main(void) {
  vector<int> v(5);
  for (int i = 0; i < 5; i++) {
    cin >> v[i];
  }
  int ans = 10000;
  do {
    int t = 0;
    for (int i = 0; i < 5; i++) {
      t = (t + 9) / 10 * 10;
      t += v[i];
    }
    ans = min(ans, t);
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
  return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

    int n,a;
    cin >>n;
    cin>>a;

    int s =n%500;

    if(s-a<=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

   
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int[] dice_number = new int[6];

		for(int side_number = 0; side_number < 6; side_number++) {

			dice_number[side_number] = in.nextInt();

		}

		dice dice = new dice();

		dice.setDice_number(dice_number);

		String roll_direction = in.next();

		for(int roll_count = 0; roll_count < roll_direction.length(); roll_count++) {

			dice.roll(roll_direction.charAt(roll_count));

		}

		dice_number = dice.getDice_number();
		System.out.println(dice_number[0]);

	}
}

class dice{

	int[] dice_number;

	public int[] getDice_number() {
		return dice_number;
	}

	public void setDice_number(int[] dice_number) {
		this.dice_number = dice_number;
	}

	void roll(char roll_direction){

		int tmp;

		switch(roll_direction){

		case 'S':

			tmp = dice_number[0];
			dice_number[0] = dice_number[4];
			dice_number[4] = dice_number[5];
			dice_number[5] = dice_number[1];
			dice_number[1] = tmp;

			break;

		case 'N':

			tmp = dice_number[0];
			dice_number[0] = dice_number[1];
			dice_number[1] = dice_number[5];
			dice_number[5] = dice_number[4];
			dice_number[4] = tmp;

			break;

		case 'W':

			tmp = dice_number[0];
			dice_number[0] = dice_number[2];
			dice_number[2] = dice_number[5];
			dice_number[5] = dice_number[3];
			dice_number[3] = tmp;

			break;

		case 'E':

			tmp = dice_number[0];
			dice_number[0] = dice_number[3];
			dice_number[3] = dice_number[5];
			dice_number[5] = dice_number[2];
			dice_number[2] = tmp;

			break;

		}
	}
}

Measured memory_bytes: 26300
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

int K;
  cin>>K;
  ll sum=0;
  for(int i=1;i<K+1;i++){
    for(int j=1;j<K+1;j++){
      for(int m=1;m<K+1;m++){
        sum+=gcd(i,gcd(j,m));
      }
    }
  }
  cout<<sum<<endl;
}



Measured memory_bytes: 3624
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max<T>(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min<T>(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	VI2D d(n, VI(2));
	REP(i, n) { cin >> d[i][0] >> d[i][1]; }

	REP(i, n - 2) {
		if(d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] &&
		   d[i + 2][0] == d[i + 2][1]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main() {
  string n;
  ll k;
  cin >> n >> k;
  vector<vector<ll>> dp0(n.size()+1,vector<ll>(k+1,0));
  vector<vector<ll>> dp1(n.size()+1,vector<ll>(k+1,0));
  dp1[0][0]=1;
  dp0[0][0]=0;
  for(ll i=0;i<n.size();i++) {
    for(ll j=0;j<=k;j++) {
      dp0[i+1][j]+=dp0[i][j];
      if(j<k) {
        dp0[i+1][j+1]+=dp0[i][j]*9;
        if(n[i]!='0') {
          dp0[i+1][j+1]+=dp1[i][j]*(int(n[i]-'0')-1);
        }
      }
      if(n[i]!='0'){
        if(j<k){
          dp1[i+1][j+1]+=dp1[i][j];
        }
        dp0[i+1][j]+=dp1[i][j];
      }
      else {
        dp1[i+1][j]+=dp1[i][j];
      }
    }
  }
  cout << dp0[n.size()][k] + dp1[n.size()][k] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>

#define PI 3.141592

using namespace std;

int main (void){
    string lest;
    cin>>lest;
    if(lest=="ABC"){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC";
    }
    return 0;
}

Measured memory_bytes: 3624
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[205];
int main(){
  cin>>n;
  REP(i,n*2) cin>>ar[i];
  sort(ar,ar+n*2);
  int res=0;
  REP(i,n) res+=ar[i*2];
  cout<<res<<endl;


  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 300005;

template<class T>
struct segment_tree {
    using F = function<T(T,T)>;
    int n;     
    vector<T> data;
    F f;
    T init_v;

    segment_tree(int n_, T init_v, F f) : f(f), init_v(init_v) {
        n = 1;
        while (n < n_) n *= 2;
        data.assign(2*n-1,init_v);
    }

    //kをaに変更
    void update(int k, T a) {
        k += n-1;
        data[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = f(data[k*2+1],data[k*2+2]);
        }
    }

    //[a,b)のquery,kは節点番号
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) return data[k];
        else {
            T vl = query(a,b,k*2+1,l,(l+r)/2);
            T vr = query(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T operator[](int a) {return data[a+n-1];}

    //[a,b)を出力
    void debug_seg(int a, int b) {
        a += n-1; b += n-1;
        for (int i = a; i < b; i++) {
            cout << data[i] << " ";
        }
        cout << endl;
    }
};

int dp[MAX];

int main() {
    int n, k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    auto f = [](int a, int b) {return max(a, b);};
    segment_tree<int> st(MAX, 0, f);
    for (int i = 1; i <= n; i++) {
        int l = max(a[i-1] - k, 0);
        int r = a[i-1] + k;
        dp[i] = st.query(l, r + 1) + 1;
        if (st[a[i-1]] < dp[i]) st.update(a[i-1], dp[i]);
    }
    int ans = 0;
    rep(i,n+1) chmax(ans,dp[i]);
    cout << ans << endl;
}

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

int main() {
    int N, T, A;
    cin >> N >> T >> A;
    int H[N];
    rep(i, N) cin >> H[i];

    float min_temp = 1000000;
    int ans = -1;

    for (int i = 0; i < N; ++i) {
        if (min_temp >= abs(T-H[i]*0.006-A)) {
            min_temp = abs(T-H[i]*0.006-A);
            ans = i+1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void AGC031A();

#if 1
int main()
{
	AGC031A();
	fflush(stdout);
	return 0;
}
#endif

static void AGC031A()
{
	int N;
	getint(N);

	std::string orgs;
	std::cin >> orgs;

	std::map<char, LLONG> chars;
	std::vector<LLONG> dp(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		dp[i] = dp[i - 1];
		
		LLONG use = 1;
		int kind = chars.size();
		for(auto it = chars.begin(); it != chars.end(); it++) {
			if (it->first != orgs[i - 1]) {
				use = (use * (it->second + 1)) % MOD_NUM;
			}
		}

		dp[i] = (dp[i] + use) % MOD_NUM;
		chars[orgs[i - 1]]++;
	}
	printf("%lld\n", dp[N]);
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll n;cin>>n;
  ll a[100000];
  REP(i,n){
    cin>>a[i];
  }
  ll m1=0,m2=0,c1=0,c2=0;
  REP(i,n){
    c1+=a[i];
    if(i%2==0 && c1<=0){m1+=(1LL-c1);c1=1;}
    if(i%2==1 && c1>=0){m1+=(c1+1LL);c1=-1;}
  }
  REP(i,n){
    c2+=a[i];
    if(i%2==1 && c2<=0){m2+=(-c2+1LL);c2=1;}
    if(i%2==0 && c2>=0){m2+=(c2+1LL);c2=-1;}
  }
  cout<<min(m1,m2)<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
using namespace std;
int f[60],pic[60][60],n,m,ans=0,a,b;
int find_fa(int x)
{
    if(f[x]==x)return x;
    return f[x]=find_fa(f[x]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)scanf("%d%d",&a,&b),pic[a][b]=pic[b][a]=1;
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
    if(pic[i][j]==1)
    {
        pic[i][j]=0;
        for(int x=1;x<=n;x++)f[x]=x;
        for(int k=1;k<=n;k++)
        for(int l=k+1;l<=n;l++)
        if(pic[k][l]==1)
        f[find_fa(k)]=find_fa(l);
        for(int y=1;y<n;y++)
        if(find_fa(y)!=find_fa(y+1))
        {ans++;break;}
        pic[i][j]=1;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128