akhauriyash/Code-Regression huggingface dataset:
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val X, Y = sc.nextLong()

    def shifts(cnt: Int, a: Long): Int = {
      if (a > Y) cnt
      else shifts(cnt + 1, a << 1)
    }

    val ans = shifts(0, X)

    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) {
      f(i)
      i += 1
    }
  }

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    var i = 0
    while(i < n) {
      res(i) = f(i)
      i += 1
    }
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }
  }
}


Measured memory_bytes: 25520
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(0);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int a;
        string b;
        cin>>a>>b;
        int mult = b[0] - '0';
        int diff = b[2] - '0';
        diff = diff*10 + (b[3] - '0');
        int ans = a*mult + (a * diff)/100;
        // cout<<a<<"  "<<b<<endl;
        cout<<ans;
    }
    
    return 0;
}

Measured memory_bytes: 3644
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

xor=a[0]^a[1]
for i in range(2,n):
  xor=xor^a[i]

ans=[]
for i in a:
  ans.append(i^xor)

print(*ans)

Measured memory_bytes: 31472
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.nextLine();
    int N = Integer.parseInt(sc.next());
    String ans = "";
    for(int i = 0; i < S.length(); i+=N){
      String T = String.valueOf(S.charAt(i));
      ans = ans+T;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 27860
from sys import stdin
from operator import add,sub,mul

stack = list()
for i in stdin.readline().split():
    if str.isdecimal(i):
        stack.append(int(i))
    else:
        operation = None
        if i == "+":
            operation = add
        elif i == "-":
            operation = sub
        elif i == "*":
            operation = mul
        operand2 = stack.pop()
        operand1 = stack.pop()
        stack.append(operation(operand1, operand2))

print(stack.pop()) 


Measured memory_bytes: 5676
N, K = map(int, input().split())

d = [None] * K
sunuke = [0] * N
A = []
for i in range(K):
    d[i] = int(input())
    A.append(list(map(int, input().split())))

for members in A:
    for member in members:
        sunuke[member - 1] = 1

print(N - sum(sunuke))


Measured memory_bytes: 9140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

map<char, vector<int >> m;

int dfs(int keta, string S, int s_index) {
  if (keta == 3) {
//    cout << S << endl;
    return 1;
  }

  int cnt = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j : m[i+'0']) {
      if (s_index <= j) {
        string s2 = S + to_string(i);
//        cout << "call dfs" << keta + 1 << ", " << s2 << " " << j + 1 << endl;
        cnt += dfs(keta + 1, s2, j + 1);
        break;
      }
    }
  }
  return cnt;
}

