akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }
  rep(i, n) {
    cin >> b[i];
  }
  rep(i, n-1) {
    cin >> c[i];
  }
  int ans = 0;
  rep(i, n) {
    ans += b[a[i]];
    if ((i < n - 1) && (a[i+1] - a[i] == 1)) {
      ans += c[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){

  int n,ans[100],agari,i,j,ap,bp;
  char a[1000],b[1000];

  scanf("%d",&n);

  for(i = 0; i < n; i++){
   
    scanf("%s %s",a,b);
    
    if(strlen(a) > 80 || strlen(b) > 80){
      puts("overflow");
      continue;
    }
    
    ap = strlen(a) - 1;
    bp = strlen(b) - 1;

    j = 0;
    agari = 0;

    while(ap >= 0 || bp >= 0){
      ans[j] = agari;

      if(ap >= 0){
	ans[j] += a[ap] - '0';
      }

      if(bp >= 0){
	ans[j] += b[bp] - '0';
      }

      agari = ans[j] / 10;
      ans[j] %= 10;
      
      j++;
      ap--;
      bp--;
    }

    if(agari == 1){
      ans[j] = 1;
    }else{
      j--;
    }

    if(j >= 80){
      puts("overflow");
      continue;
    }

    for(; j >= 0; j--){
      printf("%d",ans[j]);
    }

    puts("");
  }
  return 0;
}

Measured memory_bytes: 612
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

const int MSQ = sqrt(N) + 5;


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

	int n;

	scanf("%d",&n);
	std::vector<int> a(n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);

	a[0]=a[0]-1;

	for(int i=1;i<n;i++){
		if(a[i]<a[i-1])return !printf("No\n");
		a[i]=max(a[i-1],a[i]-1);
	}
	printf("Yes\n");

}		



Measured memory_bytes: 640
import java.util.*;
import java.lang.*;

class Main {
    
    public static void main(String[] areg) {
        Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int count = 0;
        HashSet<Integer> set = new HashSet<Integer>();
        for (int i = 0; i < N; i++) {
            int j = sc.nextInt();
            if (set.contains(j))
                count++;
            else
                set.add(j);
        }
		sc.close();
        
        System.out.println(set.size() - (count % 2 == 0 ? 0 : 1));
    }
}

Measured memory_bytes: 61792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  vector<ll> s(N+1); // s[i] .. sum of [0, i)
  rep(i, N) {
    s[i+1] = s[i] + A[i];
  }
  // For Debug
  // rep(i, N+1) {
  //   cout << s[i] << endl;
  // }

  vector<ll> l(N); // the left index of each middle i. the middle in [0, i].
  vector<ll> r(N); // the left index of each middle i. the middle in [i+1, N-1].
  ll left = 0;
  for (int i = 1; i < N-2; ++i) { // calculate l in [1, N-3]
    ll summed = s[i+1]; // The sum of [0, i]
    while ((left < i) && abs(summed - s[left+1]*2) < abs(summed - s[left]*2)) {
      ++left;
    }
    // Here, left is the index of minimum. summed - s[left] is minimum.
    l[i] = left;
  }
  ll right = 1;
  for (int i = 1; i < N-2; ++i) { // calculate r in [1, N-3]
    while ((right < N) && abs((s[N]-s[right+1]) - (s[right+1]-s[i+1])) < abs((s[N]-s[right]) - (s[right]-s[i+1]))) {
      ++right;
    }
    // Here, right is the index of minimum. s[N] - s[right] is minimum.
    r[i] = right;
  }

  ll ans = INF;
  for (int i = 1; i < N-2; ++i) {
    ll left = l[i];
    ll right = r[i];

    ll l1 = s[left];
    ll l2 = s[i+1] - s[left];
    ll r1 = s[right] - s[i+1];
    ll r2 = s[N] - s[right];
    // For Debug
    // cout << l1 << "," << l2 << "," << r1 << "," << r2 << endl;
    ll min_v = min(min(l1, l2), min(r1, r2));
    ll max_v = max(max(l1, l2), max(r1, r2));
    ans = min(ans, abs(max_v - min_v));
  }

  cout << ans << endl;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int64_t *a1, int64_t *a2) {
  scanf("%lld %lld", a1, a2);
  return 0;
}


