akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[5];
    while(scanf("%d",&a[0])!=EOF){
        for(int i=1;i<5;i++)scanf(",%d",&a[i]);
        sort(a,a+5);
        if(a[0]==a[3]||a[1]==a[4])cout<<"four card"<<endl;
        else if((a[0]==a[1]&&a[3]==a[4])&&(a[1]==a[2]||a[2]==a[3]))cout<<"full house"<<endl;
        else if(a[0]==1&&a[1]==10&&a[2]==11&&a[3]==12&&a[4]==13)cout<<"straight"<<endl;
        else if(a[0]+1==a[1]&&a[1]+1==a[2]&&a[2]+1==a[3]&&a[3]+1==a[4])cout<<"straight"<<endl;
        else if(a[0]==a[2]||a[1]==a[3]||a[2]==a[4])cout<<"three card"<<endl;
        else{
            int cou=0;
            for(int i=0;i<4;i++){
                if(a[i]==a[i+1])cou++;
            }
            if(cou==2)cout<<"two pair"<<endl;
            else if(cou)cout<<"one pair"<<endl;
            else cout<<"null"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr long long mod = 1e9 + 7;

vector<long long> get_primes(long long n) {
    vector<long long> b(n + 1, true);
    b[0] = b[1] = false;
    for (long long i = 2; i * i <= n; i++) if (b[i]) for (long long j = i * 2; j <= n; j += i)b[j] = false;
    vector<long long> primes;
    for (long long i = 0; i < b.size(); i++) if (b[i]) primes.push_back(i);
    return primes;
}

int main() {

    long long N;
    cin >> N;

    auto primes = get_primes(1000);

    long long ans = 1;
    for (int i = 0; i < primes.size(); i++) {
        long long cnt = 0;
        long long d = primes[i];
        while (N / d) cnt += N / d, d = d * primes[i];
        ans *= (cnt + 1);
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}
















































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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N,M;
	cin>>N>>M;
	vint s(M);
	rep(i,M){
		int k;cin>>k;
		rep(j,k){
			int b;cin>>b;b--;s[i]|=1<<b;
		}
	}
	vint p(M);
	rep(i,M)cin>>p[i];

	int ans=0;
	rep(i,1<<N){
		bool ok=true;
		rep(j,M){
			int mask=i&s[j];
			if(__builtin_popcount(mask)%2!=p[j])ok=false;
		}
		if(ok)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
constexpr int  INF = 1000000007;
typedef long long ll;
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; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int n;
	cin >> n; 
	vector<int>a(n); rep0(i, n)cin >> a[i];
	int m;
	cin >> m;
	int temp = 0;
	int count = 0;
	int ans = 0;
	vector<int>b(m);
	vector<int>c(m);
	rep0(j, m)cin >> b[j] >> c[j];
	rep0(k, m) {
		temp = a[b[k] - 1];
		a[b[k]-1] = c[k];
		rep0(l, n) {
			count += a[l];
		}
		cout << count << endl;
		count = 0;
		a[b[k] - 1] = temp;
	}
	return 0;
}

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

int N, M, Q;
vector<vector<int>> A;

void f(vector<int> tmp, int n) {
  if (n == N) {
    A.push_back(tmp);
    return;
  }
  int j;
  if (tmp.size()) j = tmp.at(tmp.size() - 1);
  else j = 1;
  for (int i = j; i <= M; i++) {
    vector<int> tmp2;
    tmp2 = tmp;
    tmp2.push_back(i);
    f(tmp2, n + 1);
  }
}

int main() {
  cin >> N >> M >> Q;
  vector<vector<int>> V(Q, vector<int>(4));
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> V.at(i).at(j);
    }
  }
  vector<int> tmp;
  f(tmp, 0);
  int mx = 0;
  for (int i = 0; i < A.size(); i++) {
    int sum = 0;
    for (int j = 0; j < Q; j++) {
      int a = V.at(j).at(0);
      int b = V.at(j).at(1);
      int c = V.at(j).at(2);
      int d = V.at(j).at(3);
      if (A.at(i).at(b - 1) - A.at(i).at(a - 1) == c) sum += d;
    }
    mx = max(mx, sum);  
  }
  cout << mx << "\n";
}

Measured memory_bytes: 9712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int m1 = (int)Math.abs(a - c);
    int m2 = (int)Math.abs(a - b);
    int m3 = (int)Math.abs(b - c);
    String ans = "Yes";
    if((m1 > d) && ((m2 > d) || (m3 > d))) ans = "No";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import copy
A = []  # リングバッファ 0オリジン
B = []  # 回答

# 読み込み
n, q = map(int, input().split())
for i in range(n):
    name, time = input().split()
    time = int(time)
    A.append([name, time])
A.append([])

head = 0
tail = n
m = n + 1  # リングバッファサイズ

# 処理
time = 0  # 経過時間
while head != tail:
    if A[head][1] <= q:
        B.append(copy.deepcopy(A[head]))
        B[-1][1] = B[-1][1] + time
        time += A[head][1]
    else:
        A[head][1] = A[head][1] - q
        A[tail] = A[head]
        tail = (tail + 1) % m
        time += q
    head = (head + 1) % m
    # print('head : {} tail : {} B : {} time : {}'.format(head, tail, len(B), time))

    if head == tail:
        break

for i in B:
    print(i[0], i[1])



Measured memory_bytes: 19288
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    K = int(input().strip())
    S = input().strip()
    return K, S


def solve(K, S):
    if len(S) <= K:
        return S
    else:
        return S[:K] + "..."


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <cstring>
#include <list>
using namespace std;
list<int> lst;
char op[15];
int dd;
int n;
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    while(n--)
    {
        getchar();
        scanf("%s",op);
        if(strlen(op)<=6)
        {
            if(op[0]=='i')
            {
                scanf("%d",&dd);
                lst.push_front(dd);

            }
            else  if(op[0]=='d')
            {
                scanf("%d",&dd);
                for(list<int>::iterator iter=lst.begin(); iter!=lst.end();)
                {
                    if(*iter==dd)
                    {
                        lst.erase(iter);
                        break;
                    }
                    else iter++;
                }
            }
        }
        else
        {
            if(op[6]=='F')
            {
                lst.pop_front();
            }
            else if(op[6]=='L')
            {
                lst.pop_back();
            }

        }

    }
    for(list<int>::iterator iter=lst.begin(); iter!=lst.end(); iter++)
    {
        if(iter!=lst.begin()) printf(" ");
        printf("%d",*iter);
    }
    printf("\n");



    return 0;
}