int main() {
  int N; cin >> N;
  string S; cin >> S;
  for (int i = 0; i < S.size(); ++i) {
    m[S[i]].push_back(i);
  }
#if 0
  cout << "INPUT:" << endl;
  for (auto p : m) {
    cout << p.first << ":";
    for (auto v : p.second) cout << v << " ";
    cout << endl;
  }
  cout << "PROCESS" << endl;
#endif
  cout << dfs(0, "", 0) << endl;;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N;
vector<int> G[100005];
int dp[100005];

int calc(int p, int x){
  if(dp[p] != -1) return dp[p];
  int ret = 0;
  vector<int> res;
  rep(i,G[p].size()){
    if(G[p][i] == x) continue;
    res.push_back(calc(G[p][i], p));
  }
  if(res.size()==0) ret = 0;
  else if(res.size()==1) ret = res[0] + 1;
  else{
    rep(i,res.size()){
      ret ^= (res[i]+1);
    }
  }
  return dp[p] = ret;
}

int main(){
  cin >> N;
  rep(i,N-1){
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  rep(i,100005){
    dp[i] = -1;
  }
  
  calc(1, 0);

  if(dp[1] != 0) cout << "Alice" << endl;
  else cout << "Bob" << endl;
  
  return 0;
}



Measured memory_bytes: 18560
w,h,m=[int(_) for _ in input().split()]
hw=[[int(_) for _ in input().split()]for i in range(m)]

yoko=[0 for i in range(w)]
tate=[0 for j in range(h)]

for i in range(m):
    yoko[hw[i][0]-1]+=1
    tate[hw[i][1]-1]+=1

mt =max(tate)
my=max(yoko)

cu=yoko.count(my)*tate.count(mt)
c=0
for i in range(m):
    if yoko[hw[i][0]-1]==my and tate[hw[i][1]-1]==mt:
        # print(hw[i])
        c+=1
ans= mt+my
# print(tate,yoko)
# print(c,cu)
if c== cu:
    ans-=1
print(ans)

Measured memory_bytes: 63656
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = []
    for _ in range(n):
        a.append(int(input()))
    max_l, max_r = [a[0]], [a[-1]]
    for i in range(1, n):
        max_l.append(max(max_l[i-1], a[i]))
        max_r.append(max(max_r[i-1], a[-(i+1)]))
    max_r = max_r[::-1]
    for i in range(n):
        if i == 0:
            print(max_r[1])
        elif i == n - 1:
            print(max_l[-2])
        else:
            print(max(max_l[i-1], max_r[i+1]))

if __name__ == '__main__':
    main()

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


/**
 * AIZU ONLINE JUDGE
 * 0405
 *  2020/5/6
 */
public class Main {



    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        int r = 0;
        if ('A' <= N && N <= 'Z')
            r = 1;
        else if ('a' <= N && N <= 'z')
            r = 2;
        result.printf("%d\n", r);

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 26536
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int H = in.nextInt();
            int A = in.nextInt();
            int attacks = 0;
            while (H > 0)
            {
                H -= A;
                attacks++;
            }
            out.print(attacks);
        }

    }
}



Measured memory_bytes: 23124
//Modulo Summation

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n;cin>>n;
    vector<int>a(n);
    rep(i,0,n)cin>>a[i];
    n=a.size();
    cout<<accumulate(range(a),0)-n<<nnn;
    return 0;
}

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

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter0(i, n) for (int i = 0; i < n; ++i)

typedef pair<int, int> pii;

#define fi first
#define se second

const int NR = 1010;

int n, m, K, dt[NR][NR];
char s[NR][NR];
pii q[NR * NR];

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

bool valid(int x, int y) {
	return 1 <= x && x <= n && 1 <= y && y <= m && s[x][y] == '.';
}

int mind(int x, int y) {
	return min(min(x - 1, n - x), min(y - 1, m - y));
}

int main() {
//	freopen("14C.in", "r", stdin);
	scanf("%d%d%d", &n, &m, &K);
	int sx, sy;
	iter(i, n) {
		scanf("%s", s[i] + 1);
		iter(j, m) { if (s[i][j] == 'S') sx = i, sy = j; else dt[i][j] = -1; }
	}

	int h, t;

	q[h = t = 1] = pii(sx, sy);

	int ans = 1 + (mind(sx, sy) + K - 1) / K;

	while (h <= t) {
		pii u = q[h++]; int x = u.fi, y = u.se;
//		printf("dt[%d][%d]=%d\n", x, y, dt[x][y]);
		iter0(d, 4) {
			int _x = x + dx[d], _y = y + dy[d];
			if (valid(_x, _y) && dt[_x][_y] == -1) dt[_x][_y] = dt[x][y] + 1, q[++t] = pii(_x, _y);
		}

		if (dt[x][y] <= K) ans = min(ans, 1 + (mind(x, y) + K - 1) / K);
	}

	printf("%d\n", ans);
	return 0;
}


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

