akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <cstdio>
#include <cstdint>
using namespace std;
typedef int_fast64_t ll;

unsigned int M, i = 0;
ll d, c, sd = 0, sc = 0, A;
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char readchar() {
    if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
    return *ci++;
}
 
inline ll readint() {
	A = 0;
	if (ci - cn + 16 > cm) while ((ct = readchar()) >= '0') A = A * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
    return A;
}

int main() {
    M = readint();
    while(i++ != M) {
        sd += readint() * readint();
        sc += A;
    }
    printf("%lld\n", --sc + --sd / 9);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using llong = long long;
const int MOD=1000000007;


struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};


int main(int argc, char**argv){
    llong n, m;
    cin >> n >> m;
    vector<llong> a(m), b(m);
    for (int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }

    UnionFind tree(n);

    llong ans = n * (n - 1) / 2;
    vector<llong> res;
    for (int i = 0; i < m; i++){
        res.push_back(ans);

        llong na = a[m - 1 - i], nb = b[m - 1 - i];
        if (tree.issame(na, nb)) continue;

        ans -= tree.size(na) * tree.size(nb);
        tree.merge(na, nb);
    }

    reverse(res.begin(), res.end());
    for (int i = 0; i < res.size(); i++){
        cout << res[i] << endl;
    }


    return 0;
}