Measured memory_bytes: 34388
# Driver code 
  
# Create a graph given in 
# the above diagram 

from collections import defaultdict as df
g=df(list)
for i in range(3):
    a,b=list(map(int,input().split()))
    g[a].append(b)
    g[b].append(a)
count1=0
count2=0
for i in g:
    if len(g[i])==2:
        count2+=1
    elif len(g[i])==1:
        count1+=1
if count2==2 and count1==2:
    print('YES')
else:
    print('NO')

  
# This code is contributed by Neelam Yadav 


Measured memory_bytes: 38384
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll h=in(),w=in(),n=in();
    ll m=max(h,w);
    cout<<(n+m-1)/m<<endl;
}


Measured memory_bytes: 508
a = input().split(" ")
x = int(a[2])
m = int(a[1])
n = int(a[0])
s= []
p = [] 
for i in range(n):
  aa = input().split(" ")
  ss = []
  for ii in aa:
    ss.append(int(ii))
  s.append(ss[1:])
  p.append(ss[0])
    
from itertools import chain, combinations
def getPrice(indexes):
  t = 0
  for i in indexes:
    t += p[i]
  return t
def doesSatisfy(indexes):
  t = 0
  alg_totals = [0] * m
  for i in indexes:
    for ii in range(m):
      alg_totals[ii] += s[i][ii]
  for i in alg_totals:
    if i < x:
      return False
  return True

def powerset(iterable):
    "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

  
lowest = -1  
for i in list(powerset(list(range(n)))):
  price = getPrice(i)
  if doesSatisfy(i) and lowest == -1:
    lowest = price
  elif doesSatisfy(i) and price < lowest:
    lowest = price

print(lowest)
  

Measured memory_bytes: 9344
using System;
using System.Linq;

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = CIN.LongArray();
            var A = AB[0];
            var B = AB[1];

            if (A > 9 || B > 9)
            {
                Console.WriteLine(-1);
                return;
            }
            
            Console.WriteLine(A * B);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 13268
m,d=map(int,input().split())

ans=0
for j in range(1,m+1):
  for i in range(11,d+1):
    l=[int(a) for a in str(i)]
    if 1 not in l:
      x=l[0]*l[1]
      if j==x:
        ans+=1