bool prime(int N) {
    bool ans = true;
    for (int i = 2; i * i <= N; ++i) {
        if (N % i == 0) ans = false;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    
    vector<int> a;
    int x = 11;
    while (a.size() < N) {
        if (prime(x)) a.push_back(x);
        x = x + 10;
    }
    
    for (int i = 0; i < N - 1; ++i) cout << a[i] << " ";
    cout << a[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=2e5+5;
ll i,j;

/*


*/

vi dp(N,1e15);
void solve(){
    in2(n,k);
    vi a(n); lelo(a);
  	dp[0]=0;
  	for(i=0;i<n;i++){
  		for(j=i+1;j<=i+k;j++){
  			dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
  		}
  	}
  	ce(dp[n-1]);
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/

  

Measured memory_bytes: 5576
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int x;
  cin >> x;
  ll fivehun = 0;
  ll five = 0;
  fivehun = x / 500;
  five = x % 500 / 5;
  cout << fivehun * 1000 + five * 5 << "\n";
  return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long

using namespace std;

int n,a[111];
bool d=true;

int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0)
			d&=(a[i]%3==0||a[i]%5==0);
	}
	cout<<(d?"APPROVED":"DENIED")<<endl;
	return 0;
}


Measured memory_bytes: 256
K, N = list(map(int, input().split()))
a = list(map(int, input().split()))

biggestDist = 0
for i in range(len(a)):
    if i == len(a)-1:
        aDist = a[0]-(a[i]-K)
        biggestDist = max(aDist, biggestDist)
    else:
        dist = a[i+1]-a[i]
        biggestDist = max(dist, biggestDist)
print(K-biggestDist)

Measured memory_bytes: 26100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}

int main() {
  int n;
  cin >> n;
  for(int i=n;i<=1e5+3;i++){
    if(isprime(i)){
      cout << i << endl;
      break;
    }
  }
}

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