Measured memory_bytes: 4212
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//usage
//input! {
//  h: i32;
//  v: [i32; n]
//  x: [[i32; n]; m]
//  f: chars <- Vec<char>
//}
trait BinarySearch<T> {
    fn lower_bound(&self, x: T) -> usize;
    fn upper_bound(&self, x: T) -> usize;
}
impl <T: Ord> BinarySearch<T> for Vec<T> {
    fn lower_bound(&self, x: T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (high + low) / 2;
            if self[mid] < x {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        low
    }

    fn upper_bound(&self, x: T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (high + low) / 2;
            if self[mid] > x {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        low
    }
}

fn main() {
    // ABC077_C
    input!{
        n: usize,
        mut a: [i32; n],
        mut b: [i32; n],
        mut c: [i32; n]
    }
    a.sort();
    b.sort();
    c.sort();
    let mut ans = 0;
    for i in b {
        ans += a.lower_bound(i) * (n - c.upper_bound(i));
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
def f():
 from heapq import heappop, heappush
 N=int(input())
 r=[0]*N
 for _ in[0]*(N*~-N//2):
  a,b,c,d=map(int,input().split())
  r[a-1]+=3*(c>d)+(c==d)
  r[b-1]+=3*(d>c)+(d==c)
 b=[[]for _ in[0]*N*3]
 for i in range(N):b[r[i]]+=[i]
 pq = []
 for i, s in enumerate(r):heappush(pq,[-s,i])
 rank=1
 display_rank=1
 prev_score=float('inf')
 while pq:
  s,i=heappop(pq)
  if s!=prev_score:rank=display_rank
  r[i]=rank
  display_rank+=1
  prev_score=s
 print(*r,sep='\n')
f()


Measured memory_bytes: 5724
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- readLn
    nums <- sequence $ replicate n (readLn :: IO Int)
    putStrLn $ show $ solve $ sortBy (\a b -> compare b a) nums

solve :: [Int] -> Int
solve nums =
    let (tens, ntens) = partition (\n -> n `mod` 10 == 0) nums in
        if null ntens
            then 0
            else let s = sum nums in
                if s `mod` 10 == 0
                    then s - (head $ sort ntens)
                    else s

Measured memory_bytes: 1020
k,s= map(int,input().split())


count = 0

# arr = []
# for i in range(0,k+1):
#     arr.append(i)

# def binary_search(arr,i):
#     x = arr
#     low = 0
#     high = len(x)-1
#     t = (low + high) // 2 
#     # 探索の下限のlowが上限のhighになるまで探索
#     # lowがhighに達すると数は見つからなかったということ
#     while (low<=high):
#         if (i==x[t]):
#             break
#         elif (i > x[t]):
#             low = t + 1
#         elif (i < x[t]):
#              high = t - 1
#         t = (low + high) // 2

#     if (i==x[t]):
#         return t
#     else:
#         return -1




# for i in range(0,k+1):
#         l = s - i - j
#         arr = arr[]
#         answer = binary_search(arr,l)
#         # print(i,j,l)
#         if(answer!=-1):
#             # print('clear',i,j,l)
#             count += 1

for i in range(0,k+1):
    for j in range(i,k+1):
        l = s-i-j
        if l>=j and l <= k:
            if i!=j and j != l and i!=l:
                # print(i,j,l)
                count += 6
            elif i == j and j == l and i == l:
                # print(i,j,l)
                count += 1
            else:
                # print(i,j,l)
                count += 3

print(count)

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

int main() {
    char c;
    cin >> c;
    
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }

}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))
AandB = sorted(A & B)
AorB = sorted(A | B)
print(len(AandB), len(AorB))
for x in AandB:
    print(x)
for x in AorB:
    print(x)


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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
   string s;
   cin >> s;
   string v[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
   int ind = 0;
   while(v[ind] != s) {
      ++ind;
   } 
   cout << 7 - ind << endl;
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];

    ll ans = 0;
    rep(i, n) for (int j = i + 1; j < n; j++) {
        ans += d[i] * d[j];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int n,m;
	cin>>n>>m;
	cout<<((n*n-n)/2)+((m*m-m)/2)<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    int t=1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#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,MOD = 1e9+7;
const int iINF = 1e9;

int main(){   
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    sort(all(h));

    ll c = 0;
    rep(i,n-k){
        c += h[i];
    }

    cout<<c<<endl;

}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!p)
#define until(p) while(!p)

using ll = long long;
using P = std::tuple<int,int>;

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

ll X[100100], Y[100100];
const ll MOD = 1e9 + 7;

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

    int N, M;
    std::cin >> N >> M;

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

    for(int i=0;i<M;++i){
        std::cin >> Y[i];
    }

    ll sumX = 0ll, sumY = 0ll;
    for(int i=1;i<N;++i){
        ll pr = (X[i] - X[i-1]) * i % MOD * (N-i) % MOD;
        sumX = (sumX + pr) % MOD;
    }

    for(int i=1;i<M;++i){
        ll pr = (Y[i] - Y[i-1]) * i % MOD * (M-i) % MOD;
        sumY = (sumY + pr) % MOD;
    }

    std::cout << ((sumX * sumY) % MOD) << std::endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int A[(1 << 20)];
int n, Q;
int N;
void init(){
	N = 1;
	while (N < n)N *= 2;
	for (int i = 0; i < 2*N-1; i++)A[i] = 2147483647;
}
int find(int a, int b,int k,int l,int r){
	if (a <= l && r <= b)return A[k];
	if (r <= a || b <= l)return  2147483647;
	int vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
	int vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
	//printf("find %d %d %d %d\n", l, r, vl,vr);
	return min(vl, vr);

}	
void update(int i, int x){
	i += N-1;
	A[i] = x;
	//printf("update %d %d\n", i, A[i]);
	while (i > 0){
		i = (i - 1) / 2;
		A[i] = min(A[2*i+1],A[2*i+2]);
		//printf("update %d %d\n", i, A[i]);
	}
}
int main()
{
	cin >> n >> Q;
	init();
	for (int i = 0; i < Q; i++){
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0)update(x, y);
		else printf("%d\n",find(x,y+1, 0, 0, N));
	}
	return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>

int main() {
	int n, j, ans;
	int a[32258064] = {};
	long int k;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%ld", &k);
		int s = k / 31, t = k % 31;
		if ((a[s] & (0b1 << t)) == 0)
		{
			a[s] = a[s] | (0b1 << t);
			ans++;
		}
		else
		{
			a[s] = a[s] & ~(0b1 << t);
			ans--;
		}
	}

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

Measured memory_bytes: 126208
# include <iostream>
using namespace std;
const int N=31;
int a[N];
int n,m,p;
void work (void)
{
	int i,q,t,f;
	f=0;
	q=0;
	for (i=1;i<=26;i++)
	{
		t=a[i]/4;
		if (q+t<p)
		{
			q+=t;
			a[i]%=4;
		}
   else
        {
        	t=p-q;
        	a[i]-=t*4;
        	f=1;
        	break;
        }
	}
	if (f==1)
	if (n%2==1||m%2==1)
	{
		f=0;
		p=0;
		q=0;
		if (n%2==1)
		p+=m/2;
		if (m%2==1)
		p+=n/2;
		for (i=1;i<=26;i++)
		{
			t=a[i]/2;
			if (q+t<p)
			{
				q+=t;
				a[i]%=2;
			}
   	   else
        	{
        		f=1;
        		break;
        	}
		}
	}
	if (f==1)
	cout<<"Yes";
else cout<<"No";
}
int main (void)
{
	int i,j;
	char c;
	cin>>n>>m;
	p=(n/2)*(m/2);
	for (i=1;i<=n;i++)
	for (j=1;j<=m;j++)
	{
		cin>>c;
		a[c-96]++;
	}
	work ();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
typedef long long ll;

using namespace std;

int N;
ll val;
int main() {
    cin>>N;
    ll sum=0;
    ll min_val=1e12;
    int ncnt=0;
    while(N--) {
        cin>>val;
        sum+=abs(val);
        min_val=min(min_val, abs(val));
        if(val<=0) ncnt++;
    }

    if(ncnt%2) {
        cout<<sum-2*min_val;
    } else {
        cout<<sum;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scan s = new Scan();
		s.getNum();
	}
}

class Scan {
	public static void getNum() {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		if (a < b) {		
			if (b < c) {
				System.out.println(a + " " + b + " " + c);
			} else if (a < c){
				System.out.println(a + " " + c + " " + b);
			} else {
				System.out.println(c + " " + a + " " + b);
			}
		} else {
			if (c < b) {
				System.out.println(c + " " + b + " " + a);
			} else if (a < c) {
				System.out.println(b + " " + a + " " + c);
			} else {
				System.out.println(b + " " + c + " " + a);
			}
		}
	}
}

Measured memory_bytes: 26276
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <assert.h>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define each(i,n) for(auto &i : n)

#define int long long

signed main() {

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

	int r, l;

	if (a == 0) {
		l = 0;
	}
	else {
		l = (a - 1) / x + 1;
	}
	r = b / x + 1;

	cout << r - l << 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(){
	int n,m,x;
	cin >> n >> m >> x;
	int to_zero = 0;
	int to_n = 0;
	rep(i,m){
		int a;
		cin >> a;
		if(a < x) to_zero++;
		else to_n++;
	}
	int ans = min(to_zero,to_n);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set> 
#include <iterator>
#include <bitset> 
#include <bits/stdc++.h> 
using namespace std;
typedef  long long int ll;
ll mod=1000000007;
const int N=300004;
int ind[N]={0};
int ind1[N]={0};
set <int> posx,posy;
 set <pair<int,int>> mat;
int main() {
    int t=1;
    //cin>>t;
    while(t--)
    {   int h,w;
        cin>>h>>w;
        int m;
        cin>>m;
        //int count=0;
        
        //int ma[m+1]={0};
        //int mat[h+1][w+1];
        //memset(mat,0,sizeof(mat));
        for(int i=1;i<=m;i++)
        {   int x,y;
            cin>>x>>y;
            //cin>>y;
            ind[x]++;
            ind1[y]++;
           mat.insert(pair<int,int>(x,y));
            
        }
        int maxm=INT_MIN;
        
        for(int i=1;i<=h;i++)
        {   maxm=max(maxm,ind[i]);
        }
        for(int i=1;i<=h;i++)
        {   if(ind[i]==maxm)
                posx.insert(i);
        }
        maxm=INT_MIN;
        for(int i=1;i<=w;i++)
        {   maxm=max(maxm,ind1[i]);
        }
        for(int i=1;i<=w;i++)
        {   if(ind1[i]==maxm)
                posy.insert(i);
        }
        
        int flag=0;
       /* for(int i=1;i<=m;i++)
        {   if((posx.find(x[i])!=posx.end() && posy.find(y[i])==posy.end()) ||(posx.find(x[i])==posx.end() && posy.find(y[i])!=posy.end()))
            {   flag++;
                break;
            }
        }*/
        for(auto itr=posx.begin();itr!=posx.end();itr++)
        {   for(auto itr1=posy.begin();itr1!=posy.end();itr1++)
            {    if(mat.find(pair<int,int>(*itr,*itr1))==mat.end())
                    {   flag++;
                        break;
                    }
            }
        }
        if(flag>0)
            cout<<ind[*posx.begin()]+ind1[*posy.begin()];
        else
            cout<<ind[*posx.begin()]+ind1[*posy.begin()]-1;
            
    }
	return 0;
}

Measured memory_bytes: 48116
N = int(input())
ans = 0
A,B,AB = 0,0,0
for i in range(N):
    s = input()
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] ==  'A':
        AB += 1
    elif s[0] == 'B':
        B += 1
    elif s[-1] == 'A':
        A += 1


add =  0

if AB != 0:
    add += (AB - 1)
    if A >= 1:
        A -= 1
        add += 1
    if B >= 1:
        B -= 1
        add += 1
add += min(A,B)

print(min(add,N-1) + ans)

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

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<Vl> VVl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define BASE  (1000000000 + 7)
#define MAX_N (1000000000)
#define MAX_M (100000)
#define K     (3)

int N, M;
int X[MAX_M + 1];
ll A[K] = {1, 3, 1};
ll P1[K][K] = {
  {2, 1, 0},
  {3, 1, 2},
  {1, 0, 1}},
P[31][K][K] ,
Q[K][K] = {{1, 1, 0},
  {0, 1, 2},
  {0, 0, 1}},
R[K][K];

void mat_print(ll a[K][K]) {
#ifdef DEBUG
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < K; j++) {
      debug_printf("%lld ", a[i][j]);
    }
    debug_printf("\n");
  }
#endif
}

void mat_copy(ll a[K][K], ll b[K][K]) {
  for (int i = 0; i < K; i++)
    for (int j = 0; j < K; j++) a[i][j] = b[i][j];
}

void mat_prod(ll a[K][K], ll b[K][K], ll c[K][K]) {
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < K; j++) {
      a[i][j] = 0;
      for (int k = 0; k < K; k++) a[i][j] = (a[i][j] + b[i][k] * c[k][j]) % BASE;
    }
  }
}