int main(void) {
    int num = get_int();
    int i;
    int64_t acur;
    int64_t bcur;
    get_int2(&acur, &bcur);
    for(i = 1; i < num; i++) {
        int64_t ma, mb;
        get_int2(&ma, &mb);
        int64_t aprop = (acur-1)/ma + 1;
        int64_t bprop = (bcur-1)/mb + 1;
        int64_t mult = max(aprop, bprop);
        // update
        acur = mult*ma;
        bcur = mult*mb;
#ifdef DEBUG
        printf("%lld %lld\n", acur, bcur);
#endif
    }
    printf("%lld\n", acur+bcur);
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# coding=utf-8

import sys
import re

a, b = sys.stdin.readline().strip().split(" ")
s = sys.stdin.readline().strip()
a = int(a)
b = int(b)
m = re.match(r'(\d+)(-)(\d+)', s)
if m is None:
    print("No")
else:
    if len(m.group(1)) == a and m.group(2) == "-" and len(m.group(3)) == b:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main() {
	long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);

	if(A<=9&&B<=9) cout << A*B << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<(x)<<endl
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){//階乗の計算
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}
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(){
    int k,s;
    cin >> k >>s;

    ll cnt=0;
    rep(x,k+1){
        rep(y,k+1){
            int z = s - x - y;
            if(z>=0&&z<=k) cnt += 1;
        }
    }
    cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
graph=[[] for i in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
ANS=[0 for i in range(N)]
finish=[0]
for i in finish:
  for k in graph[i]:
    if ANS[k]==0:
      ANS[k]=i+1
      finish.append(k)
print("Yes")
for i in range(1,N):
  ans=ANS[i]
  print(ans)

Measured memory_bytes: 37504
from sys import stdin
import itertools
S = (stdin.readline().rstrip())
ans = 0
s = ""
for k in list(itertools.product(["","+"],repeat=len(S)-1)):
    #print(k)
    for i,j in itertools.zip_longest(S,k,fillvalue=""):
        s = s+i+j
        #print(s)
    ans += eval(s)
    s = ""
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n;
cin >> n;
ll a[n+1] = {};
rep(i, n+1){
    cin >> a[i];
}
ll b[n] = {};
rep(i, n){
    cin >> b[i];
}
rep(i,n){
    if(b[i]>a[i]){
        b[i]-=a[i];
        ans+=a[i];
        if(a[i+1]>b[i]){
            a[i+1]-=b[i];
            ans+=b[i];
        }
        else{
            ans+=a[i+1];
            a[i+1]=0;
        }
    }
    else{
        ans+=b[i];
    }
}

cout << ans << endl;
return 0;
}


Measured memory_bytes: 1792
n, k, q = map(int, input().split())

a = [-1] * q
for i in range(q):
    a[i] = int(input())

t = [0] * (n+1)
for i in range(q):
    t[ a[i] ] += 1

p = [k - q + t[i] for i in range(0, n+1)]
p[0] = 0

for i in range(1, n+1):
    if p[i] > 0:
        print('Yes')
    else:
        print('No')


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


int main(){
    int n;
    cin >> n;
    vector<int> x(n),y(n),h(n);
    rep(i,n) cin >> x[i] >> y[i] >> h[i];
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++){
            int now;
            set<int> st;
            for(int k=0; k<n; k++){
                if(h[k]==0) continue;
                now = h[k]+abs(i-x[k])+abs(j-y[k]);
                
                st.insert(now);
            }
            if(st.size()==1){
                int check = true;
                auto itr = st.begin();
                rep(k,n){
                    if(h[k]==0){
                        if(abs(i-x[k])+abs(j-y[k])-*itr < 0) 
                            check = false;
                    }
                }
                if(check)
                cout << i << " " << j << " " << *itr << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3652
#include<set>
#include<map>
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
using namespace std;

int a, b;

int main()
{
	scanf("%d", &a);
	scanf("%d", &b);
	if (a > 8 || b > 8)
	{
		printf(":(\n");	
	}
	else
	{
		printf("Yay!\n");
	}
}

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

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

int main(){
  int V,E;
  cin>>V>>E;
  std::vector<int> s(E),t(E),w(E);
  for(int i=0;i<E;i++)cin>>s[i]>>t[i]>>w[i];
  typedef tuple<int,int,int> X;
  std::vector<X> x(E);
  for(int i=0;i<E;i++)x[i]=X(w[i],s[i],t[i]);
  sort(x.begin(),x.end());
  int ans=0;
  UnionFind uf(V);
  for(int i=0;i<E;i++){
    int& ww=std::get<0>(x[i]);
    int& ss=std::get<1>(x[i]);
    int& tt=std::get<2>(x[i]);
    if(!uf.same(ss,tt)){
      ans+=ww;
      uf.unite(ss,tt);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e7+5,mod=1e9+7;
int n,m,k;
ll f[N],invf[N];
ll inv(ll x){return x<=1?x:(mod-mod/x)*inv(mod%x)%mod;}
ll C(ll n,ll m)
{
    return m<=n?f[n]*invf[n-m]%mod*invf[m]%mod:0;
}
int main()
{
    f[0]=invf[0]=f[1]=invf[1]=1;
    for(int i=2;i<N;i++) f[i]=f[i-1]*i%mod,invf[i]=(mod-mod/i)*invf[mod%i]%mod;
    for(int i=2;i<N;i++) invf[i]=invf[i]*invf[i-1]%mod;
    scanf("%d%d%d",&n,&m,&k);
    ll ans=C(k,2)*inv(C(n+m,2))%mod+C(k,3)*inv(C(n+m,3))%mod*(n+m-2)%mod*inv(3)%mod;
    ans=ans*n%mod*m%mod;
    ll res=C(k,1)*inv(C(n+m,1))%mod+C(k,2)*inv(C(n+m,2))%mod*(n+m-1)%mod*inv(2)%mod;
    ans=(ans+res*(n+m))%mod;
    ans=(ans+k)%mod;
    ans=ans*C(n+m,k)%mod*f[k]%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 312704
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
  long X;
  cin >> X;
  long X2 = 2 * X;
  long n = sqrt(X2);
  for (; n * (n+1) < X2; ++n);
  cout << n << endl;
  return 0;
}


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

int main() {
int  N,A,B ;
    cin >> N >> A >> B ;
  int plan_A=N*A;
  
  if (plan_A<B){
    cout <<  plan_A << endl;  
  }
  
  else {		
        cout << B << endl;  
  }
}


Measured memory_bytes: 256
// Ryo Kamoi
// #define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int INF = 1000000000;

string s;
int idx = 0;
ll output = 0;
ll anum;

void findabc() {
    if (s[idx] == 'A') {
      if (idx+2 < s.size()) {
        if (s[idx+1]=='B' && s[idx+2]=='C') {
          output += anum+1;
          s[idx+2] = 'A';
          idx++;
        } else {
          anum++;
        }
      }
    } else {
      anum = 0;
    }
}

int main(){
  cin >> s;
  anum = 0;

  while(idx < s.size()) {
    findabc();
    idx++;
  }

  cout << output << endl;
}


Measured memory_bytes: 640
remover::String -> String
remover []  =[]
remover (x:[])=[x]
remover (x:y:r)= if (x=='(')&&(y==')') then remover r else x:(remover (y:r))

mult_remover::String -> Int -> String
mult_remover st 0 = st
mult_remover st n = mult_remover (remover st) (n-1)

solver::String->String
solver st = let (par,chl) =span (\x->x==')') (mult_remover st 50) in
            let (p,c)=(length par,length chl)in
            (replicate p '(')++st++(replicate c ')')

main::IO()
main=do
  _<-getLine
  dat<-getLine
  putStr (solver dat)
  putStr "\n"

Measured memory_bytes: 764
//file_name:ABC93_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0])yn;

    return 0;
}



Measured memory_bytes: 256
N,*as=$<.read.split.map(&:to_i)
as.sort!

t = (as[-1]/2.0).ceil
as = as.map.with_index{|a,i|[a,i]}
a,i = as.min_by { |a,i| (a-t).abs }
puts [as[-1][0],as[i][0]] * ' '


Measured memory_bytes: 14312
n = gets.chomp.to_i

for k in (1..n)
  gets

  pl = []
  8.times do
    pl.push gets.chomp.split("").map{|s| s.to_i}
  end

  x0 = gets.chomp.to_i - 1
  y0 = gets.chomp.to_i - 1
  #p [pl, x0, y0]

  pl[y0][x0] = 0
  queue = [[x0, y0]]

  while queue.length > 0
    x, y = queue.shift

    for x1 in ([x - 3, 0].max..(x - 1))
      if pl[y][x1] == 1
        pl[y][x1] = 0
        queue.push [x1, y]
      end
    end
    for x1 in ((x + 1)..[x + 3, 7].min)
      if pl[y][x1] == 1
        pl[y][x1] = 0
        queue.push [x1, y]
      end
    end
    for y1 in ([y - 3, 0].max..(y - 1))
      if pl[y1][x] == 1
        pl[y1][x] = 0
        queue.push [x, y1]
      end
    end
    for y1 in ((y + 1)..[y + 3, 7].min)
      if pl[y1][x] == 1
        pl[y1][x] = 0
        queue.push [x, y1]
      end
    end
  end

  puts "Data #{k}:"
  pl.each{|hl| puts hl.join("")}
end

Measured memory_bytes: 6128
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++) cin>>A[i];
  int max=0;
  for(int i=0;i<N-1;i++)
    for(int j=i+1;j<N;j++)
      if(max<abs(A[i]-A[j])) max=abs(A[i]-A[j]);
  cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 256
import math
import copy
import sys

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# inputb = input().split()
# inputbList = [int(x) for x in inputb]

# x = int(inputb[0])
# y = int(inputb[1])
#
# inputList=[]
# for i in range(a):
#     inputNum = input()
    # inputNum = [int(x) for x in inputNum]
    # inputList.append(int(inputNum))

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

inputList = list(inputa[0])

min = sys.maxsize
for i in range(len(inputList)-2):
    threeNumList = []
    for j in range(3):
        threeNumList.append(inputList[i+j])

    threenum = "".join(threeNumList)
    tmp = abs(753 - int(threenum))
    if min > tmp:
        min = tmp

print(min)





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

/*int main(){//B
    string S;
    cin>>S;
    rep(i,0,S.size()){
        if(i%2==0){
            if(S[i]!='R'&&S[i]!='U'&&S[i]!='D') {
                cout<<"No"<<endl;
                return 0;
            }
        }
        if(i%2!=0){
            if(S[i]!='L'&&S[i]!='U'&&S[i]!='D'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}*/

/*int main(){
    int N,K,Q;
    cin>>N>>K>>Q;
    vector<int> A(N,K-Q);
    //vector<int> B(Q);
    int c=N;
    rep(i,0,Q){
        int b; 
        cin>>b;
        A[b-1]++;
    }
    rep(i,0,N) {if(A[i]>0) cout<<"Yes"<<endl;
                else cout<<"No"<<endl;
    }
    return 0;
}*/

int main(){
    long long N,M;
    cin>>N>>M;
    long long c=0;
    priority_queue<long long> A;
    rep(i,0,N) {
        long long a;
        cin>>a;
        A.push(a);
    }
    rep(i,0,M) {
        long long b;
        b=A.top();
        A.pop();
        A.push(b/2);
    }
    rep(i,0,N) {
        c+=A.top();
        A.pop();
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 1400
drawFrame :: Int -> Int -> String
drawFrame h w = replicate w '#' ++ "\n" ++
                (concat . replicate (h-2) $ "#" ++ replicate (w-2) '.' ++ "#\n") ++
                replicate w '#' ++ "\n"
main = getLine >>= \l -> let (h:w:_) = map read . words $ l
                         in if h == 0 && w == 0 then return ()
                            else do
                              putStrLn $ drawFrame h w
                              main

Measured memory_bytes: 4100
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }


signed main()
{
    int N; cin>>N;
    vector<int> a(N),b(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    for(int i=0;i<N;i++){
        cin>>b[i];
    }

    vector<int> x,y;
    for(int i=0;i<N;i++){
        int diff=a[i]-b[i];
        if(diff>0) x.push_back(diff);
        if(diff<0) y.push_back(diff);
    }
    sort(x.begin(),x.end(),greater<int>());

    int ans=y.size();
    int minusSum=accumulate(y.begin(),y.end(),0LL);
    int plusSum=0;
    for(int i=0;i<x.size();i++){
        if(plusSum+minusSum<0){
            plusSum+=x[i];
            ans++;
        }
    }
    if(plusSum+minusSum<0){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
}   


Measured memory_bytes: 2812
using System;
    class Program
    {
    	static void Main(string[] args)
    	{
    		// スペース区切りの整数の入力
    		string[] input = Console.ReadLine().Split(' ');
    		int a = int.Parse(input[0]); 
    		int b = int.Parse(input[1]);
    		int c = int.Parse(input[2]);

    		//出力
    		Console.WriteLine(b - a == c - b ? "YES" : "NO");
    	}
    }



Measured memory_bytes: 13140
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define pqueue priority_queue

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int mod=1e9+7,N=1e6+3;

void solve(){	
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int ans=0;
	for(int i=0;i<=a;++i){
		for(int j=0;j<=b;++j){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x)ans++;
			}
		}
	}
	printf("%d",ans);

}

int main(){
 	ios_base::sync_with_stdio(0);
 	cin.tie(0);cout.tie(0);
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

Measured memory_bytes: 3772
import java.io.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        // 入力
        MyScanner sc = new MyScanner(System.in);
        int[] NW = sc.nextIntArray();
        int N = NW[0];
        int W = NW[1];
        int[] w = new int[N+1];
        long[] v = new long[N+1];
        w[0] = 0;
        v[0] = 0;
        for(int i=1; i<=N; i++) {
            int[] tmp = sc.nextIntArray();
            w[i] = tmp[0];
            v[i] = tmp[1];
        }
        // System.out.println("N = " + N);
        // System.out.println("W = " + W);
        // System.out.println("w = " + Arrays.toString(w));
        // System.out.println("v = " + Arrays.toString(v));

        // 初期化
        long[][] dp = new long[N+1][W+1];

        // 主処理
        for(int i = 0; i <= N; i++) {
            for(int j = 0; j <= W; j++) {
                if (i == 0) {
                    dp[i][j] = 0;
                } else {
                    if (j < w[i]) {
                        dp[i][j] = dp[i-1][j];
                    } else {
                        dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
                    }
                }
            }
        }
        // for (long[] arr : dp) {
        //     for (long var : arr) {
        //         System.out.print(var + " ");
        //     }
        //     System.out.println();
        // }

        // 出力
        System.out.println(dp[N][W]);
    }

    static class MyScanner {
        BufferedReader br;
        // 標準入力から入力値を取得
        MyScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }
        // 標準入力を文字列で取得
        public String nextString() throws IOException {
            return br.readLine();
        }
        // 標準入力を文字列の配列で取得
        public String[] nextStringArray() throws IOException {
            return nextString().split(" ");
        }
        // 標準入力を数値で取得
        public int nextInt() throws IOException {
            return Integer.parseInt(nextString());
        }
        // 標準入力を数値の配列で取得
        public int[] nextIntArray() throws IOException {
            String[] strArr = nextStringArray();
            int[] intArr = new int[strArr.length];
            for(int i = 0; i < strArr.length; i++) {
                intArr[i] = Integer.parseInt(strArr[i]);
            }
            return intArr;
        }
    }

}


Measured memory_bytes: 126164
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            dic[i**2+j**2+k**2+i*j+j*k+k*i] += 1

for i in range(1,n+1):
    print(dic[i])

Measured memory_bytes: 11632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define p(x) cout << x << endl;

#define MOD 1000000007
#define PI 3.14159265359

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

    int i = 1;
    while(1){
        if(i * i > n){
            p((i - 1) * (i - 1));
            break;
        }
        i++;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
	int N,K;
	string S;

	cin >> N;
	cin >> S;
	cin >> K;
	int i;
	string res;
	for (i=0; i<S.length(); i++) {
		if (S[i] != S[K-1])
			res += '*';
		else
			res += S[i];
	}
	cout << res << endl;
}


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



int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> members(N, 0);
    vector<ll> foods(N, 0);
    ll costSum = 0;
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        members.at(i) = a;
        costSum += a;
    }

    sort(members.begin(), members.end());
    for(int i = 0; i < N; i++)
    {
        ll f;
        cin >> f;
        foods.at(i) = f;
    }
    sort(foods.begin(), foods.end(), greater<ll>());
    ll lmin = -1;
    ll lmax = 1e12;
    while(lmax - lmin > 1){
        ll lmid = (lmin + lmax) / 2;
        ll count = 0;
        for(int i = 0; i < N; i++){
            ll cost = lmid / foods.at(i);
            count += max((ll)0, members.at(i) - cost);
            if(count > K){
                break;
            }
        }
        if (count > K){
            lmin = lmid;            
        }else{
            lmax = lmid;
        }
    }
    cout << lmax << endl;
    return 0;
}



Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int n,i,j,x,y,nx;
int map[100][100]={0};
int color[100]={0};//0 null  1 gray 2 black 
int start[100]={0};
int end[100]={0};
int pretime=0;
int dfs(int p){
	for(int m=0;m<n;m++){
		if(map[p][m]==1&&color[m]==0){
			start[m]=++pretime;
			color[m]=1;
			dfs(m);
		}
	}
	end[p]=++pretime;
	color[p]=2;
	return 0;
}
int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x>>nx;
		for(j=0;j<nx;j++){
			cin>>y;
			map[x-1][y-1]=1;
		}
	}
	for(i=0;i<n;i++){
		if(color[i]==0){
			color[i]=1;
		    start[i]=++pretime;
	     	dfs(i);
		}

	}

	for(i=0;i<n;i++){
		cout<<i+1<<" "<<start[i]<<" "<<end[i]<<endl;
	}
	
	
	return 0;
} 


