akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
long long gcd(long long a,long long b)
{ return b?gcd(b,a%b):a;}

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

int main()
{
	long long n,x,y;
	scanf("%lld%lld",&n,&x);
	n--;
	while(n--)
	{
		scanf("%lld",&y);
		x=lcm(x,y);
	}
	printf("%lld\n",x);
}

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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

ll a[100007];

int main(){
	setIO();
	ll mult = 1;
	int n; cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(a[i] == 0){
			cout<<"0\n";
			return 0;
		}
		ll res = mult*a[i];
		if ((ld)res/a[i] != mult || res>(ll)1e18){
			cout<<"-1\n";
			return 0;
		}
		mult = res;
	}
	cout<<mult<<endl;
}

Measured memory_bytes: 4436
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	long long n,k,cnt=1,ans,x;
	cin >> n >> k;
	for(long long i=0;i<n;i++){
			cin >> x;
	}
	for(ans=k;ans<n;ans+=k){
		cnt++;
		if(ans>=n){
			break;
		}
		ans--;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
const ll MOD=1000000007LL;
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  if((b-a)*(n-2)+1<0){
    cout<<0<<endl;
    return 0;
  }
  cout<<(b-a)*(n-2)+1<<endl;
}
  

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a == b){
			System.out.println("a == b");
		}else if(a < b){
			System.out.println("a < b");
		}else{
			System.out.println("a > b");
		}
	}
}