void build_pow_P() {
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < K; j++) {
      P[0][i][j] = (i == j)? 1: 0;
      P[1][i][j] = P1[i][j];
    }
  }
  for (int i = 2; i < 31; i++) mat_prod(P[i], P[i - 1], P[i - 1]);
}

void pow_P(ll a[K][K], ll n) {
  for (int i = 0; i < K; i++)
    for (int j = 0; j < K; j++) a[i][j] = P[0][i][j];

  for (int i = 1; i < 31; i++) {
    if (n == 0) break;
    if ((n & 1) != 0) {
      ll b[K][K];
      mat_prod(b, a, P[i]);
      mat_copy(a, b);
    }
    n >>= 1;
  }
}

void solve() {
  pow_P(R, X[0] - 1);
  for (int i = 1; i <= M; i++) {
    ll s[K][K], t[K][K];
    pow_P(s, X[i] - X[i - 1] - 1);
    mat_prod(t, R, Q);
    mat_prod(R, t, s);
  }

  ll ans = 0;
  for (int i = 0; i < 3; i++) ans = (ans + R[0][i] * A[i]) % BASE;

  printf("%lld\n", ans);
}

int main() {
  build_pow_P();

  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> X[i];
  X[M] = N;

  solve();

  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e6+10;

int n,left,right,s0,s1;
struct node {
	int x,y;
	bool operator <(node b) const {
		return x - y>b.x - b.y; //更大在前面 
	}
} a[N];

char s[N];

int main() {
	scanf("%d",&n);
	for(int i=1,l,r;i<=n;i++) {
		scanf("%s",s+1); l=r=0;
		for(int j=1;s[j];j++)
			if(s[j]=='(') l++;
			else {
				if(l) l--;
				else r++;
			}
		if(!l&&r) right+=r;
		else if(!r&&l) left+=l;
		else a[i]=(node){l,r};
		s0+=l;s1+=r;
	}
	if(s0^s1) puts("No"),exit(0);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) {
		if(left<a[i].y) puts("No"),exit(0);
		left-=a[i].y-a[i].x;
	}
	if(left^right)puts("No");
	else puts("Yes"); return 0;
}


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(int);