int main() {
  int S; cin >> S;  //sheep
  int W; cin >> W;  // wolf

  if (W>=S){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 3596
import heapq
def calc_Inversion(num):
    return num * -1

n, m = map(int, input().split())
a = list(map(calc_Inversion, list(map(int, input().split()))))

heapq.heapify(a)

for m_num in range(m):
    heapq.heappush(a, int(heapq.heappop(a) / 2))

print(sum(a) * -1)


Measured memory_bytes: 14180
from collections import defaultdict
s = input()
n = len(s)
a = [0]*n
p=2019
r = defaultdict(int)
a = int(s)
r[a%p]+=1
for i in range(n):
    a = (a%p-int(s[i])%p*pow(10,(n-1-i),p))%p
    r[a]+=1
#print(r)
ans = 0
cnt=1
for i in r.values():
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 72884
#include<iostream>
#include<vector>
#include<string>

using namespace std;

void solve(long long a, long long b){
	cout<<(a + b + 1) / 2 <<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    std::cin >> a;
    long long b;
    std::cin >> b;
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<ll, ll>;
const int mod = 1000000007;
const int INF = 1001001001;


int main(){
    int n, m;
    cin >> n >> m;
    vector<P> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    int index = 0;
    auto comp = [](P a, P b) {
        return a.second<b.second;
    };
    ll ans = 0;
    priority_queue<P, vector<P>, decltype(comp)> q {comp};
    
    for (int i=1; i<=m; i++) {
        
        while (p[index].first<=i && index<n) {
            q.push(p[index]);
            index++;
        }
        
        if (!q.empty()) {
            P now = q.top();
            q.pop();
            ans += now.second;
        }
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3956
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Collections;

public class Main {
    static final int MAX_LENGTH = 150; // 幅と高さの上限

    public static void main(String[] args) {
	final int MAX_LENGTH = 150;
	Scanner sc = new Scanner(System.in);
	
	ArrayList<Square> squares = new ArrayList<Square>();
	
	// iは高さ、jは幅
	for (int i = 1; i <= MAX_LENGTH; i++) {
	    for (int j = i + 1; j <= MAX_LENGTH; j++) {
		Square s = new Square(i, j);
		squares.add(s);
	    }
	}
	Collections.sort(squares, new SquareComp());

	
	while (true) {
	    int h = sc.nextInt();
	    int w = sc.nextInt();
	    if (h == 0) {
		break;
	    }
	    
	    int diagonal = diagSquare(h, w); // 入力した長方形の対角線の長さの2乗
	    Square tmp = new Square(h, w);
	    
	    // 方法1. 素直に総当たりする
	    //all(h, w, diagonal);
	    
	    // 方法2. ソートして2分探索
	    binary(squares, tmp);
	}
    }
    
    public static int diagSquare(int h, int w) {
	return h * h + w * w;
    }
    
    public static void all(int h, int w, int diagonal) {
	// iは高さ、jは幅
	int resultH = 0;
	int resultW = 0;
	int resultD = Integer.MAX_VALUE;
	
	// iは高さ、jは幅
	for (int i = 1; i <= MAX_LENGTH; i++) {
	    for (int j = i + 1; j <= MAX_LENGTH; j++) {
		int diagonalT = diagSquare(i, j);
		// データセットより大きい長方形のみ対象
		if (diagonal < diagonalT || diagonal == diagonalT && h < i) {
		    // 今までの結果より小さければ結果を更新
		    if (diagonalT < resultD || diagonalT == resultD && i < resultH) {
			resultH = i;
			resultW = j;
			resultD = diagonalT;
		    }
		}
	    }
	}
	System.out.println(resultH + " " + resultW);
    }
    
    public static void binary(ArrayList<Square> squares, Square tmp) {
	
	int n = Collections.binarySearch(squares, tmp, new SquareComp());
	Square ans = squares.get(n+1);
	System.out.println(ans.h + " " + ans.w);
	
	/*
	for (int i = 0; i < squares.size(); i++) {
	    System.out.println(squares.get(i));
	}
	*/
    }
}

class Square {
    int h;
    int w;
    int diagonal;
    
    public Square(int h, int w) {
	this.h = h;
	this.w = w;
	this.diagonal = h * h + w * w;
    }
    
    public boolean equals(Square a) {
	return a.h == this.h && a.w == this.w;
    }
    
    public String toString() {
	return "(" + h + " " + w + " " + diagonal + ")";
    }
}

class SquareComp implements Comparator<Square> {
    public int compare(Square a, Square b) {
	if (a.diagonal < b.diagonal || a.diagonal == b.diagonal && a.h < b.h) {
	    return -1;
	} else if (a.equals(b)) {
	    return 0;
	} else {
	    return 1;
	}
    }
}

Measured memory_bytes: 35080
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        _l: usize,
        s: [String; n],
    }
    let mut s = s;
    s.sort();
    println!("{}", s.concat());
}

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

int main(){
	
	int n, val;
	vector <int> a;

	cin >> n;	
	for(int i = 0; i < n; i ++){
		cin >> val;
		a.push_back(val);
	}

	int res = 0;
	int prev = a[0];
	int adj_count = 1;
	for(int i = 1; i < n; i ++){
		if(a[i] == prev){
			adj_count ++;
		}
		else{
			prev = a[i];
		}
		if(adj_count == 2){
			res ++;
			i ++;
			prev = a[i];
			adj_count = 1;
		}
	}

	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007


int main()
{
	int a, b;
	cin >> a >> b;
	if(a + b >= 10) cout << "error" << endl;
	else cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    in >> a >> b;

    ll k = (a+b) / 2;
    if(abs(a - k) == abs(b - k)){
        out << k << endl;
    }else{
        out << "IMPOSSIBLE" << endl;
    }
}


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

int main(){
  int N,K,num;
  num = 0;
  cin >> N >> K;
  int h[N];
  for(int i=0;i<N;i++){
    cin >> h[i];
  }
  for(int i=0;i<N;i++){
    if(h[i] >= K){
      num++;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

vvi nex;

int main() {

	string s;
	cin >> s;

	int ans = INF;

	bool all = true;
	rep(i, s.size() - 1)if (s[i] != s[i + 1])all = false;
	if (all) { cout << 0 << endl;return 0; }
	
	rep(i, 26) {
		
		char c = 'a' + i;
		string ss = s;
		int cnt = 0;

		while (true) {

			string t = "";
			bool allc = true;
			rep(j, ss.size() - 1) {
				if (ss[j] == c || ss[j + 1] == c)t += c;
				else { allc = false; t += '?'; }
			}
			cnt++;
			if (allc)break;
			ss = t;
			
		}

		ans = min(ans, cnt);


	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    set<char> hina;
    REP(i, n) {
        char s;
        cin >> s;
        hina.insert(s);
    }
    cout << (hina.size() == 3 ? "Three" : "Four") << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    double a,ans=0;
    rep(i,n){
        cin>>a;
        ans=ans+1/a;
    }
    ans=1/ans;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3792
using System;

        public class Program
        {
            public static void Main(string[] args)
            {
            int count = int.Parse(Console.ReadLine());
            int num = int.Parse(Console.ReadLine());
            int answer = 1;

            for (int i = 0; i < count; i++)
            {
                answer = Math.Min(answer * 2, answer + num);
            }

            Console.WriteLine(answer);
            }
        }

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long long n,h,m=0L,i,a;
    cin>>n>>h;
    vector<long long>b(n);
    for(i=0LL;i<n;i++){cin>>a>>b[i];m=max(m,a);}
    sort(b.rbegin(),b.rend());
    for(i=0LL;h>0&&b[i]>m&&i<n;i++)h-=b[i];
    cout<<(h>0LL?(h+m-1LL)/m:0LL)+i<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int digSum(int n){
  int ans=0;
  while(n){
    ans += n%10;
    n /= 10;
  }
  return ans;
}

int main(void){
  int n;
  cin >> n;
  cout << (n%digSum(n)==0?"Yes":"No") << endl;
  
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int tmp=1,ans=0;
  while(tmp<b){
    tmp+=a-1;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  vector<long long> a(N);
  vector<pair<long long, int>> bc(M);
  vector<long long> c;
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < M; ++i) {
    int b; long long c;
    cin >> b >> c;
    bc[i] = make_pair(c, b);
  }
 
  sort(a.begin(), a.end());
  sort(bc.begin(), bc.end(), greater<pair<long long, int>>());
 
  int cur = 0;
  for (int i = 0; i < N; ++i) {
    if (cur >= bc.size()) break;
    if (a[i] < bc[cur].first) {
      a[i] = bc[cur].first;
      bc[cur].second--;
    }
    if (bc[cur].second <= 0) cur++;
  }
  long long ans = 0;
  for (int i = 0; i < N; ++i) ans += a[i];
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int M = scn.nextInt();

    ArrayList<Data> data = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      int A = scn.nextInt();
      int B = scn.nextInt();
      data.add(new Data(A, B));
    }

    Collections.sort(data, new Comparator<Data>() {
      public int compare(Data d1, Data d2) {
        return Long.compare(d1.price, d2.price);
      }
    });

    long expense = 0;
    int drinkCount = 0;
    for (Data d : data) {
      drinkCount += d.stock;
      expense += d.stock * d.price;

      if (drinkCount >= M) {
        int excess = drinkCount - M;
        expense -= excess * d.price;
        break;
      }
    }

    System.out.println(expense);
  }

  public static class Data {
    private long price;
    private int stock;

    Data(long a, int b) {
      this.price = a;
      this.stock = b;
    }
  }

}


Measured memory_bytes: 65508
#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 getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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 ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int main(void){
	int t;
	cin >> t;
	rep(i,t){
		int n,d;
		cin >> n >> d;
		int ans=127*(n-1);
		if(n%2==1)
			ans+=d;
		else
			ans+=(127^d);
		cout << ans << endl;
	}	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  bool f=true;
  rep(i,n-1)if(s[i].back()!=s[i+1].front()) f=false;
  set<string> a;
  rep(i,n)
  a.insert(s[i]);
  bool b=true;
  if(a.size()!=s.size())b=false;
  if(f&&b)
  cout <<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#define N 100001

using namespace std;

int n;
int a[N];
bool dp[N][2];
bool vis[N][2] = {0};

bool solve(int k, int p)
{
	//cout << k ;
	if (k == 0)
		return false;

	if (vis[k][p])
		return dp[k][p];

	vis[k][p] = true;

	for (int i = 0; i < n; i++)
		if (k >= a[i] && !solve(k - a[i], 1 - p))
			return dp[k][p] = true;

	return dp[k][p] = false;
}

int main()
{
	int k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cout << (solve(k, 0) ? "First" : "Second") << endl;
	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int lim = 1e5;

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

  vector<int> v;
  
  v.push_back(1);

  for(int j=6; j<=lim; j*=6){
    v.push_back(j);
  }

  for(int j=9; j<=lim; j*=9){
    v.push_back(j);
  }

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

  vector<vector<int>> dp(v.size()+1, vector<int>(n+1, INT_MAX>>2));
  dp[0][0] = 0;

  REP(i, v.size())REP(j, n+1){
    if(j + v[i] <= n){
      dp[i][j + v[i]] = min(dp[i][j] + 1, dp[i][j + v[i]]);
    }
    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
  }

  cout << dp[v.size()][n] << endl;

  return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
    int r,D,x;

    do{
        scanf("%d %d %d",&r,&D,&x);
    }while(r<2 || r>5 || D<1 || D>100 || x<D || x>200);



    for(int i = 1; i <= 10; i++){
        
        
         x = r*x - D; 
         
         printf("%d",x);
         printf(" ");

    }
printf("\n");
}

Measured memory_bytes: 128
#include <cstdio>
#include <complex>
using namespace std;

typedef complex<double> P;

#define X(a)		(a).real()
#define Y(a)		(a).imag()
#define EQ(a,b)		(-EPS<(a)-(b) && (a)-(b)<EPS)
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )

// ツ点ツづ陳シツ静シツづ個仰猟猟」
double distLP(P a, P b, P p)
{
	return abs(cross(b-a, p-a))/abs(b-a);
}

// ツ陳シツ静シツづ可妥篠つキツづゥツ妥篠湘個点
P symmetryLP(P a, P b, P p)
{
	P v =unit(normal(b-a));
	v *= ( cross(b-a,p-a)>0 ?  -2.0 : 2.0 );

	return p+v*distLP(a,b,p);
}

int main()
{
	double a,b,c,d,e,f;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		P p(a,b),q(c,d),r(e,f),s;
		s = symmetryLP(p,q,r);
		printf("%.6lf %.6lf\n",X(s),Y(s));
	}
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,x;
    int s;
    
    scanf("%d",&x);
    scanf("%d",&a);
    scanf("%d",&b);
    
    s=x-a;
    while(s>=b){
        s=s-b;
    }
    
    
    printf("%d",s);
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int x=0,a=s.size(),b=t.size();
  	char ans[a+b+1];
    for(int i=0;i<a;i++){
    	ans[x]=s[i];
    	x++;
    	ans[x]=t[i];
    	x++;	
    }
    cout << ans << endl;
	return 0;
}

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


int bubbleSort(int N, int A[]){
	int cnt=0;
	int flag = 1;
	while(flag){
		flag=0;
		for(int i=N-1;i>=1;i--){
			if(A[i]< A[i-1]){
				flag=1;
				int tmp=A[i];
				A[i]=A[i-1];
				A[i-1]=tmp;
				cnt++;
			}
		}
	}
	return cnt;
}

int main(){
	
	int N,A[100],i;
	cin >> N;
	for(i=0;i<N;i++)cin >> A[i];
	
	int c = bubbleSort(N,A);
	for(i=0;i<N;i++){
		if(i>0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << c << endl;

	return 0;
}



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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = R / d - (L - 1) / d;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
	int a[4],b[4],p=0,i,o,hit,blow;

	while(1){
		hit=0;blow=0;
	for(i=0;i<4;i++){
		if(scanf("%d",&a[i]) == EOF)
			return 0;
	}
        for(i=0;i<4;i++)
		scanf("%d",&b[i]);
	for(i=0;i<4;i++){
		for(o=0;o<4;o++){
			if(a[i] == b[o]){
				if(i == o)
					hit++;
				else
					blow++;
				
			}
		}
	}

	printf("%d %d\n",hit,blow);
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, p[30];
	cin>>n;
	REP(i, n){
		cin>>p[i];
	}
	int ans=0;
	REP(i, n-2){
		if(p[i]<p[i+1]){
			if(p[i+1]<p[i+2]){
				++ans;
			}
		}
		else{
			if(p[i+1]>p[i+2]){
				++ans;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  ll A,B,C; cin>>A>>B>>C;

  string  ans = "No";
  if ((A + B < C) && (4*A*B < (C - A - B)*(C - A - B))) ans = "Yes";
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	int num1,num2;
	cin >> S;
	num1 = (S[0]-'0') * 10 + S[1]-'0';
	num2 = (S[2] - '0') * 10 + S[3] - '0';
	if ((1<=num1&&num1<=12) && (1 <= num2 && num2 <= 12)) {
		cout << "AMBIGUOUS" << endl;
	}
	if (1 <= (num1 && num1<=12) && (num2 < 1 || 12 < num2)) {
		cout << "MMYY" << endl;
	}
	if ((num1 < 1 || 12 < num1) && (1 <= num2 && num2 <= 12)) {
		cout << "YYMM" << endl;
	}
	if ((num1 < 1 || 12 < num1)&& (num2 < 1 || 12 < num2)) {
		cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScan in = new MyScan(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, MyScan in, PrintWriter out) {
            long x = in.nextInt();
            if (x == 0) {
                out.println(0);
                return;
            }

            long r = 1;
            int sign = -1;
            StringBuilder sb = new StringBuilder();
            while (x != 0) {
                if ((Math.abs(x) & r) > 0) {
                    x += sign * r;
                    sb.append(1);
                } else {
                    sb.append(0);
                }

                sign = -sign;
                r <<= 1;

            }
            out.println(sb.reverse().toString());

        }

    }

    static class MyScan {
        private final InputStream in;
        private byte[] inbuf = new byte[1024];
        public int lenbuf = 0;
        public int ptrbuf = 0;

        public MyScan(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 21332
#include <stdio.h>

int xv, yv;
int sg;

void read(void)
{
    scanf("%d %d", &xv, &yv);
}

void exec(void)
{
    static int g0[] = {1, 3, 5, 7, 8, 10, 12}, g1[] = {4, 6, 9, 11}, g2[] = {2};
    int xg, yg, i;
    
    xg = yg = -1;
    for (i = 0; i < 7; ++i)
        xg = (xv == g0[i]) ? 0 : xg, yg = (yv == g0[i]) ? 0 : yg;
    for (i = 0; i < 4; ++i)
        xg = (xv == g1[i]) ? 1 : xg, yg = (yv == g1[i]) ? 1 : yg;
    for (i = 0; i < 1; ++i)
        xg = (xv == g2[i]) ? 2 : xg, yg = (yv == g2[i]) ? 2 : yg;
    sg = (xg == yg);
}

void write(void)
{
    printf("%s\n", sg ? "Yes" : "No");
}

int main(void)
{
    read();
    exec();
    write();
    return 0;
}


Measured memory_bytes: 128
unittest
{
	assert( [ "3", "apple", "orange", "apple", "1", "grape" ].parse.expand.solve == 2 );
	assert( [ "3", "apple", "orange", "apple", "5", "apple", "apple", "apple", "apple", "apple" ].parse.expand.solve == 1 );
	assert( [ "1", "voldemort", "10", "voldemort", "voldemort", "voldemort", "voldemort", "voldemort", "voldemort", "voldemort", "voldemort", "voldemort", "voldemort" ].parse.expand.solve == 0 );
	assert( [ "6", "red", "red", "blue", "yellow", "yellow", "red", "5", "red", "red", "yellow", "green", "blue" ].parse.expand.solve == 1 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto ss = new string[ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.strip;
	}
	input.popFront;
	auto m = input.front.strip.to!( long );
	auto ts = new string[ m ];
	foreach( ref t; ts )
	{
		input.popFront;
		t = input.front.strip;
	}
	return tuple( ss, ts );
}

auto solve( string[] ss, string[] ts )
{
	auto us = ( [ "" ] ~ ss.dup ).sort().uniq;
	auto cm = long.min;
	
	foreach( u; us )
	{
		auto c = 0L;
		
		foreach( s; ss )
		{
			if( u == s ) c++;
		}
		
		foreach( t; ts )
		{
			if( u == t ) c--;
		}
		
		if( cm < c ) cm = c;
	}
	
	return cm;
}


Measured memory_bytes: 256