akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
int n,q;
int ans;
string s;

signed main(){
	acc_io;

	cin>>n;
	cin>>s;
	cin>>q;
	int type,i,l,r;
	char c;
	vector<set<int>>a(26);
	rep(j,0,s.size()) a[s[j]-'a'].insert(j);
	rep(j,0,q){
		cin>>type;
		if(type==1){
			cin>>i>>c;
			i--;
			a[s[i]-'a'].erase(i);
			s[i]=c;
			a[s[i]-'a'].insert(i);
		}
		else{
			cin>>l>>r;
			ans=0;
			rep(k,0,26){
				auto itr=a[k].lower_bound(l-1);
				if(*itr<r&&itr!=a[k].end()) ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 24220
def gcd(x,y):
    if y==0:
        return x
    return gcd(y,x%y)

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
lcm %= MOD
ans = 0
for i in A:
    ans += lcm*pow(i,MOD-2,MOD)

print(ans%MOD)


Measured memory_bytes: 4084
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var h = NextInt;
        var a = NextInt;
        Console.WriteLine((h + a - 1) / a);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 13140
include Math
A,B,H,M=gets.chomp.split(' ').map &:to_f

 h=((H/12 )+M/720)*2*PI
 m=M/60*2*PI

 Math.cos(h * Math::PI / 180)
 ax= A * Math.cos(h )
 ay=A  * Math.sin(h )
 bx=B * Math.cos(m )
 by=B * Math.sin(m )

ans=(ax-bx)**2+(ay-by)**2
p ans**(1/2.0)

Measured memory_bytes: 15020
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int a, b;
	cin >> a >> b;

	Int res = 16 - 2 * min(a, b);
	if (res/2>=max(a,b)-min(a,b)){
		cout << "Yay!"<< "\n";
	}
	else {
		cout << ":("<< "\n";
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int x,n;
	cin>>x>>n;
	int p[n];
	bool b[102]={};
	rep(i,n){
		cin>>p[i];
		b[p[i]]=true;
	}
	int mn=1000;
	rep(i,102){
		if(b[i])continue;
		mn=min(abs(x-i),mn);
	}
  	if(mn!=min(mn,x+1)){
		puts(-1);
      	return 0;
    }
      
	if(!b[x-mn]){
		puts(x-mn);
	}else{
		puts(x+mn);
	}
}


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

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

    if(s == "SAT")
        cout<<"1";
    else if(s == "SUN")
        cout<<"7";
    else if(s == "MON")
        cout<<"6";
    else if(s == "TUE")
        cout<<"5";
    else if(s == "WED")
        cout<<"4";
    else if(s == "THU")
        cout<<"3";
    else if(s == "FRI")
        cout<<"2";


}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string S, T; cin >> S >> T;
    rep(i, S.size()){
        if(S == T){
            cout << "Yes" << endl;
            return;
        }
        S = S.back() + S;
        S.pop_back();
    }

    cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;



int main(){
    ll N; cin >> N;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    multiset<ll> ST;
    ST.insert(A[0]);
    for(int i = 1; i < N; i++){
        if(A[i] < *(ST.begin())) ST.insert(A[i]);
        else{
            auto itr = ST.lower_bound(A[i]);
            if(itr == ST.begin()) { ST.insert(A[i]);continue;}
            itr--;
            ST.erase(itr);
            ST.insert(A[i]);
        }
    }
    cout << ST.size() << endl;
}


Measured memory_bytes: 8592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int P;
    int ans=0;
    int min=1E6;
    for(int i=0; i<N; i++){
        cin >> P;
        if(min>P){
            ans++;
            min=P;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[])
{
    int a, b;
    std::cin >> a;
    std::cin >> b;
    if (a+b==15) 
        std::cout << '+';
    else if (a*b==15)
        std::cout << '*';
    else
        std::cout << 'x';
    return 0;
}


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

int main(){
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    
    // Count amount of moves towards origin
    ll moves;
    moves = min(K, X/D);
    
    K -= moves;
    X -= moves*D;
    
    // How many moves are left? If odd amount, go one step further
    
    if(K%2 == 0){
        cout << X << "\n";
    }else{
        cout << D-X << "\n";
    }
}


Measured memory_bytes: 3588
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut v: [u64; n]
    }
    v.sort_by(|a, b| b.cmp(a));
    let sum: u64 = (0..n - 1).map(|k| v[(k + 1) / 2]).sum();
    println!("{}", sum);
}


Measured memory_bytes: 6248
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll A, B, N;
//---------------------------------------------------------------------------------------------------
ll f(ll x) { return (A * x) / B - A * (x / B); }
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B >> N;

	ll ans = 0;
	chmax(ans, f(N));
	if (B - 1 <= N) chmax(ans, f(B - 1));
	cout << ans << endl;
}







Measured memory_bytes: 3648
def f(n):
    ret = 1
    while n > 0:
        n %= bin(n).count('1')
        ret += 1
    return ret

if __name__ == "__main__":
    n = int(input())
    x = input()
    cnt = x.count('1')

    if cnt == 1:
        for k in x[:-1]:
            if k == '0':
                print(1)
            else:
                print(0)
        if x[-1] == '1':
            print(0)
        else:
            print(2)
        exit()

    xNum = 0
    for k in x:
        xNum <<= 1
        if k == '1':
            xNum += 1
    ans = []
    p = xNum % (cnt + 1)
    m = xNum % (cnt - 1)

    for i in range(n):
        if x[i] == '0':
            ans.append(f((p + pow(2, n - i - 1, cnt + 1)) % (cnt + 1)))
        else:
            ans.append(f((m - pow(2, n - i - 1, cnt - 1)) % (cnt - 1)))
    print(*ans, sep='\n')


Measured memory_bytes: 14496
import java.io.InputStream;
import java.io.PrintStream;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		final int N = sc.nextInt();
		final int M = sc.nextInt();

		PriorityQueue<Integer> que = new PriorityQueue<>((a, b) -> Integer.compare(b, a));
		for (int i = 0; i < N; i++) {
			que.add(sc.nextInt());
		}

		sc.close();

		for (int i = 0; i < M; i++) {
			int p = que.poll();
			que.add(p >> 1);
		}

		long ans = 0;
		while (!que.isEmpty()) {
			ans += que.poll();
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

int main() {
    int H,W;
    cin >> H >> W;
    char a[H][W];
    
    for ( int i = 0; i < H; ++i){
        for ( int j = 0; j < W; ++j){
            cin >> a[i][j];
        }
    }
    
    
    int hcount = 0; // 横が全て'.'のラインの数を数える
    bool flg = true;
    vector<int> h(H,0);
    for ( int i = 0; i < H; ++i){
        flg = true;
        for ( int j = 0; j < W; ++j){
            if ( a[i][j] == '#' ) {
                flg = false;
                h[i] = 1;
            }
        }
        if ( flg ) ++ hcount;
    }
    
    char a2[H-hcount][W];
    int idx = 0;
    for ( int i = 0; i < H; ++i){
        if ( h[i] == 0 ) continue;
        for ( int j = 0; j < W; ++j){
            a2[idx][j] = a[i][j];
        }
        ++idx;
    }
    

    int wcount = 0;
    vector<int> w(W,0);
    for ( int i = 0; i < W; ++i){
        flg = true;
        for ( int j = 0; j < H-hcount; ++j){
            if ( a2[j][i] == '#' ){
                flg = false;
                w[i] = 1;
            }
        }
        if ( flg ) ++ wcount;
    }
    
    char a3[H-hcount][W-wcount];
    idx = 0;
    for ( int i = 0; i < W; ++i){
        if ( w[i] == 0 ) continue;
        for ( int j = 0; j < H-hcount; ++j){
            a3[j][idx] = a2[j][i];
        }
        ++idx;
    }
    
    for ( int i = 0; i < H-hcount; ++i){
        for ( int j = 0; j < W-wcount; ++j){
            cout << a3[i][j];
        }
        cout << endl;
    }
    
    
    
    return 0;
}


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

using namespace std;

int n;
char c[505][505];
bool have[505];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cin >> c[i][j];
		}
	}
	
	bool flag = false;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(c[i][j] == '#') flag = true;
		}
	}
	if(!flag){
		cout << -1 << endl;
		return 0;
	}
	
	int full = 0;
	for(int j = 1; j <= n; j++){
		bool flag = true;
		for(int i = 1; i <= n; i++){
			if(c[i][j] == '.') flag = false;
			else have[j] = true;
		}
		if(flag) full++;
	}
	
	int ans = 1e9;
	for(int i = 1; i <= n; i++){
		int cnt = n;
		for(int j = 1; j <= n; j++){
			if(c[i][j] == '#') cnt--;
		}
		if(cnt == 0){
			ans = 0;
			break;
		}
		if(have[i]){
			ans = min(ans, cnt);
			continue;
		}
		cnt++;
		ans = min(ans, cnt);
	}
	
	ans += n-full;
	cout << ans << endl;
	
	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vector<pair<int,int> > a(n);
	int best = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i].first >> a[i].second;
		a[i].second++;
	}
	sort(a.begin(), a.end());
	multiset<int> l, r;
	for(int i = 0; i < n; i++){
		l.insert(a[i].first);
		r.insert(a[i].second);
	}

	for(int i = 0; i < n; i++){
		l.erase(l.find(a[i].first));
		r.erase(r.find(a[i].second));
		int len = max(0, *r.begin() - *l.rbegin());
		best = max(best, len + a[i].second - a[i].first);
		l.insert(a[i].first);
		r.insert(a[i].second);
	}
	int e1 = 2e9;
	int s2 = 0;
	for(int i = 0; i < n; i++){
		s2 = max(s2, a[i].first);
		e1 = min(e1, a[i].second);
	}
	for(int i = 0; i < n; i++){
		r.erase(r.find(a[i].second));
		if(r.empty()) break;
		best = max(best, max(0, e1 - a[i].first) + max(0, *r.begin() - s2));
	}
	cout << best << '\n';
}