Measured memory_bytes: 3120
#include<math.h>
#include <iostream>
using namespace std;
int main(void){

	int X;

	cin >> X;

	if (X == 3 || X == 5 || X == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

INF = float('inf')

def sol():
    N, M = map(int, input().split())

    edges = []

    for _ in range(M):
        fr, to, cost = map(int, input().split())
        fr -= 1
        to -= 1
        edges.append((fr, to, cost))

    graph = [[INF] * N for _ in range(N)]
    for fr, to, cost in edges:
        graph[fr][to] = cost

    graph = csgraph_from_dense(graph, null_value=INF)

    dist = floyd_warshall(graph, directed=False)
    ans = (graph > dist).sum()
    print(ans)

sol()

Measured memory_bytes: 25716
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

ll ans1,ans2; int a[10];

int main(){
	rep (i,1,7) scanf("%d",&a[i]);
	ans1=4ll*(a[1]/2)+2ll*a[2]+4ll*(a[4]/2)+4ll*(a[5]/2);
	if ((a[1]&1)&&(a[4]&1)&&(a[5]&1)) ans1+=6;
	if (a[1]&&a[4]&&a[5]) ans2=6,a[1]--,a[4]--,a[5]--; else ans2=0;
	ans2+=4ll*(a[1]/2)+2ll*a[2]+4ll*(a[4]/2)+4ll*(a[5]/2);
	cout<<max(ans1,ans2)/2;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h,w,i;
	char c[105][105];
	scanf("%d %d",&h,&w);
	
	for(i=0;i<h;i++){
		scanf("%s",c[i]);
	}
	
	for(i=0;i<h;i++){
		printf("%s\n%s\n",c[i],c[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll cur_t = 0, cur_x = 0, cur_y = 0;
    ll t, x, y;
    rep(i, N)
    {
        cin >> t >> x >> y;
        ll dis = abs(cur_x - x) + abs(cur_y - y);
        if (dis > abs(cur_t - t) || dis % 2 != abs(cur_t - t) % 2) {
            puts("No");
            return 0;
        }
        cur_t = t;
        cur_x = x;
        cur_y = y;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

main(){
  int n;
  cin>>n;
  vector<int> a(n);

  rep(i,n){
    cin>>a[i];
  }

  int ans=0;
  FOR(i,1,n-1){
    if(a[i-1]<a[i]&&a[i]<a[i+1]||a[i+1]<a[i]&&a[i]<a[i-1]) ans++;
  }

  cout<<ans<<endl;
}


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

struct shop{
  long long price;
  long long num;
};

int main(){
  long long n, m;
  cin >> n >> m;
  vector<shop> pairs;
  for(int i = 0; i < n; i++){
    long long a, b;
    cin >> a >> b;
    shop temp = {a, b};
    pairs.push_back(temp);
  }
  sort(pairs.begin(), pairs.end(), 
       [](const shop& x, const shop& y) { return x.price < y.price;});
  long long count = 0;
  long long cost = 0;
  for(int i = 0; i < n; i++){
    count += pairs.at(i).num;
    if(count < m){
      cost += pairs.at(i).price * pairs.at(i).num;
    }
    else{
      cost += pairs.at(i).price * (m - count + pairs.at(i).num);
      break;
    }
  }
  cout << cost << endl;
}

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

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

  array<int, 2> mods = {};
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    mods[A[i] % 2]++;
  }

  if(mods[1] == 0 && P == 1){
    cout << 0 << endl;
    return 0;
  }
  
  long long ans = 1;
  for(int i = 0; i < mods[0]; i++){
    ans *= 2;
  }
  for(int i = 0; i < mods[1] - 1; i++){
    ans *= 2;
  }
  cout << ans << endl;
}

  


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i < n;i++)
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define sz(x) x.size()
#define ll long long

int main() {
	ll n; cin >> n;
	vector<ll> x(3*n);
	rep(i,3*n) cin >> x[i];
	sort(x.rbegin(),x.rend());
	ll ans = 0,cou = 1,j = 1;
	while(cou <= n) {
		ans += x[j];
		cou++; j += 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;

vector<int> g[N];
vector<int> h[N];
int vis[N];

void go(int x, int p) {
    vis[x] = 1;
    for(auto v : g[x]) {
        if(!vis[v]) {
            go(v, x);
        } else if(v != p && vis[v] == 1) {
            h[x].emplace_back(v);
            pr(x, v);
        }
    }
    vis[x] = 2;
}

void go2(int x) {
    vis[x] = 1;
    for(auto v : g[x]) {
        if(!vis[v]) {
            go2(v);
            if(sz(h[v]) & 1) {
                h[v].emplace_back(x);
                prl();
                pr(v, x);
            } else {
                h[x].emplace_back(v);
                prl();
                pr(x, v);
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    if(m & 1) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, 0, m) {
        int u, v;
        cin >> u >> v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    go(1, 0);
    memset(vis, 0, sizeof(vis));
    go2(1);
    rep(i, 1, n + 1) {
        for(auto v : h[i]) {
            cout << i << ' ' << v << endl;
        }
    }
}

Measured memory_bytes: 18944
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 1003
#define inf LLONG_MAX
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//int mod=1e9+7;
//int mod=998244353;
queue<pair<pii,int>> q;
bool vis[M][M];
int steps[M][M],n,m;

void bfs()
{
    memset(steps,0,sizeof steps);
    int ans=0;
    while(!q.empty())
    {
        auto u2=q.front();
        q.pop();
        int i=u2.first.first,j=u2.first.second,k=u2.second;
        ans=max(ans,k);
        if(i>1 and (!vis[i-1][j] or steps[i-1][j]>k+1))
            q.push({{i-1,j},k+1}),steps[i-1][j]=k+1,vis[i-1][j]=1;
        if(i<n and (!vis[i+1][j] or steps[i+1][j]>k+1))
            q.push({{i+1,j},k+1}),steps[i+1][j]=k+1,vis[i+1][j]=1;
        if(j>1 and (!vis[i][j-1] or steps[i][j-1]>k+1))
            q.push({{i,j-1},k+1}),steps[i][j-1]=k+1,vis[i][j-1]=1;
        if(j<m and (!vis[i][j+1] or steps[i][j+1]>k+1))
            q.push({{i,j+1},k+1}),steps[i][j+1]=k+1,vis[i][j+1]=1;
    }
    cout<<ans;
}

signed main()
{
    SPEED

    memset(vis,0,sizeof vis);
    cin>>n>>m;
    char a[n+1][m+1];
    int i,j;
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=m;++j)
        {
            cin>>a[i][j];
            if(a[i][j]=='#')
                q.push({{i,j},0}),vis[i][j]=1;
        }
    }
    bfs();

    return 0;
}


Measured memory_bytes: 34228
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int T = scanner.nextInt();
    int prev = -1;
    long sum = 0;
    for (int i = 0; i < N; i++) {
      int t = scanner.nextInt();
      if (prev >= 0) {
        sum += Math.min(T, t - prev);
      }
      prev = t;
    }
    sum += T;
    System.out.println(sum);
  }
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<ll> s(n + 1, 0);
    map<ll, ll> mp;
    mp[0]++;
    for (int i = 0; i < n; ++i) {
        s[i + 1] = s[i] + a[i];
        mp[s[i + 1]]++;
    }

    ll ans = 0;
    for (auto p : mp) {
        if (p.second >= 2) {
            ans += (p.second) * (p.second - 1) / 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.Char (isSpace)
import Data.Vector (Vector, (!))
import qualified Data.Vector as V

main :: IO ()
main = do
  [_, _, m] <- g
  solve <$> f <*> f <*> replicateM m g >>= print
  where
    f = readiv B.readInt <$> B.getLine
    g = map read <$> words <$> getLine

solve :: Vector Int -> Vector Int -> [[Int]] -> Int
solve va vb xss = foldl f (V.minimum va + V.minimum vb) xss
  where
    f mn [x, y, c] = min mn $ va ! (x - 1) + vb ! (y - 1) - c

readiv :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> Vector a
readiv f = V.unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')


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

int gcd(int a, int b){
    if(b == 0) return a;

    return gcd(b, a%b);
}

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

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

    sort(A.begin(), A.end());

    int Ans = gcd(A[1],A[0]);

    for(int i = 0; i < N; i++)
    {
        Ans = gcd(A[i],Ans);
    }
     cout << Ans << endl;

    return 0;
}

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

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int A = input[0];
            int B = input[1];

            if (A < 6) Console.WriteLine(0);
            else if (A < 13) Console.WriteLine(B / 2);
            else Console.WriteLine(B);
        }
    }
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  double p=a.at(n-1)/pow(2,n-1);
  for(int i=0;i<n-1;i++){
    p+=a.at(i)/(pow(2,i+1));
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
std::map<ll,int>Map;
int main(){
	int n;
	ll x,s=0,o=0;
	Map[0]=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		s+=x;
		o+=Map[s];
		Map[s]++;
	}
	std::cout<<o<<std::endl;
	return 0;
}


Measured memory_bytes: 12800
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		ArrayList<String> array = new ArrayList<String>();

		while(sc.hasNext()) {
			String s = sc.next();
			int index = Collections.binarySearch(array, s);
			if(index < 0) {
				index = - (index + 1);
				array.add(index, s);
			}
		}

		int ans = array.size();

		System.out.println(ans);

		sc.close();

	}

}


Measured memory_bytes: 70144
#include <cstdio>

int n;
int s[31];

int main(){
	s[0] = 1;
	for(int i = 0; i < 31; i++){
		for(int j = 1; j <= 3; j++){
			if(i-j < 0) break;
			s[i] += s[i-j];
		}
	}
	while(scanf("%d", &n),n){
		if(s[n]%3650==0) printf("%d\n", s[n]/3650);
		else printf("%d\n", s[n]/3650+1);
	}
}

Measured memory_bytes: 1028
n,m=map(int,input().strip().split())
xs=[i for i in map(int,input().strip().split())]
xs.sort()
if n>=m:
    print(0)
else:
    ls=[xs[i+1]-xs[i] for i in range(len(xs)-1)]
    ls.sort()
    ans=xs[-1]-xs[0]
    for i in range(n-1):
        d=ls.pop()
        ans-=d
    print(ans)
    


Measured memory_bytes: 13832
search_word = STDIN.gets.chomp.downcase
count = 0
eof = false

until eof do
	text = STDIN.gets.chomp.split(" ")
	text.each {|test_word|
		if test_word.eql?("END_OF_TEXT") && text.length == 1 then
			eof = true
			break
		end
		test_word.downcase!
		count += 1 if test_word.eql?(search_word)
	}
#	print count,", ",text,"\n"
end

print count, "\n"


Measured memory_bytes: 6864
# abc162_d.py
import sys
import time
import unittest
from io import StringIO


def resolve():
    int(input())
    S = input()
    r = S.count("R")
    g = S.count("G")
    b = S.count("B")
    sum = r * g * b
    for i in range(len(S)):
        for j in range(i + 1, len(S)):
            k = j + (j - i)
            if k < len(S) and S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                sum -= 1
    print(sum)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def checkTLE(self, input):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin

    def debugIO(self, input):
        stdin = sys.stdin
        sys.stdin = StringIO(input)
        resolve()
        sys.stdin = stdin

    def setUp(self):
        self.startTime = time.time()

    def tearDown(self):
        t = time.time() - self.startTime
        print('%s: %.3f' % (self.id(), t), flush=True)

    def test_入力例_1(self):
        input = """4
RRGB"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"""
        output = """1800"""
        self.assertIO(input, output)


if __name__ == "__main__":
    if "IS_LOCAL" in locals():
        suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
        unittest.TextTestRunner(verbosity=0).run(suite)
    else:
        resolve()


Measured memory_bytes: 16356
using System;
using System.Linq;
class A{static void Main(){
    int []a=Console.ReadLine().Split().Select(int.Parse).ToArray();
    if(a[0]+a[1]<a[2]){Console.WriteLine("NA");return;}
    if(a[0]>=a[2]){Console.WriteLine(0);}
    else{Console.WriteLine(a[2]-a[0]);}
    
}}

Measured memory_bytes: 9540
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int first = 0;
        int second = 0;
        for (int i = 0 ; i < n - 1 ; i++) {
            if (first == 0) {
                if (a[n - 1 - i] == a[n - 2 - i]) {
                    first = a[n - 1 - i];
                    i++;
                }
            } else {
                if (second == 0) {
                    if (a[n - 1 - i] == a[n - 2 - i]) {
                        second = a[n - 1 - i];
                    }
                }
            }
        }
        System.out.println((long) first * second);
    }
}

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


int main(void){
    ll N; cin >> N;
    ll F,MaxF = 0;
    for (int i = 0; i < 5; i++)
    {
        cin >> F;
        F = (N + F - 1) / F; 
        MaxF = max(F,MaxF);
    }
    cout << MaxF + 4 << endl;
    
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <fstream>

using namespace std ;
typedef long long ll ;

int bfs(int s,vector<vector<int>> &adj,vector<int> &visited){

	queue<int> q ;
	q.push(s) ;

	visited[s]=1 ;

	int size=1 ;

	while(!q.empty()){

		int t=q.front() ;
		q.pop() ;

		for(auto x:adj[t]){
			if(visited[x]==0)
			{
				q.push(x) ;
				visited[x]=1 ;
				size++ ;
			}
		}

	}

	return size ;

}


void solve(){
	
	int n,m ;
	cin>>n>>m ;

	vector<vector<int>> adj(n+1) ;
	
	
	for(int i=0;i<m;i++){
		int l,r ;
		cin>>l>>r;
		//cout<<l<<r ;
			
		adj[l].push_back(r) ;
		adj[r].push_back(l) ;
	
	}

	vector<int> visited(n+1) ;

	int res=0 ;

	for(int i=1;i<=n;i++){

		if(visited[i]==0)
		{
			int answer=bfs(i,adj,visited) ;
			res=max(res,answer) ;		
		}
	
	}		

	cout<<res ;

}
int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}


Measured memory_bytes: 15628
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int K, n; cin >> n >> K;
    vi x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }

    ll res = INF;
    rep(i1, n){
        rep(i2, i1, n){
            rep(i3, i2, n){
                rep(i4, i3, n){
                    int lx = min({x[i1], x[i2], x[i3], x[i4]});
                    int ly = min({y[i1], y[i2], y[i3], y[i4]});
                    int ux = max({x[i1], x[i2], x[i3], x[i4]});
                    int uy = max({y[i1], y[i2], y[i3], y[i4]});

                    int cnt = 0;
                    rep(j, n){
                        if(lx <= x[j] and x[j] <= ux and
                           ly <= y[j] and y[j] <= uy){
                            cnt++;
                        }
                    }

                    if(cnt >= K){
                        ll S = 1LL * max(1, ux - lx) * max(1, uy - ly);
                        chmin(res, S);
                    }
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256