Measured memory_bytes: 26116
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int m, n;
    while (cin >> m >> n, n != 0 && m != 0) {
        const int maximum = 7500000;
        vector<int> a(maximum);

        int remain = n;
        int ans = -1;
        for (int i = m; i <= maximum; ++i) {
            if (a[i] != 0) {
                continue;
            }

            if (remain == 0) {
                ans = i;
                break;
            }

            remain--;

            for (int j = i; j <= maximum; j += i) {
                a[j] = 1;
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 32420
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		const int B[]={0,10,20,30,40,50,60};
		int count[7]={0};
		for(int i=0,age;i<n;++i){
			cin>>age;
			for(int j=6;j>-1;--j) if(B[j]<=age){++count[j];break;}
		}
		for(int i=0;i<7;++i)cout<<count[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 860
import java.util.Scanner;

public class Main {

	static boolean[] primes;
	
	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];
		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int call = 0;
		while(true){
			int n = stdIn.nextInt();
			if(n==0)
				return;
			if(call<n){
				primeSet(n+100);
				call=n;
			}
			
			int a=0;
			for(int i=n;;i--){
				if(primes[i]){
					a=i;
					break;
				}
			}
			for(int i=n;;i++){
				if(primes[i]){
					System.out.println(i-a);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 14000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  rep(i, N)
  {
    cin >> m[i];
    X -= m[i];
  }
  sort(m.begin(), m.end());
  int ans = X / m[0] + N;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int max(vector<int> v)
{
    int maxVal = 0;
    for(int i = 0; i < (int)v.size(); ++i) {
        if( v[i] > maxVal )
            maxVal = v[i];
    }
    return maxVal;
}

int main(void) {
  int n;

  cin >> n;

  int tmp;
  vector<int> input;
  for(int i=0; i<n; i++) {
    cin >> tmp;
    input.push_back(tmp);
  }

  int opcnt = 0;

  bool endflag = false;
  while(true) {

    for(int i=0; i<input.size(); i++) {
      //cout << input[i];
      if((input[i]%2) == 0) {
        input[i] /= 2;
      } else {
        endflag = true;
        break;
      }
    }

    if(endflag == false) {
      opcnt ++;
      int maxvalue = max(input);
      if(maxvalue == 0) {
        break;
      }
    } else {
      break;
    }

  } /* while... */
  cout << opcnt;
}

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

using namespace std;

int main() {
	int r, d, x;
	scanf("%d%d%d", &r, &d, &x);
	for(int i = 0; i < 10; i++) {
		x = r * x - d;
		printf("%d\n", x);
		
	}
	return 0;
}


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

// 0 - 1
//   - 2 - 5
//   - 3 - 6 - 4

using namespace std;

void dfs(vector<vector<int> > &graph, vector<int> &len, int start){
	vector<int> s;
	s.push_back(start);
	len[start] = 0;
	
	while(s.size() > 0){
		int x = s.back();
		s.pop_back();
		
		for(int i = 0;i < graph[x].size();i++){
			if(len[graph[x][i]] < 0){
				len[graph[x][i]] = len[x]+1;
				s.push_back(graph[x][i]);
			}
		}
	}
}

int main(){
	int n;
	cin >> n;
	vector<vector<int> > graph(n);
	vector<int> lenf(n, -1), lens(n, -1);
	
	for(int i = 0;i < n-1;i++){
		int a, b;
		cin >> a >> b;
		graph[a-1].push_back(b-1);
		graph[b-1].push_back(a-1);
	}
	
	dfs(graph, lenf, 0);
	dfs(graph, lens, n-1);
	
	int numf = 0, nums = 0;
	for(int i = 0;i < n;i++){
		if(lenf[i] <= lens[i]) numf++;
		else nums++;
	}
	
	if(numf > nums){
		cout << "Fennec" << endl;
	}else{
		cout << "Snuke" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int max(int a, int b){return a > b ? a : b;}

int main(void){
	int w, h, n, x, y, a;
	int sx = 0, ex, sy = 0, ey;
	scanf("%d %d %d", &w, &h, &n);
	ex = w; ey = h;
	for(int i = 0; i < n; i++){
		scanf("%d %d %d", &x, &y, &a);
		switch(a){
			case 1:
				if(sx < x)sx = x;
				break;
			case 2:
				if(x < ex)ex = x;
				break;
			case 3:
				if(sy < y)sy = y;
				break;
			case 4:
				if(y < ey)ey = y;
				break;
			default:
				break;
		}
	}
	printf("%d\n", max(ey - sy, 0) * max(ex - sx, 0));
	return 0;
}


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

int main() {
  long long H, W; cin >> H >> W;
  long long ans = H * W / 2;
  if (H % 2 == 1 && W % 2 == 1) ans++;
  if (H == 1 || W == 1) ans = 1;

  cout << ans << endl;

  return 0;
}


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

int main() {
 
  string A, B;
  cin >> A >> B;
  
  if(A.at(0) == B.at(2) && A.at(1) == B.at(1) && A.at(2) == B.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
    
}


Measured memory_bytes: 256
<?php
//外心＝各辺の垂直二等分線の交点
//傾きの積が-1ならば、その2直線は垂直に交わる

$file_handle = fopen('php://stdin', "r");

fscanf($file_handle, '%d', $n);

for($i=1; $i<=$n; $i++){
	fscanf($file_handle,'%f %f %f %f %f %f',$x1,$y1,$x2,$y2,$x3,$y3);
	
	// 3辺の方程式、y=ax+b のa,bを求める
	// 傾きから。0除算注意
	// 同時に垂直二等分線の傾きも求めておく
	if ( ($x1-$x2)==0 ){
		$a1 = false;
		$ra1 = 0;
	} else if ( ($y1-$y2)==0 ){
		$a1 = 0;
		$ra1 = false;
	} else {
		$a1 = ($y1-$y2) / ($x1-$x2);
		$ra1 = -1 / $a1;
	}
	if ( ($x2-$x3)==0 ){
		$a2 = false;
		$ra2 = 0;
	} else if ( ($y2-$y3)==0 ){
		$a2 = 0;
		$ra2 = false;
	} else {
		$a2 = ($y2-$y3) / ($x2-$x3);
		$ra2 = -1 / $a2;
	}
	if ( ($x3-$x1)==0 ){
		$a3 = false;
		$ra3 = 0;
	} else if ( ($y3-$y1)==0 ){
		$a3 = 0;
		$ra3 = false;
	} else {
		$a3 = ($y3-$y1) / ($x3-$x1);
		$ra3 = -1 / $a3;
	}
	// 切片不要
	//$b1 = $y1 - $a1*$x1;
	//$b2 = $y2 - $a2*$x2;
	//$b3 = $y3 - $a3*$x3;
	// 垂直二等分線の方程式を求める。
	// 三角形の各辺の中点を求める。
	$mx1 = ($x1+$x2)/2;  $my1 = ($y1+$y2)/2;
	$mx2 = ($x2+$x3)/2;  $my2 = ($y2+$y3)/2;
	$mx3 = ($x3+$x1)/2;  $my3 = ($y3+$y1)/2;
	// 切片を
	$rb1 = $my1 - $ra1*$mx1;
	$rb2 = $my2 - $ra2*$mx2;
	$rb3 = $my3 - $ra3*$mx3;
	// 垂直二等分線2本に注目し、その交点を求める
	if ($ra1 !== false && $ra2 !== false) {
		$px = ($rb2-$rb1) / ($ra1-$ra2);
		$py = $ra1*$px + $rb1;
	} else if ($ra2 !== false && $ra3 !== false) {
		$px = ($rb3-$rb2) / ($ra2-$ra3);
		$py = $ra2*$px + $rb2;
	} else if ($ra3 !== false && $ra1 !== false) {
		$px = ($rb1-$rb3) / ($ra3-$ra1);
		$py = $ra3*$px + $rb3;
	}
	// 外接円の半径ｒを求める。sqrt:SQuare RooT(平方根)
	$sqr = pow($px-$x1,2) + pow($py-$y1,2);
	$r = sqrt($sqr);
	// 整形
	$px = round($px, 3); $px = sprintf('%.3f', $px);
	$py = round($py, 3); $py = sprintf('%.3f', $py);
	$r = round($r, 3);   $r = sprintf('%.3f', $r);
	// 出力
	echo $px.' '.$py.' '.$r.PHP_EOL;
}

Measured memory_bytes: 6644
#include <stdio.h>
#define DATAMAX 200
#define DIGITMAX 7
int main(void) {
    long int a,b,sum;
    int i,j;
    int count;
    for(i=0;scanf("%ld %ld",&a,&b)!=EOF;i++){
//        scanf("%ld %ld",&a,&b);
//        printf("%d,%d\n",a,b);
//        if(a<0||b<0){  //データの終わりならプログラム終了
//            break;
//        }
         
        count=0;
        sum=a+b;
        for(i=0;i<DIGITMAX&&sum!=0;i++){
            sum/=10;
        }
        printf("%d\n",i);
    }
     
        return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main( void ){
    
    int casenum = 1;
    int input;
    
    while( 1 ){
        
    scanf( "%d", &input );
    
    if( input == 0 )
      break;
    else
      printf( "Case %d: %d\n", casenum, input );
      
    casenum++;
      
    }
    
    return 0;
    
}


Measured memory_bytes: 2100
#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()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	string	s;
	bitset<200> bs;

	cin >> s;
	rep(i, s.size())
	{
		if (bs.test(s.at(i)))
		{
			cout << "no" << endl;
			return (0);
		}
		else
			bs.set(s.at(i));
	}
	cout << "yes" << endl;
}


Measured memory_bytes: 256
import sys
MAX = 100005
n, q = map(int, input().split())

def initialize():
    head = tail = 0
    return head, tail

def isEmpty(head, tail):
    return head == tail

def isFull(head, tail):
    return head == (tail + 1) % MAX

def enqueue(x, head, tail):
    if isFull(head, tail):
        print('Error')
        sys.exit()
    Q[tail] = x
    if tail + 1 == MAX:
        tail = 0
    else:
        tail += 1
    return tail

def dequeue(head, tail):
    if isEmpty(head, tail):
        sys.exit()
    x = Q[head]
    if head + 1 == MAX:
        head = 0
    else:
        head += 1
    return x, head

head, tail = initialize()
Q = [0] * MAX
for _ in range(n):
    name, time = map(str, input().split())
    time = int(time)
    tail = enqueue([name, time], head, tail)
T = 0
while True:
    Qi, head = dequeue(head, tail)
    name = Qi[0]
    time = Qi[1]
    if time <= q:
        T += time
        print(name, T)
    else:
        T += q
        time -= q
        tail = enqueue([name, time], head, tail)



Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    int neg = 0;
    rep(i,n){
        if(a[i] < 0) neg++;
    }
    ll ans = 0;
    ll mn = LINF;
    rep(i,n){
        ans += abs(a[i]);
        mn = min(mn, abs(a[i]));
    }
    if(neg % 2 == 0){
        cout << ans << endl;
    }else{
        cout << ans - 2 * mn << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    int a, b, s, d, f, g;
    cin >> a >> b >> s >> d >> f >> g;
    if (f - a > g)cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

n,m = map(int, input().split())
hs = {i+1: x for i,x in enumerate(map(int, input().split()))}
neighbor = defaultdict(set)
for _ in range(m):
  a,b = map(int, input().split())
  neighbor[a] |= {b}
  neighbor[b] |= {a}

c = 0
check = set()
for k in hs.keys():
  if k in check: continue
  flag = True
  for x in neighbor[k]:
    if hs[x] < hs[k]:
      check |= {x}
    else:
      flag = False
  if flag:
    c += 1
print(c)

Measured memory_bytes: 61280
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

void incr(vector<ll>& b, ll a) {
    rep(i, b.size()) {
        if (a & (1LL << i)) {
            b[i]++;
        }
    }
}

void decr(vector<ll>& b, ll a) {
    rep(i, b.size()) {
        if (a & (1LL << i)) {
            b[i]--;
        }
    }
}

bool update(vector<ll>& b, ll a) {
    incr(b, a);
    rep(i, b.size()) {
        if (b[i] > 1) {
            return false;
        }
    }
    return true;
}

void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    vector<ll> b(30);

    ll res = 0;
    ll j = 0;
    rep(i, n) {
        while (j < n && update(b, A[j])) {
            j++;
        }

        res += j - i;

        if (i == j) {
            j++;
        }

        decr(b, A[i]);
        if (i != j) {
            decr(b, A[j]);
        }
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4852
#include<stdio.h>
#include<string.h>
#define NUM 1000

int main()
{
  char num[NUM];
  int x, sum, i;

  while(1){
    sum=0;
    scanf("%s", &num);

    if(num[0] == '0')break;

    x = strlen(num);

    for(i=0; i < x; i++){
      sum +=  num[i] - '0';
    }

    printf("%d\n", sum);
  }

  return 0;
}

Measured memory_bytes: 536
alp=[chr(ord('a') + i) for i in range(26)]
unused=set(alp)
     
S=input()
#print("len",len(S))

if len(S)<26:
    for i in range(len(S)):
        if S[i] in unused:
            unused.remove(S[i])
    unused=sorted(unused)
    print(S+unused[0])
else:
    for j in range(len(S)-1,-1,-1):
        p=set(S[j:])
        #print(p)
        q=sorted(p)
        if S[j]==q[-1]:
            pass
        else:
            idx=q.index(S[j])
            print(S[:j]+q[idx+1])
            break
    else:
        print(-1)

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

# P, Q, R = map(int, input().split())
#
# heap = []
# heappush(heap, P * (-1))
# heappush(heap, Q * (-1))
# heappush(heap, R * (-1))
#
# heappop(heap)
#
# heap = list(map(lambda x: x * -1, heap))
# print(sum(heap))

A = sorted(list(map(int, input().split())))
print(sum(A[:2]))


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if (x == 3) {
        ans += 100000;
    } else if (x == 2) {
        ans += 200000;
    } else if (x == 1) {
        ans += 300000;
    }
    if (y == 3) {
        ans += 100000;
    } else if (y == 2) {
        ans += 200000;
    } else if (y == 1) {
        ans += 300000;
    }

    if (x == 1 && y == 1) {
        ans += 400000;
    }

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



Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}




int main(void) {
  ll N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  ll i;
  vector<ll> l, r;
  
  ll ans=0;
  for(i=0; i<N;) {
    ll t=0;
    if(s[i]=='L') {
      while(i<N && s[i]=='L') {
        t++;
        i++;
      }
      ans+=t-1;
    }else {
      while(i<N && s[i]=='R') {
        t++;
        i++;
      }
      ans+=t-1;
    }
  }
  
  pt(min(ans+K*2, N-1));
  
}


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

#define ll long long int

int piedras[100005];
ll memo[100005];
char visitado[100005];
int N;

ll costo(int n){
	if(!n) return 0;
	if(n == 1) return memo[1] = abs(piedras[0]-piedras[1]);
	if(visitado[n]) return memo[n];
	visitado[n] = 1;
	return memo[n] = min(costo(n-1)+abs(piedras[n]-piedras[n-1]),
						 costo(n-2)+abs(piedras[n]-piedras[n-2]));
}


int main() {
	cin>>N;
	for(int i = 0; i<N;i++)
		cin>>piedras[i];
	cout<<costo(N-1)<<"\n";
	return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b;
  if(b>a)swap(a,b);
  while(a!=b){
    c=a-b;
    a=b;
    b=c;
    if(b>a)swap(a,b);
  }
  cout<<b<<endl;
  return 0;
}



Measured memory_bytes: 3076
import sys
n=int(input())
a=input()
a=[int(s)for s in a.split()]
M=1
Q=1
m=sum(a)
if a[0]>=1:
    if a[0]==1 and n==0:
        print(1)
        sys.exit()
    else:    
        print(-1)
        sys.exit()
for i in range(n):
    M=2*M-a[i+1]
    if M<0:
        print(-1)
        sys.exit()
    M1=M+a[i+1]
    m=m-a[i]
    Q=Q+min(M1,m)
print(Q)

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

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

    ll a[n];
    ll sum = 0;
    ll sum_odd = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
        if(i % 2 == 0 && i <= n - 3)
            sum_odd += a[i];
    }

    ll d[n];
    d[n-1] = (sum / 2 - sum_odd) * 2;
    d[0] = 2 * a[n-1] - d[n-1];

    rep(i, n - 1){
        d[i+1] = 2 * a[i] - d[i];
        cout << d[i] << " ";
    }

    cout << d[n-1] << endl;
    return 0;
}


Measured memory_bytes: 2816
import Data.List
import Data.Maybe
import Control.Applicative

main = interact $ unlines . map (maybe "-1" show . kakezan . read) . tail . lines

kakezan :: Int -> Maybe Int
kakezan n = kak [n] n
 where
  kak (a:acc) n'
   | n' <= 9 = Just 0
   | elem n' acc = Nothing
   | otherwise = succ <$> kak (nummax:acc) nummax
   where nummax = maximum [read s1 * read s2 | let s = show n', i <- [1 .. length s - 1], let (s1,s2) = splitAt i s]

Measured memory_bytes: 4244
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n , m , cnt;
string s;
int main(){
    cin >> s;
    for( auto it:s )
        cnt+=it-48;
    if( cnt % 9 == 0 )
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 3720
// 6/2
// 2-6-4. 素数のこすう
// エラトステネスの篩
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
    // vector<vector<bool>> is_unique(1e6 + 1, vector<bool>(1e6 + 1, true));  // is_unique[i][j] = j / iがユニークかどうか

    // for (int i = 1; i < 1e6; i++) {
    //     for (int j = 1; j < )
    // }

    // Sieve sieve(1e6);

    // vector<int> f(1e6 + 1);  // f[i] = 分母がiの時の項目数

    // f[0] = 0;
    // f[1] = 2;  // 0/1, 1/1

    // for(int i = 2; i <= 1e6; i++) {

    //     vector<P> fact = sieve.factor(i);
    //     ll yakusu = 1;
    //     for (auto f : fact) {
    //         yakusu *= f.second + 1;
    //     }
    //     f[i] = i - yakusu;
    // }

    // vector<int> unique(1e6 + 1);  // unique[i] = 分母がiで約分できない数。ただし0は覗く。

    // rep(i, 1e6 + 1) unique[i] = i;

    // for (int i = 1; i <= 1e6; i++) {
    //     for (int j = i * 2; j <= 1e6; j += i) {
    //         unique[j]--;
    //     }
    // }

    // unique[1] += 1;  // 1の時は0/1があるので特殊。

    // vector<int> ans(1e6 + 1);
    // ans[0] = 0;
    // for(int i = 1; i <= 1e6; i++) {
    //     printf("unique[%d] = %d\n", i, unique[i]);
    //     ans[i] = ans[i - 1] + unique[i];
    // };

    Sieve sieve(1e6);
    vector<ll> F(1e6 + 1);
    F[0] = 0;
    F[1] = 2;
    for (int i = 2; i <= 1e6; i++) {
        vector<P> primes = sieve.factor(i);
        F[i] = i;
        for (auto p : primes) {
            F[i] *= (1.0 - 1.0 / (double)p.first);
        }
    }

    // rep(i, 10) {
    //     printf("F[%d] = %d\n", i, F[i]);
    // }

    vector<ll> ans(1e6 + 1);
    ans[0] = 0;
    for (int i = 1; i <= 1e6; i++) {
        ans[i] = ans[i - 1] + F[i];
    }

    int t;
    cin >> t;

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

    rep(i, t) cout << ans[n[i]] << endl;
}


Measured memory_bytes: 22592
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack 
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <list>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  sort(s.begin(),s.end());
  long long sum=1;
  for(int i=0; i<n-1; i++){
    if(s[i]!=s[i+1]) sum++;
  }
  cout << sum << endl;
}


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

using namespace std;


class LazySegT{
private:
  int NN;
  struct Node{
	int f, g, l, r;
	int lazy;
  };
  Node segT[2*(1<<17)-1]; // =131072
public:
  LazySegT(int n){
	NN = 1;
	while(NN < n) NN <<= 1;

	for(int i=0;i<2*NN-1;++i){
	  segT[i].f = segT[i].g = segT[i].l = segT[i].r = 0;
	  segT[i].lazy = -1;
	}
  }

  void eval(int k, int l, int r){
	if(segT[k].lazy < 0) return;
	
	segT[k].f = (r-l) * segT[k].lazy;
	segT[k].g = (r-l-1) * segT[k].lazy;
	segT[k].l = segT[k].r = segT[k].lazy;

	if(k < NN-1){
	  segT[2*k+1].lazy = segT[2*k+2].lazy = segT[k].lazy;
	}
	segT[k].lazy = -1;
  }

  void update(int a, int b, int bit, int k, int l, int r){
	eval(k,l,r);
	if(r <= a || b <= l) return;

	if(a <= l && r <= b){
	  segT[k].lazy = bit;
	  eval(k,l,r);
	}
	else{
	  int m = (l+r) / 2;
	  update(a, b, bit, k*2+1, l, m);
	  update(a, b, bit, k*2+2, m, r);

	  segT[k].f = segT[k*2+1].f + segT[k*2+2].f;
	  segT[k].g = segT[k*2+1].g + segT[k*2+2].g + segT[k*2+1].r * segT[k*2+2].l;
	  segT[k].l = segT[k*2+1].l;
	  segT[k].r = segT[k*2+2].r;
	}
  }
  void update(int a, int b, int c){
	update(a, b, c, 0, 0, NN);
  }

  int query(){
	eval(0, 0, NN);
	return segT[0].f - segT[0].g;
  }
};

int main(){
  int N; cin >> N;
  string X; cin >> X;
  int Q; cin >> Q;

  LazySegT seg(N);
  for(int i=0;i<X.size();++i){
	seg.update(i, i+1, X[i]-'0');
  }

  for(int q=0;q<Q;++q){
	int l, r, b;
	cin >> l >> r >> b;
	--l;
	seg.update(l, r, b);
	cout << seg.query() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8444
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;


int main() {
	ll a, b, c, k, ans=0;
	cin >> a >> b >> c >> k;
	if (a <= k) {
		k = k - a;
		ans = a;
		for (ll i = 0; i < k; i++) {
			if (b != 0) {
				b--;
			}
			else {
				c--;
				ans--;
			}
		}
	}
	else {
		ans = k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();        
        String t = sc.next();
        String t2 = t.substring(0, t.length()-1);
        if (t2.equals(s)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35752
#include <stdio.h>

int main(int argc, char *argv[])
{
	int n, x = 3;

	scanf("%d", &n);
	while (x <= n)
	{
		if (x % 3 == 0)
		{
			printf(" %d", x);
		}
		else if (x % 10 == 3)
		{
			printf(" %d", x);
		}
		else
		{
			int y = x / 10;
			while (y)
			{
				if (y % 10 == 3)
				{
					printf(" %d", x);
					break;
				}
				y = y / 10;
			}
		}
		x++;
	}

	printf("\n");
	return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
     
    int main() {
        int n;
        cin>>n;
        vector<double> a(n);
        for(int i=0;i<n;i++) cin>>a[i];
        double dp[n+1][n+1];
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++) dp[i][j] = 0;
        }
        
        dp[0][0] = 1;
        
        for(int i=1;i<=n;i++){
            dp[i][0] = dp[i-1][0] * (1 - a[i-1]); 
        }
        
        for(int i=1;i<=n;i++){
            for(int j=1;j<=i;j++){
                dp[i][j] = dp[i-1][j-1]*a[i-1];
                dp[i][j] += dp[i-1][j]*(1-a[i-1]); 
            }
        }
        double ans=0;
        for(int i=n/2+1;i<=n;i++){
            ans += dp[n][i];
        }
        
        printf("%0.10lf",ans);
        
        return 0;
    } 

Measured memory_bytes: 70528
#include <iostream>
#include <string.h>
using namespace std;

int main(){
	char in[30];
	char out[30];
	cin >> in;
	int length = strlen(in);
	for(int i = 0; i<=length;i++){
		out[i] = in[length -i-1];	
	}
	out[length] = in[length];
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define lmax LLONG_MAX
#define lmin LLONG_MIN
#define imax INT_MAX
#define imin INT_MIN
#define f(i,a,b) for(long long i=a;i<b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define tc long long test;cin>>test;while(test--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define up upper_bound
#define lo lower_bound
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long
#define umap unordered_map

int fun(vector<int>& arr, int n) { 
    int max_sum = arr[0], min_sum = arr[0];  
    for (int i = 0; i < n; i++) { // Finding max and min sum value 
        max_sum=max(max_sum,arr[i]);
        min_sum=min(min_sum,arr[i]);
    } 
    return (max_sum-min_sum); 
} 
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ll n;
    cin>>n;
    
    ll arr1[n];
    ll arr2[n];
    
    f(i,0,n){
        cin>>arr1[i];
        cin>>arr2[i];
    }

    vector<int> sum1(n,0),diff1(n,0),sum2(n,0),diff2(n,0);
    for(int i=0;i<n;i++) {
        sum1[i]=arr1[i]+arr2[i];
        diff1[i]=arr1[i]-arr2[i];
        sum2[i]=arr1[i]+arr2[i];
        diff2[i]=arr1[i]-arr2[i];
    }
    cout<<max(max(fun(sum1,n),fun(diff1,n)),max(fun(sum2,n),fun(diff2,n)));  

    // cout<<res-1<<endl;    

    return 0;
}

Measured memory_bytes: 9588
#include<stdio.h>

int main(){
  int x,y,tmp,tmpp;
  scanf("%d %d",&x,&y);
  if(x>y){
    tmp =x;
    x=y;
    y=tmp;
  }
  while(x%y !=0){
    tmp =x;
    tmpp=y;
    x = tmpp;
    y=tmp % tmpp;
    
  }
  printf("%d\n",y);
return 0;
}



Measured memory_bytes: 2080
#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 int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	char c;
	in(c);
	out((char)(c+1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1000000007;

int n, m;
bool ng[100001];
int dp[100001];
int main() {
  cin >> n >> m;
  for (int j = 0; j < m; ++j) {
    int k;
    cin >> k;
    ng[k] = true;
  }
  
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (ng[i]) continue;
    dp[i] += dp[i - 1];
    if (i >= 2) dp[i] += dp[i - 2];
    if (dp[i] >= MOD) dp[i] -= MOD;
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll INF = 2000000000;

ll mergesort(vector<ll> &a,ll index,ll k){
  ll l =0,r = k/2;
  vector<ll> vec(k);
  rep(i,k) vec.at(i) = a.at(i+index);
  /*cout<<index<<endl;
  rep(i,k)cout<<vec.at(i)<<' ';
  cout<<endl;
  rep(i,k)cout<<a.at(i+index)<<' ';
  cout<<endl;*/
  ll ans = 0;
  reps(i,index,k+index){
    if(l == k/2){
      a.at(i) = vec.at(r);
      ++r;
      continue;
    }
    if(r == k){
      a.at(i) = vec.at(l);
      ++l;
      continue;
    }
    if(vec.at(l)>vec.at(r)){
      ans+= k/2 - l;
      a.at(i) = vec.at(r);
      ++r;
    }else{
      a.at(i) = vec.at(l);
      ++l;
    }
  }
  //cout<<ans<<endl;
  return ans;
  
}
int main() {
  cin>>N;
  ll vs=1;
  while(N>vs) vs <<= 1;
  vector<ll> a(vs,INF);
  rep(i,N) cin>>a.at(i);
  /*rep(i,vs) cout<<a.at(i)<<' ';
    cout<<endl;*/
  //=で反転しないように注意
  ll nvs = 1;
  ll ans=0;
  //cout<<vs<<endl;
  while(vs>1){
    vs >>= 1;
    nvs <<= 1;
    rep(i,vs) ans += mergesort(a,nvs*i,nvs);
    //cout<<ans<<endl;
  }
  /*rep(i,nvs) cout<<a.at(i)<<' ';
    cout<<endl;*/
  cout<<ans<<endl;
}



Measured memory_bytes: 7924
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
//	run();
	ll n, a, b;
	cin >> n >> a >> b;
	ll cnt = n / (a + b);
	n %= (a + b);
	cout << cnt * a + min(a, n);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define M_PI 3.14159265358979

int main(void){
    double num;
    //????????\???
    scanf("%lf",&num);
    double circumference=num*2*M_PI;
    double circlearea=num*num*M_PI;
    
    printf("%.6f %.6f\n",circlearea,circumference);

return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<int> dist;

    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        dist.resize(n);
        for(int i=0;i<n;i++)par[i]=i,rank[i]=0,dist[i]=0;
    }
    int root(int x){
        if(par[x]==x){
            return x;
        }else{
            int r = root(par[x]);
            dist[x]+=dist[par[x]];
            return par[x] = r;      
        }
    }
    int dis(int x){
        root(x);
        return dist[x];
    }
    int diff(int x,int y){
        return dis(y)-dis(x);
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    void unite(int x,int y,int d){
        d+=dis(x);
        d-=dis(y);
        x=root(x);
        y=root(y);
        if(x==y)return;
        if(rank[x]<rank[y])swap(x,y),d=-d;
        if(rank[x]==rank[y])++rank[x];
        par[y]=x;
        dist[y]=d;
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int l,r,d;
        cin >> l >> r >> d;
        l--;r--;
        if(uf.same(l,r)){
            int diff = uf.diff(l,r);
            if(diff!=d){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            uf.unite(l,r,d);
        }
    }
    cout <<"Yes"<< endl;

}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  cnt += n >= 10 ? 9 : n;
  cnt += n >= 1000 ? 900 : max(n - 99, 0);
  cnt += n >= 100000 ? 90000 : max(n - 9999, 0);
  cout<<cnt<<endl;
}


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

int main() {
    int n;
    cin >> n;
    int pre = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x - pre >= -1) {
            pre = max(pre, x);
            continue;
        } else {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x,u,b,c,a=0,i,j,o,q;
int main()
{
    cin>>u>>b>>c>>x;
    for(i=0;i<=u;i++)
    {
        for(j=0;j<=b;j++)
        {
            for(o=0;o<=c;o++)
            {
                q=i*500+j*100+o*50;
                if(q==x) a=a+1;
            }
        }
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#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 REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

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

  int y,m,d;
  char c1,c2;
  cin >> y >> c1 >> m >> c2 >> d;
  cout << (m <= 4 ? "Heisei" : "TBD") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector> 
#include<stack>

using namespace std;

typedef long long ll;
const int N=2e5+10;
int l;//1所连接的环的起点
int dfn[N],low[N];
bool instack[N]; 
int ans;//记录环的大小 
int idex=1;
int len;//1所在的链路的大小 
stack<int> s;
vector<int> G[N];
bool flag =1;

void tarjan(int u){
	s.push(u);
	instack[u]=1;
	len++;
	int v;
	dfn[u]=low[u]=idex++;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i];
		if(!dfn[v]){
			tarjan(v);
			low[u]=min(low[u],low[v]);
		}
		else if(instack[v]){
			low[u]=min(low[u],dfn[v]);
			
		}
	}
	if(dfn[u]==low[u]){
		if(flag){
			l=u;
		}
		while(1){
			if(flag) ans++;
			v=s.top();
			s.pop();
			instack[v]=0;
			if(u==v){
				flag=0;
				break;
			}
		}
	}
}
int main()
{
	ll n,k;
	cin>>n>>k;
	int u;
	for(int i=1;i<=n;i++){
		cin>>u;
		G[i].push_back(u);
	}
	tarjan(1);
	int answer;
	int num=len-ans;//链路上除了环的大小以外的大小 
	if(k<=num-1){
		answer=1;
		while(k--){
			answer=G[answer][0];
		}
		cout<<answer<<endl;	
	}
	else{
		answer=l;
		k=k-num;
		k%=ans;
		while(k--){
			answer=G[answer][0];
		}
		cout<<answer<<endl;
	} 
	return 0;
} 

Measured memory_bytes: 32384
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10, MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long double a, b;
	cin >> a >> b;
	cout << (long long)floor(a * b) << '\n';
}

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

ll gcd(ll,ll);

int main(){
  ll x,y;
  cin>>x>>y;
  if(x<y) swap(x,y);
  cout<<gcd(x,y)<<endl;
  return 0;
}

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



Measured memory_bytes: 3084
n = int(input())
s = input()
 
r = []
g = []
b = []
 
val = 0
 
for i in range(n):
    if s[i] == "R":
        r.append(i+1)
    elif s[i] == "G":
        g.append(i+1)
    else:
        b.append(i+1)

r = set(r)
g = set(g)
b = set(b)
for i in r:
    for j in g:
        if 2 * j - i in b:
            val +=1
for i in g:
    for j in b:
        if 2 * j - i in r:
            val +=1
for i in b:
    for j in r:
        if 2 * j - i in g:
            val +=1

print(len(r) * len(g) * len(b) - val)

Measured memory_bytes: 67804
if __name__ == '__main__':
    from collections import deque

    la = list(map(int, input().split()))

    nl = deque([])

    for i in range(0, la[0]):
        nl.append(list(input()))

    for j in range(len(nl)):
        if '#' not in nl[j]:
            nl[j].clear()

    sl = [u for u in nl if u]

    for c in range(0, la[1]):
        zl = [row[c] for row in sl]
        # print(zl)
        if '#' not in zl:
            for d in sl:
                d[c] = ''

    for e in range(len(sl)):
        sl[e] = [u for u in sl[e] if u]

    for k in sl:
        print(''.join(k))


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

int main()
{
    long N;
    std::cin >> N;
    std::vector<std::vector<int> > map(50,std::vector<int>(26));
    for(long i=0; i<N; i++){
        std::string H;
        std::cin >> H;
        int length=H.length();
        for(int j=0; j<length; j++){
            map[i][H[j]-97]+=1;
        }
    }


    for(int i=0; i<26; i++){
        std::vector<int> temp;
        for(int j=0; j<N; j++){
            temp.push_back(map[j][i]);
        }
        std::sort(temp.begin(),temp.end());
        int num=temp[0];
        for(int j=0; j<num;j++){
            std::string S;
            S=i+97;
            std::cout << S;
            temp.clear();
        }
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*
願はくは花の下にて春死なんそのきさらぎの望月のころ（西行 1118-1190）
--This is old Japanese poem expressing the desire to die under tree on the full moon night.(written by Saigyo)
In my research, there is possibility that the tree may be seg-tree.
*/

/*Coding Space*/
// n <= 40 は半分全列挙って古事記にも書いてある。（多分）

int dp[41][1000][1000] = {}; // cost
int main(){
  int n,ma,mb; cin >> n >> ma >> mb;
  int ans = INF;
  fill_n(dp[0][0],41*1000*1000,INF);
  dp[0][0][0] = 0;
  rep(i,n){
    int a,b,c; cin >> a >> b >> c;
    rep(j,1000)rep(k,1000)if(dp[i][j][k]!=INF){
      dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
      dp[i+1][j+a][k+b] = min(dp[i][j][k] + c, dp[i+1][j+a][k+b]);
    }
  }
  rep(j,1000)rep(k,1000){
    if(j != 0 && k != 0 && dp[n][j][k] != INF && j*mb == k * ma)
      ans = min(ans, dp[n][j][k]);
  }
  
  cout << (ans == INF?-1:ans) << endl;
}

Measured memory_bytes: 160384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i > 0; i--)

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    char last = ' ';
    rep(i,n){
        if(last == s[i])continue;
        else{
            last = s[i];
            ans ++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int REM[3][31];
int D[31][31];
int c[501][501];

int main()
{
	int N, C;
	int ans = (int)1e9;

	cin >> N >> C;
	repc(i, 1, C) repc(j, 1, C) cin >> D[i][j];
	repc(i, 1, N) repc(j, 1, N) cin >> c[i][j];

	repc(color, 1, C) {
		repc(i, 1, N) repc(j, 1, N) {
			REM[(i + j) % 3][color] += D[c[i][j]][color];
		}
	}

	repc(c1, 1, C) repc(c2, 1, C) repc(c3, 1, C) {
		if (c1 == c2 || c2 == c3 || c3 == c1) continue;
		ans = min(ans, REM[0][c1] + REM[1][c2] + REM[2][c3]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define forn(i,x,y) for(int i=x;i<y;++i)
#define fornr(i,x,y) for(long long i=x;i>=y;--i)
#define testcase int _t; cin >> _t; while(_t--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 1e3+10;
int dp[MAXN][MAXN]; //
int main()
{
	ios_base :: sync_with_stdio(false);
  	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int h,w;
	cin >> h >> w;
	char grid[h+1][w+1];
	ll mod = (int)1e9+7;
	forn(i,1,h+1)
		forn(j,1,w+1)
			cin >> grid[i][j];
	dp[1][1] = 1;
	forn(i,1,h+1)
		grid[i][0] = '!';	    
	forn(i,1,w+1)
		dp[0][i] = '!';	    
	forn(i,1,h+1){
		forn(j,1,w+1){
			if(grid[i][j] == '#') continue;
			if(grid[i][j-1] == '.')
				dp[i][j] += (dp[i][j-1]%mod);
			if(grid[i-1][j] == '.')
				dp[i][j] += (dp[i-1][j]%mod);
			dp[i][j] %= mod;
		}
	}
	cout << dp[h][w];  	
  	return 0;
}

 	/* 















 	*/


Measured memory_bytes: 8464