Measured memory_bytes: 10368
class Node:
    def __init__(self,v):
        self.v = v
        self.next = None

class Queue:
    def __init__(self):
        self.head = None
        self.tail = None
        self.size = 0

    def enqueue(self,v):
        self.size += 1
        n = Node(v)
        if self.tail == None:
            self.tail = n
        else:
            self.tail.next = n
            self.tail = n
        if self.head == None:
            self.head = self.tail
    def dequeue(self):
        if self.size == 0:
            print 'underflow'
            exit()
        self.size -= 1
        v = self.head.v
        self.head = self.head.next
        if self.head == None:
            self.tail = None
        return v

#class Queue:
#    def __init__(self,l):
#        self.values = []
#        self.l = l
#        for _ in range(l):
#            self.values.append(None)
#        self.head = 0
#        self.tail = 0
#    def inc(self,n):
#        if n+1 >= self.l:
#            return 0
#        else:
#            return n+1
#    def enqueue(self,v):
#        if self.inc(self.head) == self.tail:
#            print 'overflow'
#            exit()
#        self.values[self.head] = v
#        self.head = self.inc(self.head)
#    def dequeue(self):
#        if self.head == self.tail:
#            print 'underflow'
#            exit()
#        v = self.values[self.tail]
#        self.tail = self.inc(self.tail)
#        return v
#    def size(self):
#        if self.head >= self.tail:
#            return self.head-self.tail
#        else:
#            self.head + (self.l-self.tail)

