akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>



int main() {
    std::string s; std::cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) {
            std::cout << "Bad" << std::endl;
            return 0;
        }
    }
    std::cout << "Good" << std::endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.reverse()
ans=[]
ans_2=[]
for i in range(n):
    if i%2==0:
        ans.append(a[i])
    else:
        ans_2.append(a[i])
ans_2.reverse()
print(*(ans+ans_2))



Measured memory_bytes: 26020
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long L = input.nextLong();
		long R = input.nextLong();
		long mod = 2019;
		long TotalDistance = R-L;
		long LDistance = mod-L%mod; //Above lowerbound
		long RDistance = R%mod; //Below upperbound
		TotalDistance-=LDistance;
		TotalDistance-=RDistance;
		if (TotalDistance>=2019) System.out.println(0);
		else {
			long ans = 2018;
			for (long l = L; l <= R;l++) {
				for (long r = l+1; r <= R; r++) {
					long curans = l*r;
					curans%=mod;
					ans = Math.min(ans, curans);
					//if (ans==curans) System.out.println(l+" "+r);
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 22228
//ABC089C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	vector<vector<int>> c(3, vector<int>(3));
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> c.at(i).at(j);
		}
	}
	for(int i=1;i<3;i++){
		for(int j=0;j<2;j++){
			if(c[i][j]-c[i-1][j] != c[i][j+1]-c[i-1][j+1]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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


def main():
    mod = 998244353
    N = int(input())
    D = list(map(int, input().split()))
    if D[0] != 0 or D.count(0) != 1:
        print(0)
        return
    DD = dict()
    for d in D:
        if d in DD:
            DD[d] += 1
        else:
            DD[d] = 1
    li = sorted(DD.items(), key=lambda x:x[0])
    ans = 1
    x = 0
    pre_v = 1
#    print(li)
    for k, v in li:
        if k != x:
            print(0)
            return
        ans *= (pre_v**v)
        ans = ans % mod
#        print(pre_v, x, k, v, ans)
        pre_v = v
        x += 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  char C;
  cin >> C;
  string alphabet = "abcdefghijklmnopqrstuvwxyz";
  rep(i, 26) {
    if (C == alphabet.at(i)) {
      cout << alphabet.at(i+1) << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int num;
    cin >> num;
    vector<int> B;

    for (int i = 0; i < num-1; i++) {
        int val;
        cin >> val;
        B.push_back(val);
    }

    int ans = 0;

    int prevCandidata = -1;
    int nextCandidata = -1;

    for(int i=0; i<num; i++) {
        if(i==0) {
            ans += B[i];
            prevCandidata = B[i];
        } else if(i==(num-1)) {
            ans += prevCandidata;
        } else {
            nextCandidata = B[i];
            ans += min(prevCandidata, nextCandidata);
            prevCandidata = nextCandidata;
        }
    }

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

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

int main()
{
  int count,N,x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) { 
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  
  count = 0;
  for (int i = 0; i < N- 1; i++)
  {
    x -= a.at(i);
    if (x < 0)
      break;
    
    ++count;
  }
  if (x == a.at(N-1))
    count++;
  cout << count << endl;  
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000
#define NMAX 100000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

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

ll C,N,W,H,dp[HMAX][WMAX],ans[2] = {},A[NMAX],mark = 0,sum = 0;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
dy[8] = {1,1,0,-1,-1,-1,0,1};

void markchange(){
	if(mark){
		mark = 0;
	}else{
		mark = 1;
	}
}

void solve(){
	for (int j = 0; j < 2; ++j)
	{
		for (int i = 0; i < N; ++i)
		{
			sum += A[i];
			if(mark && sum <= 0){
				ans[j] = ans[j]-sum+1;
				sum = 1;
			}else if(!mark && sum >= 0){
				ans[j] = ans[j]+sum+1;
				sum = -1;
			}
			markchange();
			// cout << ans[j] << " ";
		}
		// cout << "\n";
		mark = 1;
		sum = 0;
	}
}

void debug(){

}

void answer(){
	cout << min(ans[0],ans[1]) << "\n";
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 1024
n,q = gets.split.map &:to_i
s = gets.split(//).map &:to_i

def solve_two_five(n,q,s)
  n.times.inject(0) do |ans,i|
    ans += s[i] % q == 0 ? i + 1 : 0
  end
end

def solve(n,q,s)
  cnt = Array.new(q,0)
  per = 1
  cur = 0
  (n-1).downto(0) do |d|
    cur += s[d] * per
    per = per * 10 % q
    cnt[cur % q] += 1
  end

  ans = 0
  q.times do |i|
    ans += cnt[i] * (cnt[i] - 1) / 2
  end
  ans += cnt[0]
end

if q == 2 || q == 5
  puts solve_two_five(n,q,s)
else
  puts solve(n,q,s)
end


Measured memory_bytes: 14204
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

vector<vector<int>>ab(200000);
int point[200000];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

void dfs(int root, int current) {
	for (int c : ab[current]) {
		if (c == root)continue;
		point[c] += point[current];
		dfs(current, c);
	}
}

int main() {

	int N, Q;
	cin >> N >> Q;

	for (int i = 0; i < N-1; ++i) {
		int a, b;
		cin >> a >> b;
		ab[a - 1].push_back(b-1);
		ab[b - 1].push_back(a - 1);
	}

	for (int i = 0; i < Q; ++i) {
		int p, x;
		cin >> p >> x;
		point[p - 1] += x;
	}

	dfs(-1,0);
	for (int i = 0; i < N; ++i)cout << point[i] << " ";
}


Measured memory_bytes: 23552
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    int ans = 0;
    REP(i,s.length()){
        if(s[i]=='+') ans++;
        else ans--;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
import numpy as np
n, x = map(int, input().split())
city = np.array(list(map(int, input().split())))
w = abs(city - x)


def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y % x, x)


ans = w[0]
for i in w[1:]:
    ans = gcd(ans, i)

print(ans)

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

int main(){

    int N;
    cin >> N;

    bool ans = false;
    for(int i = 0; 4 * i <= N; i++){
        for(int j = 0; (4 * i) + (7 * j) <= N ; j++){
            if((4 * i) + (7 * j) == N) ans = true;
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int n, a, b; cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;
static const lint MOD = 1e9 + 7;
static bool debug = true;

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 3; i++) {
		if (i == a || i == b)
			continue;
		cout << i;
		return 0;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll n,p;
	cin >> n >> p;
	string s;
	cin >> s;

	ll res = 0;
	if(p==2 || p==5){
		rep(i,n) if((s[i]-'0') % p == 0) res += i+1;
	}
	else{

		vector<ll> memo(p);
		vector<ll> u(n+1);
		ll tmp = 1;
		for(ll i = n-1; i >= 0; i--){
			u[i] = ((s[i]-'0') * tmp) % p;
			u[i] = (u[i] + u[i+1]) % p;
			tmp = (tmp * 10) % p;

			memo[u[i]]++;
		}
      memo[0]++;

		rep(i,p){
			res += memo[i] * (memo[i]-1) / 2;
		}
	}

	cout << res << endl;

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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


int main(){
    int n;
    cin >> n;
    string ans;
    while(1){
        if(n%2==0){
            n = -n/2;
            ans.push_back('0');
        }
        else{
            n = n-1;
            n = -n/2;
            ans.push_back('1');
        }
        if(n==0) break;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
/*
 * Author: FreePascal
 * Created Time:  2011-8-31 16:04:31
 * File Name: e.cpp
 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <stack>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

const int maxn = 100000 + 100;
const int maxm = 10000;
int an,bn,r,ans;
struct node{
    int x,y;
}plane[maxn];
vector<int> x[maxm + 100];
int main() {
    while (scanf("%d%d%d",&an,&bn,&r) != EOF){
        if (an == 0 && bn == 0 && r == 0) break;
        r = 4 * r;
        for (int i = 0; i < an; i++) scanf("%d%d",&plane[i].x,&plane[i].y);
        for (int i = 0; i <= maxm; i++) x[i].clear();
        for (int i = 0; i < bn; i++){
            int y,z;
            scanf("%d%d",&z,&y);
            x[z].push_back(y);
        }
        //for (int i = 0; i < bn; i++) sort(x[i].begin(),x[i].end());
        for (int i = 0; i <= maxm; i++) sort(x[i].begin(),x[i].end());
        ans = 0;
        for (int i = 0; i < an; i++){
            int left,right,up,down;
            left = plane[i].x - r; right = plane[i].x + r;
            if (left < 0) left = 0;
            if (right > maxm) right = maxm;
            for (int j = left; j <= right; j++){
                int cha = sqrt(r * r - (plane[i].x - j) * (plane[i].x - j));
                //out(cha);
                down = plane[i].y - cha;
                if (down < 0) down = 0;
                up = plane[i].y + cha;
                if (up > maxm) up = maxm;
                ans += lower_bound(x[j].begin(),x[j].end(),up + 1) - upper_bound(x[j].begin(),x[j].end(),down - 1);
                //out(ans);
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var first = s.IndexOf('A');
            var last = s.LastIndexOf('Z');
            Console.WriteLine(last - first + 1);
        }
    }
}


Measured memory_bytes: 11616
#abc157c
n,m=map(int,input().split())
sc=[]
for i in range(m):
 s,c=list(map(int,input().split()))
 sc.append([s,c])
for i in range(10**n):
 st=str(i)
 if len(st)!=n:
  continue
 if all([st[s-1]==str(c) for s,c in sc]):
  print(st)
  exit()
print(-1)


Measured memory_bytes: 3060
import java.util.Scanner;

class Main{

    public static void main(String[] args) {
        // write your code here

        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int n = sc.nextInt();

        int[] arr = new int[n];
        int sum=0;
        for(int i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
            sum+=arr[i];
        }

        if(sum>=h)
            System.out.println("Yes");
        else
            System.out.println("No");




    }
}


Measured memory_bytes: 47076
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        int hosei = 0;
        if (a % x == 0){
         hosei = 1;
       }
        
       System.out.println(b/x-a/x+hosei);
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"siktim seni\n";
ll int a,b,c;
int main(){
	cin>>a>>b>>c;
	if((a==b and b==c)or (a!=b and b!=c and a!=c)){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int m[108][108];
int a[10008];
int main()
{
    int H, W, N, i, j;
    scanf("%d%d", &H, &W);
    scanf("%d", &N);
    int sum = 0;
    for (i = 1; i <= N; i++)
    {
        scanf("%d", &a[i]);
        sum+=a[i];
    }
    i = 1;
    int x = 0, y = 1;
    int k = 1;
    j = 1;
    while(i <= sum)
    {
        while(!m[x + 1][y] && x + 1 <= H)
        {
            x++;
            i++;
            if(a[j] > 0)
            {
                k = j;
                a[j]--;
            }
            else
            {
                k = ++j;
                a[j]--;
            }
            m[x][y] = k;
        }
        while(!m[x][y + 1] && y + 1 <= W)
        {
            y++;
            i++;
            if(a[j] > 0)
            {
                k = j;
                a[j]--;
            }
            else
            {
                k = ++j;
                a[j]--;
            }
            m[x][y] = k;
        }
        while(!m[x - 1][y] && x - 1 > 0)
        {
            x--;
            i++;
            if(a[j] > 0)
            {
                k = j;
                a[j]--;
            }
            else
            {
                k = ++j;
                a[j]--;
            }
            m[x][y] = k;
        }
        while(!m[x][y - 1] && y - 1 > 0)
        {
            y--;
            i++;
            if(a[j] > 0)
            {
                k = j;
                a[j]--;
            }
            else
            {
                k = ++j;
                a[j]--;
            }
            m[x][y] = k;
        }
    }
    for (i = 1; i <= H; i++)
    {
        for (j = 1; j <= W; j++)
        {
            printf(j == 1 ? "%d" : " %d", m[i][j]);
        }
        printf("\n");
    }
    return 0;
}


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

  int a,b ;
  string s,t,u ;
  cin >> s>> t >> a>>b>> u ;
  if(u==s){a=a-1 ;}
  else {b=b-1 ;}
cout << a << ' '<< b ;

    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 < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

ll gcd(ll a, ll b){
    ll r;
    while(r=a%b){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll A,B;
    cin >> A >> B;
    ll val = gcd(A,B);
    ll ans = 1;
    ll tmp = val;
    ll end = ceil(sqrt(val));
    for(ll i=2;i<=end;i++){
        if(tmp%i==0){
            ans++;
            tmp/=i;
            while(tmp%i==0){
                tmp/=i;
            }
        }
    }
    if(tmp>1){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(x:i64));
    let mut now = 0;
    for i in 1.. {
        now += i;
        if now >= x {
            return i.to_string();
        }
    }
    panic!();
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "6" => "3",
    test2: "2" => "2",
    test3: "11" => "5",
}


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

int n;
int dice[6];//top,botom,front,right,back,left
int c[6];
int mas[100][100];
int below[100][100];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

void def(int t,int f){
  if(t==1){
    if(f==2){
      dice[3]=3;
    }
    else if(f==3){
      dice[3]=5;
    }
    else if(f==4){
      dice[3]=2;
    }
    else if(f==5){
      dice[3]=4;
    }
  }
  else if(t==2){
    if(f==1){
      dice[3]=4;
    }
    else if(f==3){
      dice[3]=1;
    }
    else if(f==4){
      dice[3]=6;
    }
    else if(f==6){
      dice[3]=3;
    }
  }
  else if(t==3){
    if(f==1){
      dice[3]=2;
    }
    else if(f==2){
      dice[3]=6;
    }
    else if(f==5){
      dice[3]=1;
    }
    else if(f==6){
      dice[3]=5;
    }
  }
  else if(t==4){
    if(f==1){
      dice[3]=5;
    }
    else if(f==2){
      dice[3]=1;
    }
    else if(f==5){
      dice[3]=6;
    }
    else if(f==6){
      dice[3]=2;
    }
  }
  else if(t==5){
    if(f==1){
      dice[3]=3;
    }
    else if(f==3){
      dice[3]=6;
    }
    else if(f==4){
      dice[3]=1;
    }
    else if(f==6){
      dice[3]=4;
    }
  }
  else if(t==6){
    if(f==2){
      dice[3]=4;
    }
    else if(f==3){
      dice[3]=2;
    }
    else if(f==4){
      dice[3]=5;
    }
    else if(f==5){
      dice[3]=3;
    }
  }

  dice[1]=7-dice[0];
  dice[4]=7-dice[2];
  dice[5]=7-dice[3];
  
}

void roll(int p){
  int temp=dice[0];
  if(p==0){
    dice[0]=dice[4];
    dice[4]=dice[1];
    dice[1]=dice[2];
    dice[2]=temp;
  }
  else if(p==1){
    dice[0]=dice[5];
    dice[5]=dice[1];
    dice[1]=dice[3];
    dice[3]=temp;
  }
  else if(p==2){
    dice[0]=dice[2];
    dice[2]=dice[1];
    dice[1]=dice[4];
    dice[4]=temp;
  }
  else if(p==3){
    dice[0]=dice[3];
    dice[3]=dice[1];
    dice[1]=dice[5];
    dice[5]=temp;
  }
  return ;
}

void fall(int x,int y){
  int cf=0;
  for(int i=0;i<3 && cf==0;i++){
    for(int j=0;j<4 && cf==0;j++){
      if(dice[2+j]==6-i){
	if(below[y+dy[j]][x+dx[j]]<below[y][x]){
	  cf=1;
	  roll(j);
	  fall(x+dx[j],y+dy[j]);
	}
      }
    }
  }
  if(cf==0){
    mas[y][x]=dice[0];
    below[y][x]++;
  }
  return ;
}
main(){
  while(cin >> n,n){
    for(int i=0;i<100;i++)for(int j=0;j<100;j++)mas[i][j]=0;
    for(int i=0;i<100;i++)for(int j=0;j<100;j++)below[i][j]=0;

    for(int i=0;i<6;i++)c[i]=0;

    for(int i=0;i<n;i++){
      cin >> dice[0] >> dice[2];
      def(dice[0],dice[2]);
      fall(50,50);
    }

    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	if(mas[i][j]>0)c[mas[i][j]-1]++;
      }
    }
    cout << c[0];
    for(int i=1;i<6;i++){
      cout << " " << c[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int x, a, b, c;
    while(cin >> a >> b >> c >> x) {
        int cnt = 0;
        for(int i = 0; i <= a; ++i) {
            for(int j = 0; j <= b; ++j) {
                for(int k = 0; k <= c; ++k) {
                    if(i * 500 + j * 100 + k * 50 == x) ++cnt;
                }
            }
        }
        cout << cnt << endl;
    }
}


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

int main()
{
    ll n;
    cin >> n;
    ll cnt[n+10] = {0};
    ll a[n+10];

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

    ll total = 0;
    for(ll i = 1; i <= n; i++) {
        if (cnt[i] == 0) continue;
        total += cnt[i] * (cnt[i] - 1) / 2;
    }

    rep(i, n) {
        cout << total - (cnt[a[i]] * (cnt[a[i]] - 1) / 2) + ((cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2) << endl;
    }


    return 0;
}

Measured memory_bytes: 6724
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     int []hairetu = new int[N];
     int ans =1;
     for(int i=0;i<N;i++){
    	 hairetu[i]=sc.nextInt();
     }
     for(int i=0;i<N-1;i++){
    	 for(int j=0;j<N-1-i;j++){
    		 if(hairetu[j]<hairetu[j+1]){
    			 int temp = hairetu[j];
    			 hairetu[j]=hairetu[j+1];
    			 hairetu[j+1]=temp;
    		 }
    	 }
     }
     int now = hairetu[0];
     for(int i=0;i<N;i++){
    	 if(now>hairetu[i]){
    		 now=hairetu[i];
    		 ans++;
    	 }
     }
     System.out.println(ans);
     
     
	}
}


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

int main () {
  int A, B, PN = 0;
  cin >> A >> B;
 
  for (int i = A; i < B + 1; i++) {
    if ((i / 10000 == i % 10) && (((i / 1000) % 10) == ((i % 100) / 10)))
      PN++;
  }
  
  cout << PN << endl;
}

Measured memory_bytes: 256
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi; ///VECTOR<VECTOR<INT>NAME>NAME 2
typedef vector<vl> vvl;///LONG LONG
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;///VECTOR WITH PAIR
typedef vector<pll> vll;
typedef double dl;

#define endl "\n"
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define over return 0;

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


///--------> YOUR JOURNEY STARTS HERE <-------



int main(){

string h;
cin>>h;
int j=h.length(); int hh=0;
    int ii=0;if(h[0]=='i' || h[j-1]=='h'){
        cout<<"No"<<endl;

return 0;
    }
for(int i=0;i<j;i++){
    if(h[i]!='h' && h[i]!='i'){
        cout<<"No"<<endl;
        return 0;
    }

    else{
        for(int i=0;i<j;i++){
            if(h[i]=='h'){
                hh++;
                ii=0;
            }
            else if(h[i]=='i'){
                ii++;
                hh=0;
            }
            if(hh>1 || ii>1){
                cout<<"No"<<endl;
                return 0;
            }


        }
    }

}
  cout<<"Yes"<<endl;

over
}


Measured memory_bytes: 3572
from collections import defaultdict
N,C=map(int,input().split())

event_list=[]
for i in range(N):
  s,t,c=map(int,input().split())
  event_list.append((s-0.5,c))
  event_list.append((t,-c))
event_list.sort()
#print(event_list)

answer=0
cdic=defaultdict(int)
for t,c in event_list:
  if c>0:
    cdic[c]+=1
    answer=max(answer,len(cdic))
  else:
    cdic[-c]-=1
    if cdic[-c]==0:
      cdic.pop(-c)
  #print(cdic)

print(answer)

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int a,b;
    cin>>a>>b;

    for(int x=1;x<=5000;x++)
    {
        ll aa = (x*8)/100;
        ll bb = (x*10)/100;
        if( aa == a && bb == b )
        {
            cout<<x;
            return 0;
        }
    }
    cout<<-1,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

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

    for( int i = 0; i < n; i++ ){
        cin >> vec.at(i);
    }

    sort(vec.begin(),vec.end());
    string message = "YES";
    for( int j = 0; j < n; j++ ){
        if( j == n - 1 ){
            goto OUT;
        }
        if( vec.at(j) == vec.at(j+1) ){
            message = "NO";
            goto OUT;
        }
    }
    OUT:
    cout << message <<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<ll,pair<ll,ll>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int N,M;
  cin>>N>>M;
  scc_graph G(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    G.add_edge(a,b);
  }

  vector<vector<int>> A=G.scc();
  cout<<A.size()<<endl;
  for(int i=0;i<A.size();i++){
    cout<<A[i].size();
    for(int j=0;j<A[i].size();j++){
      cout<<" "<<A[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 40096
#include<iostream>
#include<algorithm>
#include<climits>
#include<utility>
#include<map>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll MOD=1000000007;
int n;
int a[200010];

ll bit[200010];
ll sum(int i){
  ll s=0;
  while(i>0){
    s=(s+bit[i])%MOD;
    i-=i&-i;
  }
  return s;
}

void add(int i,ll x){
  while(i<=n){
    bit[i]+=x;
    i+=i&-i;
  }
}


int main(){
  scan(n);
  rep(i,n){
    scan(a[i]);
  }
  map<int,int> mi;
  vector<pii> pi;
  rep(i,n){
    if(mi[a[i]]>0){
      if(mi[a[i]]+1!=i+1){
	pi.push_back(pii(mi[a[i]],i+1));
      }
      mi[a[i]]=i+1;
    }
    else{
      mi[a[i]]=i+1;
    }
  }
  /* rep(i,pi.size()){
    prin2(pi[i].first,pi[i].second);
    }*/
  ll res=1;
  rep(i,pi.size()){
    int pf=pi[i].first,ps=pi[i].second;
    ll sump=sum(pf);
    // prin(sump+1);
    res=(res+sump+1)%MOD;
    add(ps,sump+1);
  }
  prin(res);
  
  
  return 0;
}


Measured memory_bytes: 10368
var a:array[0..100000]of longint;
    n,i:longint;
procedure quickly_sort(var a:array of longint;l,r:longint);inline;
var i,j,x,y:longint;
begin
  while true do
  begin
    if r<l+74 then
      exit;
    i:=l;j:=r;
    x:=a[(l+r)>>1];
    repeat
      while a[i]<x do inc(i);
      while x<a[j] do dec(j);
      if not(i>j) then
      begin
        y:=a[i];a[i]:=a[j];
        a[j]:=y;inc(i);dec(j);
      end;
    until i>j;
    if l<j then quickly_sort(a,l,j);
    if not(i<r) then
      exit;
    l:=i;
  end;
end;
procedure sort(var a:array of longint;l,r:longint);inline;
var i,j,t:longint;
begin
  if r>l then
  begin
    quickly_sort(a,l,r);
    i:=l;
    for i:=l to r do
    begin
      j:=i; 
      while j>pred(l) do
        if a[j]<a[pred(j)] then
        begin
          t:=a[pred(j)];a[pred(j)]:=a[j];a[j]:=t;
          dec(j);
        end
        else
          break;
    end;
  end;
end;
begin
  readln(n);
  for i:=1 to n do
    read(a[i]);
  sort(a,1,n);
  write(a[n]-a[1]);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    int A[N]; rep(i,N) cin >> A[i];
    sort(A,A+N);
    double sum=0;
    rep(i,N){
       if(i==0) sum+=(double)(A[i]+A[i+1])/2; 
       else if(i==1) continue;
       else sum=(sum+A[i])/2;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    switch(Number(input)){
        case 22:
            console.log("Christmas Eve Eve Eve");
            break;
        case 23:
            console.log("Christmas Eve Eve");
            break;
        case 24:
            console.log("Christmas Eve");
            break;
        case 25:
            console.log("Christmas");
            break;
    }
    
    
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

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

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

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

#define NUM_MAX 100
#define WEIGHT_MAX 10000

struct product {
    int value;
    int weight;
};
int main(void) {
    int num, ulimit;
    get_int2(&num, &ulimit);
    struct product prods[NUM_MAX];
    int i;
    for(i = 0; i < num; i++) {
        get_int2(&prods[i].value, &prods[i].weight);
    }

    static int dp[NUM_MAX+1][WEIGHT_MAX+1];
    int n, w;
    for(n = 1; n <= num; n++) {
        struct product p = prods[n-1];
        for(w = 1; w <= ulimit; w++) {
            // stay or take over
            dp[n][w] = max(dp[n-1][w], dp[n][w-1]);
            if(w>=p.weight) dp[n][w] = max(dp[n][w], dp[n-1][w-p.weight]+p.value);
        }
    }
    printf("%d\n", dp[num][ulimit]);
    return 0;
}


Measured memory_bytes: 5756
N = int(input())
C = list(map(int, input().split()))

a = 10**9+7
C = list(reversed(sorted(C)))

count = 0
# Cに掛ける数
# N=1 1
# N=2 2, 3
# N=3 4, 6, 8
# N=4 8, 12, 16, 20
for i in range(0, N):
    count += C[i] * (2+i)

print(count * 4**(N-1) % a)

Measured memory_bytes: 27108
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		if(a<b && b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	} 
}

Measured memory_bytes: 26332
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int bitcount(lli n) {
    int cnt = 0;
    while (n) {
        cnt += (n & 1);
        n >>= 1;
    }
    return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    bool arr[64] = {0};
    lli x = 0;
    REP(i, 0, N) {
        lli a;
        cin >> a;
        x ^= a;
        a = a ^ (a - 1);
        arr[bitcount(a)] = true;
    }
    int ans = 0;
    for (int i = 60; i >= 0; i--) {
        if (x & (1LL << i)) {
            if (arr[i + 1]) {
                ans++;
                x ^= ((1LL << (i + 1)) - 1);
            }
        }
    }
    if (x != 0) {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

struct process{
	string name;
	int time;
	process *next;
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	process pl[100000];
	process *p=pl;
	int n, q, now=0;
	cin>>n>>q;
	string pn;
	int pt;
	for(int i=0; i<n; i++) {
		cin>>pn>>pt;
		if(pt<=q) {
			now+=pt;
			cout<<pn<<' '<<now<<'\n';
		} else {
			now+=q;
			p->name=pn;
			p->time=pt-q;
			p->next=p+1;
			p++;
		}
	}
	if(p==pl) return 0;
	--p;
	p->next=pl;
	while(true) {
		if(p->next->time<=q) {
			now+=p->next->time;
			cout<<p->next->name<<' '<<now<<'\n';
			if(p==p->next) break;
			p->next=p->next->next;
		} else {
			p=p->next;
			now+=q;
			p->time-=q;
		}
	}
	return 0;
}



Measured memory_bytes: 6304
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    int ans = 0;
    foreach (i; 1 .. n+1) {
        auto s = i.to!string;
        if (s.length % 2 == 1) { ++ans; }
    }
    
    ans.writeln;
}

Measured memory_bytes: 1276
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n,m;cin>>n>>m;
  vll c(n,-1);
  bool ok=false;
  rep(i,0,m){
    ll s,a;cin>>s>>a;
    if(c[s-1]!=-1&&c[s-1]!=a){
      ok=true;break;
    }
    else{
      c[s-1]=a;
    }
  }
  if(n!=1&&c[0]==0)ok=true;
  if(n!=1&&c[0]==-1){c[0]=1;}
  if(ok){cout<<-1<<endl;}
  else{
    ll ans=0;
    rep(i,0,n){
      if(c[i]!=-1)ans+=c[i]*pow(10,n-1-i);
      
    }
    cout<<ans<<endl;
  }
}






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

const double PI = acos(-1);
const int MOD = 1000000007;

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

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x, ll mod) {
    return mod_pow(x, mod-2, mod);
}

ll mod_frac(ll a, ll b, ll mod) {
    // a*(a+1)*...(b)
    // inclusive a and b
    ll res=1;
    for (size_t i = a; i <= b; i++)
    {
        res = res * i % mod;
    }
    return res;
}


using Mat = vector<vector<ll>>;
using Column = vector<ll>;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    // 2^n
    int res_pow = mod_pow(2, n, MOD);
    
    // C(n,a)
    chmin(a, n-a);
    ll X_a = mod_frac(n-(a-1), n, MOD);
    ll Y_a = mod_frac(1, a, MOD);
    ll res_a = X_a * mod_inv(Y_a, MOD) % MOD;
    
    // C(n,b)
    chmin(b, n-b);
    ll X_b = mod_frac(n-(b-1), n, MOD);
    ll Y_b = mod_frac(1, b, MOD);
    ll res_b = X_b * mod_inv(Y_b, MOD) % MOD;

    cout << (res_pow - 1 - res_a - res_b + 2*MOD) % MOD << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int a[4] , b[4];
	int hit , blow;
	while(cin >> a[0] >>a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3] ){
		hit=blow=0;
		for(int i=0;i<4;++i){
			for(int j=0;j<4;++j){
				if(a[i]==b[j] && a[i]==b[i]) hit++;
				else if (a[i]==b[j]) blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0; 
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    int N; cin >> N;
    vector<int> v(N,-1);

    auto q = [&](int i) {
        cout << i << endl;
        cout.flush();
        string s; cin >> s;
        if (s == "Male") v[i] = 1;
        else if (s == "Female") v[i] = 2;
        else v[i] = 0;
        return;
    };

    int l = 0;
    int r = N;
    q(0);
    if(v[0] == 0) return 0;
    int Q = 19;
    while(Q > 0) {
        int mid = (l+r) / 2;
        q(mid);
        if (v[mid] == 0) return 0;
        else {
            if ((mid-l) % 2 == 0) {
                if (v[mid] == v[l]) l = mid;
                else r = mid;
            } else {
                if (v[mid] == v[l]) r = mid;
                else l = mid;
            }
        }
        Q--;
    }

    return 0;
}


Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	char a;
	cin>>a;
	if(range(a,'a','z'))cout<<'a';
	else cout<<'A';
	return 0;
}

Measured memory_bytes: 3576
import sys
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

x=sorted([a,b,c,d,e])
if x[4]-x[0]>k:
  print(':(')
  sys.exit()
print('Yay!')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n;
  cin >> n;
  vector<vector<int>> arr(n + 1, vector<int>(3));
  for (int i = 0; i < n; i++)
    cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
  vector<vector<int>> dp(n + 1, vector<int>(3));
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      dp[i][j] = arr[i-1][j]+ max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
    }
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]});
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 11264
// https://atcoder.jp/contests/abc122/tasks/abc122_b

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin >> s;

    int ans = 0;
    int cont = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A' | s[i] == 'C' | s[i] == 'G' | s[i] == 'T')
        {
            cont++;
        }
        else
        {
            ans = max(ans, cont);
            cont = 0;
        }
    }
    ans = max(ans, cont);
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b;
    while(~scanf("%d %d",&a,&b))
    {
        if(a*b>(a+b)&&a*b>(a-b))
            printf("%d\n",a*b);
        else if((a+b)>(a-b)&&(a+b)>a*b)
            printf("%d\n",a+b);
        else
            printf("%d\n",a-b);
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long ans[10][11][11]={
{{0,1},{0,4}}
,{{0,0,0,1},{0,2,11,29},{0,0,44,102},{0,0,0,224}}
,{{0,0,0,0,0,1},{0,0,3,26,94,234},{0,0,56,267,758,1654},{0,0,0,1044,2696,5566},{0,0,0,0,6632,13295},{0,0,0,0,0,26172}}
,{{0,0,0,0,0,0,0,1},{0,0,0,5,56,263,815,1982},{0,0,18,302,1597,5256,13254,28191},{0,0,0,2593,10769,31106,72277,145356},{0,0,0,0,39979,108186,240905,470212},{0,0,0,0,0,281514,610743,1170167},{0,0,0,0,0,0,1301950,2463246},{0,0,0,0,0,0,0,4618099}}
,{{0,0,0,0,0,0,0,0,0,1},{0,0,0,0,8,114,667,2504,7191,17266},{0,0,0,123,1670,9503,35004,99183,235800,494490},{0,0,0,3388,25835,111882,350894,893980,1970796,3906352},{0,0,0,0,157000,600254,1740018,4199101,8897744,17112669},{0,0,0,0,0,2135356,5906304,13791678,28520567,53833620},{0,0,0,0,0,0,15836664,36172358,73580280,137124251},{0,0,0,0,0,0,0,81324796,163475022,301850816},{0,0,0,0,0,0,0,0,325679904,597166866},{0,0,0,0,0,0,0,0,0,1088989348}}
};;
long long modpow(long long a,long long b){
	long long ret=1;
	long long now=a;
	while(b){
		if(b%2)ret=ret*now%mod;
		b/=2;
		now=now*now%mod;
	}
	return ret;
}
long long f[25];
int main(){
	int H,W,N;scanf("%d%d%d",&H,&W,&N);
	int sz=2*N;
	int n=(sz)*(sz);
	for(int i=0;i<5;i++)for(int j=0;j<i*2+2;j++)for(int k=j+1;k<i*2+2;k++)ans[i][k][j]=ans[i][j][k];
	if(H<=2*N&&W<=2*N){
		printf("%lld\n",ans[N-1][H-1][W-1]);return 0;
	}
	if(H<N){
		long long ret=0;
		for(int j=0;j<=N;j++){
			long long tmp=1;
			for(int k=0;k<=N;k++){
				if(j==k)continue;
				tmp=(tmp*(mod+W-(N+k))%mod*modpow((mod+j-k)%mod,mod-2))%mod;
			}
			ret=(ret+tmp*ans[N-1][H-1][N-1+j])%mod;
		}
		printf("%lld\n",ret);
		return 0;
	}
	if(W<N){
		long long ret=0;
		for(int j=0;j<=N;j++){
			long long tmp=1;
			for(int k=0;k<=N;k++){
				if(j==k)continue;
				tmp=(tmp*(mod+H-(N+k))%mod*modpow((mod+j-k)%mod,mod-2))%mod;
			}
			ret=(ret+tmp*ans[N-1][W-1][N-1+j])%mod;
		}
		printf("%lld\n",ret);
		return 0;
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			long long tmp=1;
			for(int k=0;k<=N;k++){
				if(j==k)continue;
				tmp=(tmp*(mod+H-(N+k))%mod*modpow((mod+j-k)%mod,mod-2))%mod;
			}
			f[i]=(f[i]+tmp*ans[N-1][N-1+i][N-1+j])%mod;
		}
		//printf("%d: %lld\n",i,f[i]);
	}
	long long ret=0;
	for(int i=0;i<=N;i++){
		long long tmp=1;
		for(int j=0;j<=N;j++){
			if(i==j)continue;
			tmp=(tmp*(mod+W-(N+j))%mod*modpow((mod+i-j)%mod,mod-2))%mod;
		}
		ret=(ret+tmp*f[i])%mod;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
 
using namespace std;
 
int const N = 1234567;
int const INF = 1 << 30;
 
int deg[N];
int was[42];

int dp[1 << 16];
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int v, u, w;
		cin >> v >> u >> w;
		deg[v] ^= w;
		deg[u] ^= w;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (deg[i] == 0) continue;
		if (was[deg[i]]) {
			++ans;
			was[deg[i]] = false;
		} else {
			was[deg[i]] = true;
		}
	}
	int mask = 0;
	for (int i = 0; i < 16; i++) {
		if (was[i]) mask |= 1 << i;
	}
	for (int i = 0; i < 1 << 16; i++) dp[i] = INF;
	dp[mask] = 0;
	for (int i = mask; i >= 1; i--) {
		if (dp[i] == INF) continue;
		if ((i & (i - 1)) == 0) continue;
		for (int j = 1; j < 16; j++) {
			if (((i >> j) & 1) == 0) continue;
			for (int k = j + 1; k < 16; k++) {
				if (((i >> k) & 1) == 0) continue;
				if ((j & k) == 0) continue;
				// cerr << i << ' ' << j << ' ' << k << endl;
				int nj = j ^ k;
				int nmask = i ^ (1 << j) ^ (1 << k);
				int cost = 1;
				if (nj > 0) {
					if (((nmask >> nj) & 1) == 1) {
						cost++;
					}
					nmask ^= 1 << nj;
				}
				// cout << "nmask = " << nmask << endl;
				dp[nmask] = std::min(dp[nmask], dp[i] + cost);
			}
		}
	}
	cout << dp[0] + ans << '\n';
}


Measured memory_bytes: 896