print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ma = 0;
		for(int i=0;i<N;i++){
			long vx = X[i];
			long vy = Y[i];
			for(int j=0;j<N;j++){
				if(i == j) continue;
				if(X[i] * X[j] + X[i] * Y[j] >= 0){
					vx += X[j];
					vy += Y[j];
				}
			}
			ma = Math.Max(ma, vx * vx + vy * vy);
		}
		
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				long vx = X[i] + X[j];
				long vy = Y[i] + Y[j];
				for(int k=0;k<N;k++){
					if(k == i || k == j) continue;
					if((X[i] + X[j]) * X[k] + (Y[i] + Y[j]) * Y[k] >= 0){
						vx += X[k];
						vy += Y[k];
					}
				}
				ma = Math.Max(ma, vx * vx + vy * vy);
			}
		}
		
		Console.WriteLine(Math.Sqrt(ma));
		
		
	}
	int N;
	long[] X,Y;
	public Sol(){
		N = ri();
		X = new long[N];
		Y = new long[N];
		for(int i=0;i<N;i++){
			var d = rla();
			X[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int n, a, b;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	if(n == 1){
		cout << "Hello World" << "\n";
	}else{
		cin >> a >> b;
		cout << a + b << "\n";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  int tmp=0;
  bool wakeup=true;
  int t=0;
  while(1){
    if(wakeup){
      if(tmp<=c&&c<=tmp+a){
        cout<<60*t+c<<endl;
        break;
      }
      tmp+=a;
      wakeup=false;
    }else{
      tmp+=b;
      wakeup=true;
    }
    if(tmp>=60){
      tmp%=60;
      t++;
    }
    if(t>60){
      cout<<-1<<endl;
      break;
    }
  }
  return 0;
}



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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  int n,m;cin>>n>>m;
  int ans = m*1900+(n-m)*100;
  while (m>0) {
    ans *= 2;
    m--;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;

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

    vector<int>C(N);

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

    int ans=0;
    for(int i=0;i<N;i++){
        if(V[i]>C[i]){
            ans+=V[i]-C[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define lli long long int
#define pb push_back
#define pii pair <int, int>
#define pll pair <lli, lli>
#define _F first
#define _S second
#define mset(x) memset(x, 0, sizeof(x))
#define fastio() ios_base::sync_with_stdio(0)

using namespace std;

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

	lli A[n], B[n];
	for(int i=0; i<n; i++)
		cin >> A[i] >> B[i];

	lli ans = 0;
	for(int i=n-1; i>=0; i--)
		ans += (B[i] - ((A[i] + ans) % B[i])) % B[i];

	cout << ans << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

bool isKaibun(int x) {
  string s = to_string(x);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == s[s.size() - 1 - i]) {
      continue;
    }
    return false;
  }
  return true;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){cin>>arr[i];}
	int res=0;
	for(int i=0;i<n;i++){
	    if(i%2==0 && arr[i]%2==1){res++;}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,MOD=1000000007,s[100001],ans;
ll f(ll x,ll y){
    if(y==0)return 1;
    if(y%2==0)return f(x,y/2)*f(x,y/2)%MOD;
    return x*f(x,y-1)%MOD;
}
int main(void){
    cin>>k>>n;
    for(int i=n;i>=1;i--){
        s[i]=f(n/i,k);
        //cout<<s[i]<<endl;
    }
    for(int i=n;i>=1;i--){
        ll cnt=2;
        while(1){
            if(cnt*i<=n){
                s[i]-=s[cnt*i];
                s[i]%=MOD;
            }
            else break;
            cnt++;
        }
    }
    for(ll i=n;i>=1LL;i--){
        ans+=(i*s[i])%MOD;
        ans%=MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

int main ()
{
    int N,A,B,fin,abroad;
    string S;

    cin >> N >> A >> B;
    cin >> S;

    fin = 0;
    abroad = 1;

    REPI(N)
    {
        if (S[i] == 'a'){
            if (fin < A+B)
            {
                fin++;
                cout << "Yes" << endl;
                continue;
            }                
        }else if (S[i] == 'b'){
            if (fin < A+B && abroad <= B){
                fin++;
                cout << "Yes" << endl;
                abroad++;
                continue;
            }
            abroad++;
        }
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	long long int a, b, k;
	cin >> a >> b >> k;
	if (a >= k) {
		a -= k;
	}
	else if (a + b >= k) {
		b -= (k - a);
		a = 0;
	}
	else {
		a = 0;
		b = 0;
	}
	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,G; cin>>N>>G;
    vint p(N),c(N);
    REP(i,N) cin>>p[i]>>c[i];

    int ans=1e9;
    REP(S,1<<N){
        int score=0,cnt=0;
        REP(i,N){
            if(S>>i&1){
                score+=100*(i+1)*p[i]+c[i];
                cnt+=p[i];
            }
        }
        for(int i=N-1;i>=0;i--){
            if(S>>i&1) continue;
            if(score<G){
                int s=100*(i+1);
                int c=min(p[i],(G-score+s-1)/s);
                score+=s*c;
                cnt+=c;
            }
        }
        if(score>=G) ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    vi vec(n);
    REP(i,n)cin>>vec[i];
    int ans=0;
    for(int i=0;i<n;){
        ans++;
        int a=i,b=i;
        while(a<n&&vec[a]<=vec[a+1])a++;
        while(b<n&&vec[b]>=vec[b+1])b++;
        i=max(a,b)+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;


int main() {
    int a,b;
    cin >> a >> b;
    int n;
    cin >> n;
    int s[n],f[n];
    for(int i = 0; i < n; i++) {
        cin >> s[i] >> f[i];
    }
    bool ok = true;
    int tmp[1001];
    for(int i = 0; i < 1001; i++) {
        tmp[i] = 0;
    }
    for(int i = 0; i < n; i++) {
        for(int j = s[i]; j < f[i]; j++) {
            tmp[j] = 1;
        }
    }
    for(int i = a; i < b; i++) {
        if(tmp[i] == 1) {
            ok = false;
        }
    }
    if(ok) cout << "0" << endl;
    else cout << "1" << endl;
}

Measured memory_bytes: 3096
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define lpton(i,n) for(int i=0;i<(int)n;i++)
#define lpto0(i,n) for(int i=n;i>-1;i--)
#define lpmn(i,m,n) for(i=m;i<n;i++)
#define ms(l,n,s) memset(l,n,s)
typedef struct rtree{
  int nnode;
  int nparent;
  int brn;
  int first;
  int last;
}rtree;
int dep;
void print(rtree*,int*,int);
int depth(rtree*,int);
char* type(rtree*,int);
int main(){
  int n,rn,cnt=0;
  int *cn;
  scanf("%d",&n);
  rtree *rt;
  rt=(rtree*)malloc(sizeof(rtree)*n);
  cn=(int*)malloc(sizeof(int)*n);
  ms(rt,-1,n*sizeof(rtree));
  lpton(i,n){
    scanf("%d",&rn);
    scanf("%d",&(rt+rn)->brn);
    (rt+rn)->nnode=rn;
    (rt+rn)->first=cnt;
    lpton(j,(rt+rn)->brn){
      scanf("%d",&*(cn+cnt));
      (rt+*(cn+cnt))->nparent=rn;
      cnt++;
    }
    (rt+rn)->last=cnt;
  }
  print(rt,cn,n);
  return 0;
}
void print(rtree *rt,int* cn,int n){
  int j,c;
  lpton(i,n){
    dep=0;
    printf("node %d: parent = %d, depth = %d, %s, [",(rt+i)->nnode,(rt+i)->nparent,depth(rt,i),type(rt,i));
    if((rt+i)->brn!=0)lpmn(j,(rt+i)->first,(rt+i)->last)printf("%d%s",*(cn+j),(j<(rt+i)->last-1)?", ":"]\n");
    else printf("]\n");
  }
}
int depth(rtree *rt,int i){
  if((rt+i)->nparent==-1)return dep;
  depth(rt,(rt+i)->nparent);
  return dep+=1;
}
char *type(rtree *rt,int i){
if((rt+i)->nparent==-1)return "root";
else if((rt+i)->brn==0)return "leaf";
else return "internal node";
}



Measured memory_bytes: 4112
#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<int, int>;

int main() {
    string s;
    cin >> s;
    string ans = "";
    rep(i, s.size()) { ans += 'x'; }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = nextInt()
	}
	return sl
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	as, bs, cs := nextInts(n), nextInts(n), nextInts(n)

	sort.Ints(as)
	sort.Ints(cs)
	var sum int
	for _, b := range bs {
		aCnt := lowerBound(as, b)
		cCnt := n - upperBound(cs, b)
		sum += aCnt * cCnt
	}

	fmt.Println(sum)
}

func lowerBound(a []int, x int) int {
	return sort.Search(len(a), func(i int) bool { return a[i] >= x })
}

func upperBound(a []int, x int) int {
	return sort.Search(len(a), func(i int) bool { return a[i] > x })
}


Measured memory_bytes: 6016
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var aLp = "abcdefghijklmnopqrstuvwxyz";
        var d = new Dictionary<string, int>();
        var d2 = new Dictionary<int, string>();
        for (int i = 1; i <= 26; i++)
        {
            var w = aLp.Substring(i - 1, 1);
            d[w] = i;
            d2[i] = w;
        }
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new string[n];
        for (int i = 0; i < n; i++) a[i] = Console.ReadLine().Trim();
        var ans = "";
        for (int i = 1; i <= 4; i++)
        {
            var hs = getP(a, d, i);
            if (hs.Count() == (int)Pow(26, i)) continue;
            else
            {
                if (i == 1) ans = getAns1(hs, d2);
                else if (i == 2) ans = getAns2(hs, d2);
                else if (i == 3) ans = getAns3(hs, d2);
                else ans = getAns4(hs, d2);
                break;
            }
        }
        Console.WriteLine(ans);
    }
    static string getAns4(HashSet<int> hs, Dictionary<int, string> d2)
    {
        for (int i = 1; i <= 26; i++)
            for (int j = 1; j <= 26; j++)
                for (int k = 1; k <= 26; k++)
                    for (int L = 1; L <= 26; L++)
                        if (hs.Add(i * 1000000 + j * 10000 + k * 100 + L)) return d2[i] + d2[j] + d2[k] + d2[L];
        return "";
    }
    static string getAns3(HashSet<int> hs, Dictionary<int, string> d2)
    {
        for (int i = 1; i <= 26; i++)
            for (int j = 1; j <= 26; j++)
                for (int k = 1; k <= 26; k++)
                    if (hs.Add(i * 10000 + j * 100 + k)) return d2[i] + d2[j] + d2[k];
        return "";
    }
    static string getAns2(HashSet<int> hs, Dictionary<int, string> d2)
    {
        for (int i = 1; i <= 26; i++)
            for (int j = 1; j <= 26; j++)
                if (hs.Add(i * 100 + j)) return d2[i] + d2[j];
        return "";
    }
    static string getAns1(HashSet<int> hs, Dictionary<int, string> d2)
    {
        for (int i = 1; i <= 26; i++)
            if (hs.Add(i)) return d2[i];
        return "";
    }
    static HashSet<int> getP(string[] a, Dictionary<string, int> d, int k)
    {
        var hs = new HashSet<int>();
        foreach (var x in a)
            for (int i = 0; i <= x.Length - k; i++)
            {
                var w = x.Substring(i, k);
                var t = 0;
                for (int j = 0; j < k; j++)
                    t += d[w.Substring(j, 1)] * (int)Pow(10, (k - j - 1) * 2);
                hs.Add(t);
            }
        return hs;
    }
}



Measured memory_bytes: 41720
import sys
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    l = 0
    r = max(A)

    while l+1 < r:
        count = 0
        length = (l+r) // 2
        for a in A:
            count += (a-1) // length

        if count <= k:
            r = length
        else:
            l = length

    print(r)


if __name__ == "__main__":
    main()


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

int main()
{
	int N,p = 0,w = 0,g = 0,y = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		if (S[0] == 'P')p = 1;
		if (S[0] == 'W')w = 1;
		if (S[0] == 'G')g = 1;
		if (S[0] == 'Y')y = 1;
	}

	if (p + w + g + y == 4)cout << "Four" << endl;
	else cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
for m, f, r in ((int(j) for j in i.split()) for i in iter(input, "-1 -1 -1")):
  if m == -1 or f == -1:
    print ('F')
  elif m + f >= 80:
    print ('A')
  elif m + f >= 65:
    print ('B')
  elif m + f >= 50 or (m + f >= 30 and r >= 50):
    print ('C')
  elif m + f >= 30:
    print ('D')
  else:
    print ('F')

Measured memory_bytes: 7736
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
int main()
{
	int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	X3=X2-(Y2-Y1);
	Y3=Y2+(X2-X1);
	X4=X3-(Y3-Y2);
	Y4=Y3+(X3-X2);
	printf("%d %d %d %d",X3,Y3,X4,Y4);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = (1e+9) + 7;
ll s,t;
vec memo(500010,-1);

ll dfs(ll now, ll parent, vector<bool> &mdl){
    if(memo.at(now) != -1) return memo.at(now);
    if(parent == now) return -1;
    ll ans = 0;
    if(parent == -1) parent = now;
    if(mdl.at(now)) {
        ll temp = dfs((now + t) % s, parent, mdl);
        if(temp == -1) ans = -1;
        else ans = temp+1;
    }
    memo.at(now) = ans;
    return ans;
}

int main() {
    string S, T;
    cin >> S >> T;
    s = S.size(), t = T.size();
    if(t == 1){
        ll ans = 0, temp = 0;
        rep(i,s*2){
            if(S[i%s] == T[0]){
                ++temp;
                ans = max(ans,temp);
            }else{
                temp = 0;
            }
        }
        cout<<(ans == s*2 ? -1 : ans)<<endl;
        return 0;
    }
    vec table(t, 0);
    table[0] = -1;
    table[1] = 0;
    ll I = 2, J = 0;
    while(I < t){
        if(T.at(I-1) == T.at(J)){
            table.at(I) = J+1;
            ++I;
            ++J;
        }else if(J > 0){
            J = table.at(J);
        }else{
            table.at(I) = 0;
            ++I;
        }
    }
    I = 0; J = 0;
    vector<bool> mdl(s,false);
    while(I < s){
        if(S.at((I+J)%s) == T.at(J)){
            if(J == t-1){
                mdl.at(I) = true;
                I = I + J - table.at(J);
                J = table.at(J);
            }else{
                ++J;
            }
        }else{
            I = I + J - table.at(J);
            if(J > 0) {
                J = table.at(J);
            }else{
                J = 0;
            }
        }
    }
    ll ans = 0;
    rep(i,s){
        if(memo.at(i) != -1) continue;
        ll temp = dfs(i,-1,mdl);
        if(temp == -1){
            ans = -1;
            break;
        }else{
            ans = max(ans,temp);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 24840
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int N;
    cin >> N;
    int ans = N/3;
    cout << ans << endl;
    

}


Measured memory_bytes: 256
N, A, B=map(int,input().split())
import sys
for i in range (1,1000000):
    if i%2==1:
        if A+1!=B:
            A+=1
        elif A!=1:
            A-=1
        else:
            print ('Borys')
            sys.exit()
            
    if i%2==0:
        if B-1!=A:
            B-=1
        elif B!=N:
            B+=1
        else:
            print('Alice')
            sys.exit()
            


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

#define oo ll(1e14)
#define maxn 5003

using namespace std;
typedef long long ll;

int n;

int a[maxn];

ll dp[maxn][maxn][2];
int sz[maxn];

vector < int > g[maxn];

void dfs(int u, int du) {
  if (a[u] >= 0)
    dp[u][1][1] = 1;
  dp[u][1][0] = a[u];
  sz[u] = 1;

  for (auto v : g[u]) {
    if (v == du) continue;

    dfs(v, u);
    sz[u] += sz[v];

    for (int j = sz[u]; j > 0; --j) {
      bool flag = 0;
      ll mi = oo;

      for (int k = max(1, j - sz[u] + sz[v]); k <= j && k <= sz[v]; ++k) {
        flag |= (dp[u][j - k + 1][1] & dp[v][k][1]);
        mi = min(mi, dp[u][j - k + 1][0] + dp[v][k][0]);

        if (dp[v][k][0] < 0 || dp[v][k][1]) {
          mi = min(mi, dp[u][j - k][0]);
          flag |= dp[u][j - k][1];
        }
      }

      dp[u][j][1] = flag;
      dp[u][j][0] = mi;
    }
  }

  return;
}

int main(){

  ios_base::sync_with_stdio(0);

  cin >> n;

  for (int i = 1; i <= n; ++i)
    cin >> a[i];

  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;

    g[u].push_back(v);
    g[v].push_back(u);
  }

  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= n; ++j) {
      dp[i][j][0] = oo;
      dp[i][j][1] = 0;
    }

  dfs(1, 1);

  for (int j = 1; j <= n; ++j)
    if (dp[1][j][0] < 0 || dp[1][j][1]) {
      cout << j - 1;
      break;
    }
  return 0;

}


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

using namespace std;
typedef long long ll;

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

int main()
{
    string a, b;
    cin >> a >> b;
    reverse(all(a));

    cout << ((a == b) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-


n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
if 2 not in a:
    print(-1)
else:
    cnt = 0
    before_num = 1
    lighted_bottons = [0 for i in range(n + 1)]
    while True:
        cnt += 1
        if a[before_num - 1] == 2:
            print(cnt)
            break
        else:
            if lighted_bottons[a[before_num - 1]] == 1:
                print(-1)
                break
            before_num = a[before_num - 1]
            lighted_bottons[before_num] = 1

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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl


int main() {

	fast_cin;
	
	long long a,b,ans;
	string s;

	cin >> a >> s;
	
	b = 0;

	for(int i = 0; i < (int)s.size(); i++) {
		
		if(s[i] == '.') continue;

		b *= 10;
		b += s[i] - '0';
	}

	ans = a * b;
	ans /= 100;
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 3652
#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 h, w, k;
    int ans = 0;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(i, 1 << h){
        rep(j, 1 << w){
            int sum = 0;
            rep(k, h){
                rep(l, w){
                    if(s[k][l] == '#' && !(i & (1 << k)) && !(j & (1 << l))) sum++;
                }
            }
            if(sum == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	int N;
	cin >> N;
	
	int ans = 100000;
	for(int i = 1; i < N; i++){
		int n1 = i;
		int n2 = N - i;
		int S = 0;
		while(n1 > 0){
			S += n1 % 10;
			n1 /= 10;
		}
		while(n2 > 0){
			S += n2 % 10;
			n2 /= 10;
		}
		ans = min(ans, S);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int n;cin>>n;
    deque<int> b;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(i%2==0)
            b.push_back(a);
        else
            b.push_front(a);
    }
    if(n%2==0){
        for(int i=0;i<b.size();i++)
            cout<<b[i]<<" ";
    }
    else{
        for(int i=0;i<b.size();i++)
            cout<<b[b.size()-1-i]<<" ";
    }
    return 0;
}

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

using namespace std;
#define int long long
typedef pair <int, int> ii;

const int N = 1e5 + 5;
int n, val[N], k;
vector <int> adj[N];

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

	cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int k;
	cin >> k;
	memset(val, -1, sizeof val);
	priority_queue <ii, vector <ii>, greater <ii>> pq;
	for (int i = 1; i <= k; ++i) {
		int v, p;
		cin >> v >> p;
		val[v] = p;
		pq.push({p, v});
	}
	while (!pq.empty()) {
		int v = pq.top().second;
		int p = pq.top().first;
		pq.pop();
		for (int u : adj[v]) {
			if (~val[u]) {
				if (abs(val[u] - val[v]) != 1) {
					cout << "No" << endl;
					return 0;
				}
			} else {
				val[u] = val[v] + 1;
				pq.push({val[u], u});
			}
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i <= n; ++i)
		cout << val[i] << endl;

	return 0;
}

Measured memory_bytes: 12276
from math import gcd

N = int(input())
A = tuple(map(int, input().split(' ')))

left = []
right = []

left.append(A[0])
for a in A[1:]:
    left.append(gcd(left[-1], a))

right.append(A[-1])
for a in A[-2::-1]:
    right.append(gcd(right[-1], a))

right = list(reversed(right))

ans = [left[-2], right[1]]

for i in range(1, len(left) - 1):
    ans.append(gcd(left[i - 1], right[i + 1]))

print(max(ans))


Measured memory_bytes: 25024
<?php
  fscanf(STDIN,"%d%d", $n , $y);
  const SEN = 1000;
  const GO = 5000;
  for($i=0; $i<=$n; $i++){
      for($j=0; $j<=$n; $j++){
          if($i+$j<=$n){
              $man = $y - ($i*SEN + $j*GO);
              if($man%10000 == 0 && $i+$j+($man/10000) == $n){
                  echo ($man/10000)." ".$j." ".$i;
                  exit;
              }
          }
      }
  }
  echo "-1 -1 -1";

Measured memory_bytes: 4728
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    int a[3],k;cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a,a+3,greater<>());
    p(a[0]*pow(2,k)+a[1]+a[2])
}

Measured memory_bytes: 256
// AOJ 2769: 28
// 2018.1.6 bal4u@uu

#include <stdio.h>
#include <math.h>

#define HASHSIZ 1000033
long long hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

int lookup(long long n)
{
	long long *p = hash + (int)(n % HASHSIZ);
	while (*p) {
		if (*p == n) return 1;
		if (++p == hashend) p = hash;
	}
	return 0;
}

void insert(long long n)
{
	long long *p = hash + (int)(n % HASHSIZ);
	while (*p) {
		if (*p == n) return;
		if (++p == hashend) p = hash;
	}
	*p = n;
}

int sz;
long long p[524300];		// 2^19
int ans;

//#define getchar_unlocked()  getchar()
long long in()
{
	long long n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(long long n, int id, int s)
{
	int i, a, b;
	long long n1;

	if (n & 1) return 0;
	if (n == 2 || n == 4 || n == 8) {
		if (n == 2) { if (s+1 > ans) ans = s+1; return 1; }
		if (n == 4) { if (s+2 > ans) ans = s+2; return 1; }
		if (n == 8) { if (s+3 > ans) ans = s+3; return 1; }
	}
	if (n < 15) return 0;

	b = (int)sqrt((double)n);
	for (i = id; p[i] <= b; i++) {
		if (n % p[i]) continue;
		n1 = n / p[i], a = 1;
		while (n1 % p[i] == 0) n1 /= p[i], a++;
		if (n1 == 1) {
			if (s+a > ans) ans = s+a; return 1;
		}
		while (a >= 0) {
			if (calc(n1, i+1, s+a)) return 1;
			n1 *= p[i], a--;
		}
	}
	if (lookup(n)) { if (s+1 > ans) ans = s+1; return 1; }
	return 0;
}

int main()
{
	int i, j, k, k2;
	long long n, t;

	sz = 3;
	p[1] = 2, p[2] = 8, insert(2), insert(8);
	for (k = 1, i = 2; i <= 19; i++, k = k2) {
		k2 = k << 1;
		for (j = k; j < k2; j++) {
			t = p[j]*10;
			t += 2, p[sz++] = t, insert(t);
			t += 6, p[sz++] = t, insert(t);
		}
	}

	n = in();
	if (n & 1) { puts("-1"); return 0; }
	ans = 0;
	calc(n, 1, 0);
	if (ans <= 0) puts("-1");
	else printf("%d\n", ans);
	return 0;
}




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

const int MAX = 510000;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
	int N,K,R;
	cin >> N >> K;
	R = N-K;
	for(int i=1;i<=K;i++){
		cout << (COM(N-K+1,i)*COM(K-1,i-1))%MOD << endl;
	}
}

Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

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

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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

bool edges[51][51] = {false};

int main() {
    ll N, M;
    cin>>N>>M;
    for (ll m = 0; m < M; m++) {
        ll a, b;
        cin>>a>>b;
        edges[a-1][b-1] = edges[b-1][a-1] = true;
    }

    ll ans = 0;
    vector<bool> flags(N);
    function<void(ll)> dfs = [&](ll v) {
        if (flags[v]) return;
        flags[v] = true;
        for (ll to = 0; to < N; to++) {
            if (edges[v][to]) dfs(to);
        }
    };
    for (ll a = 0; a < N; a++) {
        for (ll b = a + 1; b < N; b++) {
            if (!edges[a][b]) continue;

            edges[a][b] = edges[b][a] = false;

            fill(begin(flags), end(flags), false);
            dfs(0);
            for (ll n = 1; n < N; n++)
                if (!flags[n]) {
                    ans++;
                    break;
                }

            edges[a][b] = edges[b][a] = true;
        }
    }
    cout<<ans<<endl;
}

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

int main(){

  int x,a=0,b=0,c=0,q=-1,p=-1;

  for(int i=0;i<10;i++){
   cin >> x;
  
   if(x>c){
    if(x>b){
      if(x>a){
	q=a;
	a=x;
      }
      if(q!=-1){
	p=b;
	b=q;
      }else{
	p=b;
	b=x;
      }
    }
    if(p!=-1){
      c=p;
    }else{
      c=x;
    }
   }
   p=-1;
   q=-1;
  }
      
  cout << a << endl;
  cout << b << endl;
  cout << c << endl;
	  
	  

 return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define INT long long
#define MOD 1000000007
#define OO 99999998765432100
using namespace std;
INT x, y, p;

int main()
{
    ios::sync_with_stdio(false);
    cin>>x>>y;
    if( x == 1 ) p = 300000;
    else if( x == 2 ) p = 200000;
    else if( x == 3 ) p = 100000;
    if( y == 1 ) p += 300000;
    else if( y == 2 ) p += 200000;
    else if( y == 3 ) p += 100000;
    if( x == 1 and y == 1 ) p += 400000;
    cout<<p<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(i, c) ((c).find(i) != (c).end())
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define foreach(i, c) for(auto i : c)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watchc(x) TRACE(cerr << #x" = "); for(auto __i : x) cerr << __i << " "; cerr << endl

//=========================

string p[10] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};

void run_test() {
	int n; cin >> n;
    cout << p[n%10] << endl;
}

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t;
	//while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	infile = ifstream("input.in");
	if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl;
	cerr << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	if(infile.good()) infile.close();
}


Measured memory_bytes: 3860
var
	n,i,j,ans,p,f,now,c:Longint;
	sum,t,v:array[0..101]of Longint;
begin
	read(n);
	for i:=1 to n do begin
		read(t[i]);
		t[i]:=t[i]*2;
		sum[i]:=sum[i-1]+t[i];
	end;
	for i:=1 to n do begin
		read(v[i]);
		v[i]:=v[i]*2;
	end;
	for i:=1 to sum[n]do begin
		if i>sum[f] then inc(f);
		now:=v[f];
		for j:=0 to n+1 do begin
			if j<f then c:=v[j]+i-sum[j] else if j>f then c:=v[j]+sum[j-1]-i else c:=now;
			if now>c then now:=c;
		end;
		ans:=ans+p+now;
		p:=now;
	end;
	writeln(ans/8:0:9);
end.


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  8 08:28:30 2019

@author: avina
"""

n = int(input())
l = list(map(int, input().split()))
dp= [0]*n

for i in range(1,n):
    b = 1e6
    a = dp[i-1] + abs(l[i] - l[i-1])
    if i -2 >-1:
        b = dp[i-2] + abs(l[i] - l[i-2])
    dp[i] = min(a,b)    
print(dp[-1])

Measured memory_bytes: 13928