n,q = map(int,raw_input().split(' '))
queue = Queue()
for _ in range(n):
    n,t = raw_input().split(' ')
    t = int(t)
    queue.enqueue((n,t))

c = 0
while queue.size>0:
    n,t = queue.dequeue()
    if t <= q:
        c += t
        print n,c
    else:
        queue.enqueue((n,t-q))
        c += q

Measured memory_bytes: 31512
n = int(input())
c = [0]*10001

for x in range(1,101):
    if(x > n):
        break
    for y in range(1,101):
        for z in range(1,101):
            p = int(((x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x))/2)
            if(n >= p):
                c[p] += 1

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


Measured memory_bytes: 9432
#include <stdio.h>
int main(){
    int n,a[7],b[7],ans;
    bool f;
    char c[2];
    while(scanf("%d",&n)!=EOF){
        ans=0;
        for(int i=0;i<7;i++)a[i]=b[i]=0;
        for(int i=0;i<n;i++){
            scanf("%s",c);
            if(c[0]==c[1]){
                b[c[0]-'0']++;
            }
            a[c[0]-'0']++;
            a[c[1]-'0']++;
        }
        f=true;
        for(int i=0;i<7&&f;i++){
            if(b[i]>0){
                if(a[i]==b[i]*2){
                    if(a[i]!=n*2){
                        f=false;
                        printf("No\n");
                    }
                }
            }
            if(a[i]%2==1){
                ans++;
            }
            if(ans>2){
                f=false;
                printf("No\n");
            }
        }
        if(f)printf("Yes\n");
    }
}

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