/***** MAIN *****/
signed main() {
  int a, b, c, d;
  cin >> a >> b;
  cin >> c >> d;
  if (a != c)  {
    cout << 1;
  } else {
    cout << 0;
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val Array(n, t) = readLine.split(" ").map(_.toInt)

  @scala.annotation.tailrec
  def next(list: List[Int], cur: Long, until: Long): Long =
    list match {
      case Nil => cur
      case x :: xs => next(xs, cur + t - (if (x < until) until - x else 0), x + t)
    }

  println(next(readLine.split(" ").map(_.toInt).toList, 0, 0))
}

Measured memory_bytes: 54852
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100010
#define ll long long
using namespace std;

int n, m, x, y, d, p;
ll s[N], s1[N], s2[N], mn;

inline void ins(int L, int R, int x, int f){
	if(!f){s[L]+=x; s[R+1]-=x; return;}
	s[L]+=x; s[R+1]-=x;
	s1[L+1]--; s1[R+1]++; s2[R+1]+=R-L;
}

int main(){
	scanf("%d%d", &m, &n);
	scanf("%d", &x);
	for(int i=2; i<=m; i++){
		scanf("%d", &y);
		if(x<=y){
			d=y-x;
			ins(1, x, d, 0);
			ins(x+1, y, d, -1);
			if(y<=n-1)ins(y+1, n, d, 0);
		}else{
			d=n-x+y; p=x%n+1;
			if(p==1){ins(1, y, y, -1); ins(y+1, x, d, 0);}
			else{ins(1, y, y, -1); ins(p, n, d, -1); ins(y+1, x, d, 0);}
		}
		x=y;
	}
	for(int i=1; i<=n; i++)s[i]+=s[i-1];
	for(int i=1; i<=n; i++)s1[i]+=s1[i-1];
	for(int i=1; i<=n; i++)s1[i]+=s1[i-1]+s2[i];
	for(int i=1; i<=n; i++)s[i]+=s1[i];
	mn=s[1]; for(int i=2; i<=n; i++)mn=min(mn, s[i]);
	printf("%lld", mn);
	return 0;
}

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

int main(){
	int N;
	int pt, res, money[] = {500, 100, 50, 10, 5, 1};
	
	while(true){
		scanf("%d", &N);
		
		if(N == 0) return 0;
		
		N = 1000 - N;
		
		pt = 0; res = 0;
		while(N > 0){
			while(N >= money[pt]){
				N -= money[pt];
				res++;
			}
			pt++;
		}
		
		printf("%d\n", res);
	}
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  string T=S;
  sort(T.begin(),T.end());
  int count=0;
  for(int i=0;i<N;i++){
    if(S.at(i)!=T.at(i)){
      count++;
    }
  }
  cout << count/2 << endl;
}

Measured memory_bytes: 3892
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll gcd(ll a, ll b)
{
	if (a < b) return gcd(b, a);
	if (b == 0) return a;
	else return gcd(b, a % b);
}

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

int main()
{
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll ans = B / C + B / D - B / lcm(C, D);
	ll num = (A - 1) / C + (A - 1) / D - (A - 1) / lcm(C, D);
	cout << (B - A + 1) - ans + num << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std; 

int main(){
	int n,m;
	cin>>n>>m;
	if(n==m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
main = solve

solve = do
    allS <- readLn
    (h, allS) <- getHour allS
    (m, allS) <- getMinute allS
    putStrLn $ show h ++ ":" ++ show m ++ ":" ++ show allS

getHour :: Int -> IO (Int, Int)
getHour s = getTime s 3600

getMinute :: Int -> IO (Int, Int)
getMinute s = getTime s 60

getTime :: Int -> Int -> IO (Int, Int)
getTime s x = let t = s `div` x
                  remain = s - (t * x)
              in return (t, remain)

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

//////////
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // 頂点 s をスタートとした探索
    vector<int> dist(N, -1);
    queue<int> que;
    int count = 0;
    for (int v = 0; v < N; ++v) {
        if (dist[v] != -1) continue; // v が探索済みならスルー
        dist[v] = 0, que.push(v);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            for (auto nv : G[v]) {
                if (dist[nv] == -1) {
                    dist[nv] = dist[v] + 1;
                    que.push(nv);
                }
            }
        }
        ++count;
    }
    cout << count-1 << endl;
}

Measured memory_bytes: 8752
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
//#include <algorithm>
#include<set>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  int n;
  cin >> n;
  double a[n];
  rep(i,n){
    cin >> a[i];
  }
  double sum=0;
  rep(i,n){
    sum+=1/a[i];
  }
  std::cout << std::fixed;
  cout << setprecision(10)<< 1/sum;
	return 0;
}

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


int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<int> T(N, 0);
    for (int i = 1; i < N; i++) {
        T[i] += T[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C') T[i]++;
    }

    int l, r;
    rep(_, Q) {
        cin >> l >> r;
        cout << T[r - 1] - T[l - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3828
a=list()
b=list()
a="R", "U","D"
b="L", "U", "D"
s=input()
count=0
ans=True
for i in s:
    if count%2==0:
        if i not in a:
            ans=False
    if count%2!=0:
        if i not in b:
            ans=False
    count+=1

if ans==True:
    print('Yes')
else:
    print('No')
             

Measured memory_bytes: 3064
a,b=list(map(int,input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

aa=factorization(a)
bb=factorization(b)

dicta={"1":1}
dictb={"1":1}
for i in range(len(aa)):
  if(str(aa[i][0]) not in dicta):
    dicta[str(aa[i][0])]=1
for i in range(len(bb)):
  if(str(bb[i][0]) not in dictb):
    dictb[str(bb[i][0])]=1
count=0
for i in dicta:
  if(i in dictb):
    count +=1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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

int n,x[10];
int b,c;
char t;
bool flag=true;

int main(){
	cin>>n;
	rep(i,n){
		flag = true;
		b = c = -1;
		rep(j,10) cin>>x[j];
		rep(j,10){
			if(x[j]<min(b,c)){
				flag = false;
				break;
			}
			if(x[j]<b) c = x[j];
			else if(x[j]<c) b = x[j];
			else if(b<c) c = x[j];
			else b = x[j];
			//cout<<b<<" "<<c<<endl;
		}
		if(flag) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(a>=b)
        b*=2,k--;
    while(b>=c)
        c*=2,k--;
    if(k>=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3636
a,b,c,x,y = map(int,input().split())

if 2*c >= a+b:
    print(a*x +b*y)
else:
    if x < y:
        if b < 2*c:
            print(2*c*x +b*(y-x))
        else:
            print(2*c*y)
    else:
        if a < 2*c:
            print(2*c*y +a*(x-y))
        else:
            print(2*c*x)



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

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

	int numa, numz;
	for (int i = s.length()-1; i > 0; i--) {
		if (s[i] == 'Z') {
			numz = i;
			break;
		}
	}
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			numa = i;
			break;
		}
	}

	cout << numz - numa + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())
int T,N,A,B,C,D;
unordered_map<int,int> M;

int dp(int x){
	if (x==0) return 0;
	if (M[x]) return M[x];
	int ans = 1e18;
	ans = min(ans,dp(x/2) + A + (x%2)*D);
	if (x/2 + 1 != x) ans = min(ans,dp(x/2 + 1) + A + (2-(x%2))*D);
	ans = min(ans,dp(x/3) + B + (x%3)*D);
	if (x/3 + 1 != x) ans = min(ans,dp(x/3 + 1) + B + (3-(x%3))*D);
	ans = min(ans,dp(x/5) + C + (x%5)*D);
	if (x/5 + 1 != x) ans = min(ans,dp(x/5 + 1) + C + (5-(x%5))*D);
	if (x*D > 0) ans = min(ans,x*D);
	//db(x), db(ans);
	return M[x] = ans;
}
void solve(){
	M.clear();
	cin>>N>>A>>B>>C>>D;
	M[1] = D;
	cout<<dp(N)<<"\n";
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>T;
	FOR(tc,1,T) solve();
}


Measured memory_bytes: 4232
int main() {
 
    int R[200000], n, i, max, min;
 
    scanf("%d",&n);
 
    for (i = 0; i < n; i++)   scanf("%d",&R[i]);
 
    max = -100000000000;
    min = R[0];
 
        for(i = 1; i < n; i++) {
 
            if (max < R[i] - min) max = R[i] - min;
 
            if (min > R[i]) min = R[i];
        }
 
    printf("%d\n", max);
 
    return 0;
 
}

Measured memory_bytes: 2516
#include <stdio.h>

int main(void) {
    int a, b, c, d, e, k;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &k);
    if (e-a > k) printf(":(\n");
    else printf("Yay!\n");
    return 0;
}

Measured memory_bytes: 128
'use strict'
function Main(input){
  input = input.trim().split('\n');
  const hw = input.shift().split(' ').map((str)=> Number(str));
  const H  = hw[0], W = hw[1];  
  const data = input.map(ls => ls.split(''));
  
  const hy = [-1, -1, -1, 0, 0, 1, 1, 1];
  const wx = [-1, 0, 1, -1, 1, -1, 0, 1];
  
  for(let i = 0; i < H; i++){
    for(let j = 0; j < W; j++){
      
      if(data[i][j] === '#') continue;
      
      let count = 0;
      for(let k = 0; k < 8; k++){
        const y = i + hy[k] , x = j + wx[k]; 
        if(y < 0 || H <= y) continue;
        if(x < 0 || W <= x) continue;
        
        if(data[y][x] === '#') {
          count += 1;
        }
      }
      data[i][j] = count;
    }
  }
  const result = data.map(ls => ls.join('')).join('\n');
  console.log(result);
}

//固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	char A[5]="YAKI",S[1000];
	cin>>S;
	for(int i=0;i<4;i++){
		if(A[i]!=S[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,a[35][35],c[35],C;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i][0];
		for(int j=1;j<=a[i][0];j++)cin>>a[i][j];
	}
	for(int i=1;i<=m;i++){
		for(int j=0;j<n;j++){
			for(int k=1;k<=a[j][0];k++){
				if(a[j][k]==i)c[i]++;
			}
		}
		if(c[i]==n)C++;
	}
	cout<<C<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define name(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int N=(int)1e6+7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n ;
    map<pii , int>haps;
    vector<vi>a(n , vi(2));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 2; j++) {
            cin >> a[i][j];
        }

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if(i == j)continue;
                int x = a[i][0] - a[j][0] , y = a[i][1] - a[j][1];
                haps[ pii(x, y) ]++;
            }
        }
        int ans = 0;
        for(auto c : haps) {
            ans = max(ans , c.second);
        }
        cout << n - ans << '\n';

    return 0;
}



Measured memory_bytes: 384
#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>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, m;

    while (cin >> n >> m and n and m) {

        vector<int> a(n);
        rep(i, n) cin >> a[i];

        int ma = -1;
        rep(i, n) rep(j, n) {
            if (i == j) continue;
            if (a[i]+a[j] <= m) ma = max(ma, a[i]+a[j]);
        }

        if (ma == -1) cout << "NONE" << endl;
        else cout << ma << endl;

    }

    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n, x; cin >> n >> x;
  int ans = 1, d = 0;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
    d += l[i];

    if (d > x) break;
    else {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map &:to_i
a = [0] * (N + 2)
$<.each{|s|
  l, r = s.split.map &:to_i
  a[l] += 1
  a[r + 1] -= 1
}
sum = 0
cusum = a.map{|n| sum += n }
p cusum.count(M)


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X,A,B;
  cin >> X >> A>> B;
  cout << (X-A)%B << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

int main(void) {

    int N, K;
    cin >> N >> K;

    long long P[N];
    long long ans = 0;
    long long tmp = 0;

    rep(i, N) {
        long long p;
        cin >> p;
        long long ex = (1+p);
        P[i] = ex;
        // cout << ex << endl;

        if(i-K > -1) tmp -= P[i-K];
        tmp += P[i];
        if(ans < tmp) ans = tmp;
    }

    printf("%.6lf", (double)ans/2);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int a, b;
    string b_temp;
    cin >> a >> b_temp;
    reverse(b_temp.begin(), b_temp.end());
    b_temp.erase(b_temp.begin() + 2);
    reverse(b_temp.begin(), b_temp.end());
    b = stoi(b_temp);
    cout << a * b / 100 << endl;
    return 0;
}



Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<limits>
#include<cmath>
using namespace std;
int main(void){
	int x,y,s,a,i;
	cin>>x>>y;
	s=x+y;
	for(i=1;i<x;i++){
		a=(i*y)%x;
		if(a==0) s--;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3136
#include<iostream>
typedef long long ll;

using namespace std;

int main()
{ll N, K;
 cin >> N >> K;
  if(K%2 != 0){cout << (long long) (N/K)*(N/K)*(N/K) << endl;}
 else
 {ll cnt1 =  (N/K)*(N/K)*(N/K);
  ll cnt2 = ((N + (K/2))/K)*((N + (K/2))/K)*((N + (K/2))/K);
  cout << cnt1 + cnt2 << endl;
 }
 return 0;}

Measured memory_bytes: 764
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>           // sorted map so O(logn)
#include <unordered_map> // O(1)
typedef long long ll;
using namespace std;

bool isPalin(string word)
{
    string reverse;
    for (int i = word.length() - 1; i > -1; --i)
    {
        reverse += word[i];
    }
    return word == reverse;
}

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    bool flag = false;
    if (isPalin(s))
    {
        if (isPalin(s.substr(0, (n - 1) / 2)))

        {
            if (isPalin(s.substr((n + 3) / 2 - 1, (n - 1) / 2)))
            {
                flag = true;
            }
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {

        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>

int main()
{	
	int n, i, j;
	while((scanf("%d", &n)!=EOF) && n){
		int key[100] = {};
		char s[100] = {};
		char ans[100] = {};
		
		for(i = 0; i < n; i++)		scanf("%d", &key[i]);
		for(i = n; i < 100; i++)	key[i] = key[i%n];
		
		scanf("%s", s);
		
		for(i = 0; i < 100; i++)
		{
			if(s[i] == '\0')	break;
			ans[i] = s[i];
		}
		
		for(i = 0; i < 100; i++)
		{
			if(s[i] == '\0')	break;
			for(j = 0; j < key[i]; j++)
			{
				if(ans[i] == 'a')	ans[i] = 'Z';
				else if(ans[i] == 'A')	ans[i] = 'z';
				else	ans[i]--;
			}
		}
		
		printf("%s\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <queue>

static constexpr long long int  INF = 10000000000;

int main() {
    int V, E;
    std::cin >> V >> E;

    // std::vector<std::vector<Line>> link_list(V);
    std::vector<std::vector<long long int>> costs(V, std::vector<long long int>(V, INF));
    for (int i = 0; i < V; i++) {
        costs[i][i] = 0;
    }

    for (int i = 0; i < E; i++) {
        int s, t, d;
        std::cin >> s >> t >> d;
        // link_list[s].push_back(Line(t, d));
        costs[s][t] = d;
    }

    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            if (costs[i][k] == INF) {
                continue;
            }
            for (int j = 0; j < V; j++) {
                if (costs[k][j] == INF) {
                    continue;
                }
                costs[i][j] = std::min(costs[i][j], costs[i][k] + costs[k][j]);
            }
        }
    }

    for (int i = 0; i < V; i++) {
        if (costs[i][i] < 0) {
            std::cout << "NEGATIVE CYCLE" << std::endl;
            return 0;
        }
    }

    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            if (j) {
                std::cout << " ";
            }
            if (costs[i][j] == INF) {
                std::cout << "INF";
            } else {
                std::cout << costs[i][j];
            }
        }
        std::cout << std::endl;
    }
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m; cin >> n >> m;
  const int nmmax = 50;
  int a[nmmax], b[nmmax];

  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
  }

  int road[nmmax];
  for(int i = 0; i < n; i++){
    road[i] = 0;
  }

  for(int i = 0; i < m; i++){
    road[a[i] - 1]++; road[b[i] - 1]++;
  }

  for(int i = 0; i < n; i++){
    cout << road[i] << endl;
  }
}

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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr<<"LINE ("<< __LINE__ << ") : [" << #__VA_ARGS__ << "] -> ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> a = {111, 222, 333, 444, 555, 666, 777, 888, 999};
    int n;
    cin >> n;
    auto it = lower_bound(a.begin(), a.end(), n);
    cout << *it; 
    return 0;
}




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

#define fr first
#define sc second
#define mk make_pair

using namespace std;

long long n, a, b;

int main()
{
    a = 1, b = 1;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        long long l, r;
        cin >> l >> r;
        l = l / __gcd(l, r);
        r = r / __gcd(l, r);
        long long rr = 1e18 / max(l, r) + 1, ll = 0;
        while(rr - ll > 1)
        {
            long long mid = (rr + ll ) / 2;
            if(mid * l >= a && mid * r >= b)
                rr = mid;
            else
                ll = mid;
        }
        a = rr * l;
        b = rr * r;
    }

    cout << a + b;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}


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

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

    int p[4][2];
    cin >> p[0][0] >> p[0][1] >> p[1][0] >> p[1][1];

    for (int i = 0; i < 2; ++i) {
        p[i + 2][0] = p[i + 1][0] - (p[i + 1][1] - p[i][1]);
        p[i + 2][1] = p[i + 1][1] + (p[i + 1][0] - p[i][0]);
    }
    cout << p[2][0] << " " << p[2][1] << " " << p[3][0] << " " << p[3][1] << endl;

    return 0;
}


Measured memory_bytes: 256