int main(){
  int N,x = 0,y = 0;
  cin >> N;
  string S;
  cin >> S;
  for(int i = 0;i < N;i++){
    if(S[i] == 'I')
      y++;
    if(S[i] == 'D')
      y--;
    x = max(x, y);
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String b=scanner.next();
		String ans="";
		if(b.equals("A")) {
			ans="T";
		}else if(b.equals("T")) {
			ans="A";
		}else if(b.equals("G")) {
			ans="C";
		}else {
			ans="G";
		}
		System.out.println(ans);
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;

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

    if(a == b) {
        cout << "Draw" << endl;
    } else if( a != 1 && a < b || b == 1) {
        cout << "Bob" <<endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}

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


int main(){
	string w;
	cin >> w;
	int N = w.size();
	vector<int> alphabet(26);
	rep(i,N){
		++alphabet[w[i] - 'a'];
	}
	rep(i,26){
		if(alphabet[i]%2!=0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}












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

int main() {
  string str;
  int cnt = 0;
  
  cin >> str;
  
  for(int i = 0; i < 3; i++){
    if(str.at(i) == 'o') cnt++;
  }
  
  cout << 700 + (100 * cnt);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    int c[3][3];
    bool flag = false;
    rep(i,3)rep(j,3)cin>>c[i][j];
    rep(i,101){
        if(flag)break;
        rep(j,101){
            if(flag)break;
            rep(k,101){
                bool same = true;
               if(c[0][0]-i != c[1][0]-j || c[1][0]-j != c[2][0]-k || c[0][0]-i != c[2][0]-k) same = false;
               if(c[0][1]-i != c[1][1]-j || c[1][1]-j != c[2][1]-k || c[0][1]-i != c[2][1]-k) same = false;
               if(c[0][2]-i != c[1][2]-j || c[1][2]-j != c[2][2]-k || c[0][2]-i != c[2][2]-k) same = false;
                if(same)flag = true;
            }
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




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

// Function to return the probability when 
// number of heads is greater than the number of tails 
double Probability(double p[], ll n) 
{ 
    // Declaring the DP table 
    double dp[n + 1][n + 1]; 
    memset(dp, 0.0, sizeof(dp)); 
  
    // Base case 
    dp[0][0] = 1.0; 
    ll i,j;
    // Iterating for every coin 
    for (i=1;i<=n;i++) 
    { 
        // j represents the numbers of heads 
        for (j=0;j<=i;j++) 
        { 
            // If number of heads is equal to zero 
            // there there is only one possiblity 
            if (j == 0) 
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i]); 
            else
                dp[i][j] = dp[i - 1][j]*(1.0 - p[i])+dp[i - 1][j - 1]*p[i]; 
        } 
    } 
    // for(i=0;i<=n;i++)
    //     {for(j=0;j<=n;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;}    
    // cout<<endl;
    double ans = 0.0; 
    // When the number of heads is greater than (n+1)/2 
    // it means that heads are greater than tails as 
    // no of tails + no of heads is equal to n for 
    // any permuation of heads and tails 
    for (i=(n + 1)/2;i<=n;i++) 
        ans += dp[n][i]; 
  
    return ans; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i;
    cin>>n;
    double p[n+1];
    for (i=1;i<=n;i++)
    cin>>p[i];

    cout<<fixed<<setprecision(10)<<Probability(p,n);
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    int cnt = 1, ans = 0;
    FOR(i, 1, n) {
        if (a[i - 1] == a[i])++cnt;
        else {
            ans += cnt / 2;
            cnt = 1;
        }
    }
    ans += cnt / 2;
    cout << ans << "\n";
}

Measured memory_bytes: 256
S = list(input())
K = int(input())

if len(set(S)) == 1:
  print(len(S)*K//2)
  
else:
  cnt = 1
  counter = []
  for i in range(len(S)-1):
    if S[i] == S[i+1]:
      cnt += 1
    else:
      counter.append(cnt)
      cnt = 1
  counter.append(cnt)
  ans = 0
  for l in counter:
    ans += (l//2)*K

  if S[0] == S[-1]:
    a = counter[0]
    b = counter[-1]
    ans -= (a//2 + b//2 - (a+b)//2)*(K-1)
  
  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
bool broken[100010];
int dp[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    
    rep(i, M) {
        int a; cin >> a;
        broken[a] = true;
    }
    dp[0] = 1;
    rep(i, N + 1) {
        if(!broken[i + 1]) dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
        if(!broken[i + 2]) dp[i + 2] = (dp[i + 2] + dp[i]) % mod;
    }
    //rep(i, N + 1) cout << i << " " << dp[i] << endl;
    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 4524
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		int in = 0;
		int ans = 0;

		for(int i = 0;i < N;i++) {
			in = scan.nextInt();
			list.add(in);
			ans += in;
		}

		int M = scan.nextInt();
		ArrayList<Integer> ans_box = new ArrayList<Integer>();

		for(int i = 0;i < M;i++) {
			in = scan.nextInt();
			ans_box.add(ans + (scan.nextInt() - list.get(in - 1)));
		}

		for(int i = 0;i < M;i++) {
			System.out.println(ans_box.get(i));
		}
	}
}

Measured memory_bytes: 36064
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
using namespace std;
typedef long long ll;



int main() {
	int m, d,d1,d10,ans=0;
	cin >> m >> d;
	for (int i = 1; i <= m; i++) {
		for (int j = 22; j <= d; j++) {
			if (((j % 10)*(j / 10) == i)&&j%10>=2)
				//cout << i << "��" << j<<endl;
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
dp = [[0 for i in range(3)] for j in range(N)]

a, b, c = map(int,input().split())
dp[0][0] = a
dp[0][1] = b
dp[0][2] = c

if N ==1:
    print(max(a, b, c))
    sys.exit()

a, b, c = map(int,input().split())
case1 = a + dp[0][1] 
case2 = a + dp[0][2] 
case3 = b + dp[0][0] 
case4 = b + dp[0][2] 
case5 = c + dp[0][0] 
case6 = c + dp[0][1]

dp[1][0] = max(case1,case2)
dp[1][1] = max(case3,case4)
dp[1][2] = max(case5,case6)

if N ==2:
    print(max(dp[1][0], dp[1][1], dp[1][2]))
    sys.exit()

for i in range (2, N):
    a, b, c = map(int,input().split())
    case1 = a + dp[i-1][1]
    case2 = a + dp[i-1][2]
    case3 = b + dp[i-1][0]
    case4 = b + dp[i-1][2]
    case5 = c + dp[i-1][0]
    case6 = c + dp[i-1][1]
    
    dp[i][0] = max(case1,case2)
    dp[i][1] = max(case3,case4)
    dp[i][2] = max(case5,case6)
    
print(max(dp[N-1][0],dp[N-1][1],dp[N-1][2]))

Measured memory_bytes: 24376
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

vector<int> a[4];
vector<_int64> sum[4];

int main()
{
  int i,j,k,l;
  int n,w,ww,vv,x,y;
  _int64 ans,tot,tmp;
  scanf("%d%d",&n,&w);
  scanf("%d%d",&ww,&vv);
  for (i=0;i<4;i++)
    a[i].clear();
  a[0].push_back(vv);
  for (i=1;i<n;i++)
  {
    scanf("%d%d",&x,&y);
    a[x-ww].push_back(y);
  }
  //cout<<"a"<<endl;
  for (i=0;i<4;i++)
  {
    sort(a[i].begin(),a[i].end());
    reverse(a[i].begin(),a[i].end());
    sum[i].clear();
    sum[i].push_back(0);
    for (j=0;j<a[i].size();j++)
      sum[i].push_back(sum[i][j]+a[i][j]);
  }
  ans=0;
  //cout<<"b"<<endl;
  for (i=0;i<=a[0].size();i++)
    for (j=0;j<=a[1].size();j++)
      for (k=0;k<=a[2].size();k++)
      {
        tot=(_int64)i*ww+(_int64)j*(ww+1)+(_int64)k*(ww+2);
        if (tot>w) continue;
        l=(w-tot)/(ww+3);
        tmp=sum[0][i]+sum[1][j]+sum[2][k];
        if (l<sum[3].size()) tmp+=sum[3][l];
        else tmp+=sum[3][sum[3].size()-1];
        if (tmp>ans) ans=tmp;
      }
  printf("%lld\n",ans);
  return 0;
}

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

using namespace std;

int main(){
  int n, k, result = 0;
  
  cin >> n >> k;
  
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  for(int i = 0; i < k; i++){
    result+= p.at(i);
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#define SWAP(type,a,b) do{type tmp=a;a=b;b=tmp;}while(0)
typedef struct{
  int no;
  int time;
}P;

main(){
  int n,i,j,m1,s1,m2,s2,m3,s3,m4,s4;
  while(1){
    scanf("%d",&n);
    if(n==0) return 0;
    P a[n];
    for(i=0;i<n;i++){
      scanf("%d %d %d %d %d %d %d %d %d",&a[i].no,&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
      s1+=m1*60,s2+=m2*60,s3+=m3*60,s4+=m4*60;
      a[i].time=s1+s2+s3+s4;
    }
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(a[j].time<a[j-1].time){
	  SWAP(P,a[j],a[j-1]);
	}
      }
    }

    printf("%d\n%d\n%d\n",a[0].no,a[1].no,a[n-2].no);
  }
}

Measured memory_bytes: 636
import copy
A,B,M = (int(x) for x in input().split())
a = list()
b = list()
x = list()
y = list()
c = list()
for j in input().split():
    a.append(int(j))

for j in input().split():
    b.append(int(j))
    
for i in range(M):
    tx,ty,tc = (int(j) for j in input().split())
    x.append(int(tx))
    y.append(int(ty))
    c.append(int(tc))

pat=0
mini = 200000
ca = copy.copy(a)
cb = copy.copy(b)
a.sort()
b.sort()

mini = a[0] + b[0]

#for i in range(len(a)):
#    for j in range(len(b)):
#        pat = a[i] + b[j]
#        if mini > pat:
#            mini = pat
for i in range(M):
    pat = ca[x[i]-1] + cb[y[i]-1] - c[i]
    if mini > pat:
        mini = pat

print(mini)



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

int main(){
  while(1){
  int n,w,v[100],p[100]={},maxp=0,cnt=0;
  double ans=0.01;
  cin>>n>>w;
  if(n+w==0) break;
  for(int i=0;i<n;i++) cin>>v[i],p[v[i]/w]++,maxp=max(maxp,p[v[i]/w]);
  for(int i=0;i<100;i++)if(p[i]>0)cnt=i;
  for(int i=0;i<=cnt;i++) ans+=((1.0*(cnt-i)/(cnt))*(1.0*p[i]/maxp));
  cout<<ans<<endl;
  }  
  
  return 0;
}

Measured memory_bytes: 1232
from collections import defaultdict
N, M = map(int, input().split())
constraint = defaultdict(set)
for _ in range(M):
    s, c = map(int, input().split())
    constraint[s].add(c)

for k, v in constraint.items():
    if len(v) > 1:
        print(-1)
        exit()

for i in range(1001):
    i = str(i)
    if len(i) != N:
        continue
    flag = True
    for k, v in constraint.items():
        if i[k-1] != str(list(v)[0]):
            flag = False
    if flag:
        print(i)
        exit()
print(-1)


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

using namespace std;

typedef long long ll;

int max_n = 300015;
int N, M;
int S, T;
vector<vector<int>> g(max_n, vector<int>());
vector<bool> used(max_n, false);

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

	cin >> N >> M;

	rep(i, M){
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v + N);
		g[u + N].push_back(v + 2 * N);
		g[u + 2 * N].push_back(v);
	}

	cin >> S >> T;
	S--;
	T--;

	queue<int> q1, q2;
	q1.push(S);
	q2.push(0);

	while(q1.size() > 0){
		// cout << q1.front() << "," << q2.front() << endl;
		int x = q1.front();
		q1.pop();

		int cnt = q2.front();
		q2.pop();

		if(x == T){
			cout << cnt / 3 << endl;
			return 0;
		}

		for(int y : g[x]){
			if(!used[y]){
				used[y] = true;
				q1.push(y);
				q2.push(cnt+1);
			}
		}
	}

	cout << -1 << endl;
}


Measured memory_bytes: 16768
#include <iostream>
#include <math.h>
#include <iomanip>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif

#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main()
{
	long double a, b, x;

	std::cin >> a >> b >> x;

	if (x > a*a*b/2.0) {
		long double x_bar = a * a * b - x;
		long double c = 2.0 * x_bar / (a * a);
		std::cout << std::setprecision(12) << (long double)rad_to_deg((long double)atan(c / a)) << std::endl;
	}
	else {
		long double c = 2.0 * x / (a * b);
		std::cout << std::setprecision(12) << (long double)rad_to_deg((long double)atan(b / c)) << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
 
ll r[111111];
pair<ii,ii> func[111111]; //[l, r] => mn + l, < l mn, > r, mx
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x; cin>>x;
	int n; cin>>n;
	vi V;
	V.pb(0);
	r[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>r[i];
		V.pb(r[i]);
	}
	for(int i=n;i>=1;i--)
	{
		r[i]-=r[i-1];
	}
	func[0] = mp(mp(0,x),mp(0,x));
	for(int i = 1; i <= n; i++)
	{
		func[i]=func[i-1];
		if(i&1)
		{
			//-r[i]
			if(func[i].se.fi>=r[i])
			{
				func[i].se.fi-=r[i];
				func[i].se.se-=r[i];
			}
			else
			{
				func[i].fi.fi = min(func[i].fi.fi+r[i]-func[i].se.fi,x);
				func[i].fi.se = max(func[i].fi.se,func[i].fi.fi);
				func[i].se.se = max(0LL, func[i].se.se - r[i]);
				func[i].se.fi=0;
			}
		}
		else
		{
			//+r[i]
			if(func[i].se.se+r[i]<=x)
			{
				func[i].se.fi+=r[i];
				func[i].se.se+=r[i];
			}
			else
			{
				func[i].fi.se = max(0LL, func[i].fi.se - func[i].se.se + x - r[i]);
				func[i].fi.fi = min(func[i].fi.fi,func[i].fi.se);
				func[i].se.se = x;
				func[i].se.fi = min(x, func[i].se.fi + r[i]);
			}
		}
	}
	int q; cin>>q;
	while(q--)
	{
		ll t, v; cin>>t>>v;
		int z = upper_bound(V.begin(),V.end(),t) - V.begin();
		z--;
		//V[z] <= t
		ll l = func[z].fi.fi;
		ll r = func[z].fi.se;
		ll mn = func[z].se.fi;
		ll mx = func[z].se.se;
		ll cur = 0;
		if(v<l)
		{
			cur = mn;
		}
		else if(v>r)
		{
			cur = mx;
		}
		else
		{
			cur = mn + v - l;
		}
		t -= V[z];
		if(z&1) //add t
		{
			cur+=t;
			if(cur>x) cur=x;
		}
		else
		{
			cur-=t;
			if(cur<0) cur=0;
		}
		cout<<cur<<'\n';
	}
}


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


class pz{
public:
	int sq[30];
	int c;

	bool complete(){
		if (count(&sq[0], &sq[9], sq[0]) != 9) return false;
		if (count(&sq[9], &sq[12], sq[9]) != 3) return false;
		if (count(&sq[12], &sq[15], sq[12]) != 3) return false;
		if (count(&sq[15], &sq[18], sq[15]) != 3) return false;
		if (count(&sq[18], &sq[21], sq[18]) != 3) return false;
		if (count(&sq[21], &sq[30], sq[21]) != 9) return false;
		return true;
	}

	pz change(int p){
		pz cube = *this;
		cube.c++;

		if (p == 0){
			swap(cube.sq[0], cube.sq[23]);
			swap(cube.sq[3], cube.sq[26]);
			swap(cube.sq[6], cube.sq[29]);
			swap(cube.sq[9], cube.sq[20]);
			swap(cube.sq[15], cube.sq[17]);
		}
		else if (p == 1){
			swap(cube.sq[2], cube.sq[21]);
			swap(cube.sq[5], cube.sq[24]);
			swap(cube.sq[8], cube.sq[27]);
			swap(cube.sq[11], cube.sq[18]);
			swap(cube.sq[12], cube.sq[14]);
		}
		else if (p == 2){
			swap(cube.sq[6], cube.sq[21]);
			swap(cube.sq[7], cube.sq[22]);
			swap(cube.sq[8], cube.sq[23]);
			swap(cube.sq[12], cube.sq[17]);
			swap(cube.sq[9], cube.sq[11]);
		}
		else if (p == 3){
			swap(cube.sq[0], cube.sq[27]);
			swap(cube.sq[1], cube.sq[28]);
			swap(cube.sq[2], cube.sq[29]);
			swap(cube.sq[14], cube.sq[15]);
			swap(cube.sq[18], cube.sq[20]);
		}
		return cube;
	}
};


void clear(queue<pz> &q){
	queue<pz> emp;
	swap(emp, q);
}


int main(){
	int n;
	queue<pz> q;

	cin >> n;


	for (int i = 0; i < n; i++){
		pz cube;
		cube.c = 0;
		for (int j = 0; j < 30; j++){
			cin >> cube.sq[j];
		}
		q.push(cube);
		while (true){
			if (q.front().complete()){
				cout << q.front().c << endl;
				clear(q);
				break;
			}
			for (int j = 0; j < 4; j++){
				q.push(q.front().change(j));
			}
			q.pop();
		}
	}

	return 0;
}

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

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

	if (a < b)cout << "a < b" << endl;
	if(a>b)cout << "a > b" << endl;
	if(a==b)cout << "a == b" << endl;


	return 0;
}


Measured memory_bytes: 3088
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc= new Scanner(System.in);
    int ar[]= new int[5];
    for(int i=0;i<5;i++)
    {
      ar[i]=sc.nextInt();
    }
    for(int i=0;i<5;i++)
    {
      if(ar[i]==0)
      {
        System.out.println(i+1);
        break;
      }
    }
  }
}

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

using namespace std;
int main(){
 
  string S;
  cin>>S;
 int  count =0;
 size_t k = S.length();
 
  for(int i=1;i<=k;i++){
    if(S[i]=='o'){
      ++count;
    }
  }
  if(S[0]=='o'){
      ++count;
  }
  
  int b=15-k;
 
  if(b+count>=8){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;

}

Measured memory_bytes: 256
a11,a12,a13 = map(int,input().split())
a21,a22,a23 = map(int,input().split())
a31,a32,a33 = map(int,input().split())
N=int(input())
i=0
B=[]
while i<N:
  B.append(int(input()))
  i+=1
ans=0
c11=c12=c13=c21=c22=c23=c31=c32=c33=0
  
for k in B:
  if k==a11:
    c11+=1
  elif k==a12:
    c12+=1
  elif k==a13:
    c13+=1
  elif k==a21:
    c21+=1
  elif k==a22:
    c22+=1
  elif k==a23:
    c23+=1
  elif k==a31:
    c31+=1
  elif k==a32:
    c32+=1
  elif k==a33:
    c33+=1
  
if c11>0 and c12>0 and c13>0:
  ans+=1
elif c21>0 and c22>0 and c23>0:
  ans+=1
elif c31>0 and c32>0 and c33>0:
  ans+=1
elif c11>0 and c21>0 and c31>0:
  ans+=1
elif c12>0 and c22>0 and c32>0:
  ans+=1
elif c13>0 and c23>0 and c33>0:
  ans+=1
elif c11>0 and c22>0 and c33>0:
  ans+=1
elif c31>0 and c22>0 and c13>0:
  ans+=1


if ans>0:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3192
import itertools
import fractions
from functools import reduce

n = int(input())
a = [int(s) for s in input().split(' ')]

L = [0] * n
R = [0] * n

for i in range(len(a)):
    if i == 0:
        L[i] = a[i]
        R[n - 1] = a[n - 1]
    else:
        L[i] = fractions.gcd(L[i - 1], a[i])
        R[n - 1 - i] = fractions.gcd(R[n - i], a[n - 1 - i])

val = 1

for i in range(len(a)):
    ret = 0
    if i == 0:
        ret = R[i + 1]
    elif i == n - 1:
        ret = L[i - 1]
    else:
        ret = fractions.gcd(L[i - 1], R[i + 1])

    if ret > val:
       val = ret
        
print(val)


Measured memory_bytes: 16148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
    int a,b;
    cin>>a>>b;
    if(a<6){
        cout<<"0"<<endl;
    }else if(a<13){
        cout<<b/2<<endl;
    }else{
        cout<<b<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	long n,s=0,min=0,max=0,a;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(i==0){min=a;max=a;}
		s+=a;
		if(min>a)min=a;
		if(max<a)max=a;
	}
	cout<<min<<" "<<max<<" "<<s<<endl;
    return 0;
}



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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int N = 1e5 + 4;
int parent[N], depth[N], ssize[N];

void init_sets(int n) {
	for (int i = 1; i <= n; i++) {
		parent[i] = i;
		ssize[i] = 1;
	}
}

int find_set(int a) {
	if (parent[a] == a) return a;
	return parent[a] = find_set(parent[a]);
}

void union_sets(int a, int b) {
	a = find_set(a);
	b = find_set(b);
	if (a == b) return;
	if (depth[a] < depth[b]) swap(a, b);
	parent[b] = a;
	ssize[a] += ssize[b];
	if (depth[a] == depth[b]) ++depth[a];
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m;
	scanf("%d%d", &n, &m);
	vii edge(m);
	for (int i = 0; i < m; i++) scanf("%d%d", &edge[i].first, &edge[i].second);

	vll answer{(ll)n * (n-1) / 2};
	init_sets(n);
	for (int i = m-1; i > 0; i--) {
		int a = find_set(edge[i].first);
		int b = find_set(edge[i].second);
		ll reduce;
		if (a == b)
			reduce = 0;
		else {
			reduce = (ll)ssize[a] * ssize[b];
			union_sets(a, b);
		}
		answer.push_back(answer.back() - reduce);
	}

	for (auto it = answer.rbegin(); it != answer.rend(); ++it)
		printf("%lld\n", *it);
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	string s[n];
	rep(i, n) cin >> s[i];
	
	int cnt = 0;
	rep(k, n) {
		rep(i, n) {
			rotate(s[i].begin(), s[i].begin() + 1, s[i].end());
		}
		
		bool ok = true;
		rep(i, n) {
			FOR(j, i + 1, n) {
				if (s[i][j] != s[j][i]) {
					ok = false;
				}
			}
		}
		if (ok) cnt++;
	}
	
	cout << cnt * n << endl;
	
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
typedef long long lint;
const int N=1e5+2;
int n,m;
lint st[N],cnt[N],add_p[N];

template <class T> inline T nxi(){
	T x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
#ifndef ONLINE_JUDGE
//	freopen("a.in","r",stdin);
#endif
	n=nxi<int>(),m=nxi<int>();
	int pt=1;
	st[1]=n;
	for(int i=1;i<=m;++i){
		const lint x=nxi<lint>();
		while(pt&&st[pt]>=x) --pt;
		st[++pt]=x;
	}
	m=pt;
	cnt[m]=1;
	st[m+1]=(lint)2e18;
	for(int i=m;i>1;--i){
		lint cur=st[i];
		for(int tp=i-1;cur>=st[1];cur%=st[tp]){
			tp=std::upper_bound(st+1,st+tp+1,cur)-st-1;
			cnt[tp]+=cur/st[tp]*cnt[i];
		}
		add_p[cur]+=cnt[i];
	}
	for(int i=st[1];i;--i){
		add_p[i-1]+=add_p[i];
	}
	for(int i=1;i<=n;++i){
		printf("%lld\n",(st[1]>=i?cnt[1]:0)+add_p[i]);
	}
	return 0;
}

Measured memory_bytes: 4096