akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l,ans;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> n >> m;
  clr(d,0);
  rep(i,0,n)cin >> d[i];
  rep(i,0,n){
    l = 0;
    if(d[i] > m){
      l = d[i] - m;
      d[i] = m;
    }
    if(d[i] + d[i+1] > m){
      ll p = d[i] + d[i+1] - m;
      d[i+1] -= p;
      l += p;
    }
    ans += l;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1792
import numpy as np
N = int(input())
A_B = []
for i in range(N):
	A_B.append(list(map(int,input().split())))
A_B = np.array(A_B)

A_B_sort = A_B[np.argsort(A_B[:,1])]
time = 0
judge = True
for A_B_data in A_B_sort:
	time += A_B_data[0]
	if time > A_B_data[1]:
		judge = False
		break
if judge:
	print("Yes")
else:
	print("No")
	
	

Measured memory_bytes: 62468
N, M = map(int, input().split())
coma = list(map(int, input().split()))
difference = []

coma.sort(reverse = True)

for i in range(M - 1):
    difference.append(abs(coma[i + 1] - coma[i]))

difference.sort(reverse = True)

i = 0

print(sum(difference[i + N - 1:]))

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

// Common memset settings
//memset(memo, -1, sizeof memo); // dp memoization with -1
//memset(arr, 0, sizeof arr); //clear array of integers




int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;

	cin >> n;

	vector <long long> arr(n);

	for(int i =0;i<n;i++){
		cin >> arr[i];
	}

	long long left = arr[0];
	long long right = arr[n-1];

	int l_p = 0;
	int r_p = n-1;


	while(l_p < r_p){

		if(left < right){


			if(l_p + 1 == r_p)
				break;

			l_p++;

			left += arr[l_p];
		}else{
			if(r_p - 1 == l_p)
				break;

			r_p--;
			right += arr[r_p];
		}
	}

	long long ans = abs(right -left);

	cout << ans;

	

	return 0;
}






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

int main()
{
    long long int a,b,c,x;
    cin >> a >> b >> c;
    if(b-1<c)
    {
        x = b-1;
    }
    else
    {
        x = c;
    }
    cout << x * a / b << endl;
    

}

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

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


    double r;
    cin >> r;
    
    printf("%f %f", r * r * M_PI, 2 * M_PI * r);
    
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool CheckOK(int N, const string& S, const vector<int>& v)
{
    auto vv = [&](int i)
    {
        while (i < 0) i += N;
        while (i >= N) i -= N;
        return v[i];
    };

    rep(i, 0, N)
    {
        if (v[i] == 0)
        {
            if (S[i] == 'o')
            {
                if (vv(i - 1) != vv(i + 1)) return false;
            }
            else
            {
                if (vv(i - 1) == vv(i + 1)) return false;
            }
        }
        else
        {
            if (S[i] == 'o')
            {
                if (vv(i - 1) == vv(i + 1)) return false;
            }
            else
            {
                if (vv(i - 1) != vv(i + 1)) return false;
            }
        }
    }
    return true;
}

void _main()
{
    int N;
    string s;
    cin >> N >> s;
    rep(i, 0, 2)
    {
        rep(j, 0, 2)
        {
            vector<int> v;
            v.push_back(i);
            v.push_back(j);

            rep(k, 1, N - 1)
            {
                if (v[k] == 0)
                {
                    if (s[k] == 'o')
                    {
                        v.push_back(v[k - 1]);
                    }
                    else
                    {
                        v.push_back(1 - v[k - 1]);
                    }
                }
                else
                {
                    if (s[k] == 'o')
                    {
                        v.push_back(1 - v[k - 1]);
                    }
                    else
                    {
                        v.push_back(v[k - 1]);
                    }
                }
            }

            assert(v.size() == N);

            if (CheckOK(N, s, v))
            {
                for (const int i : v)
                {
                    cout << (i == 0 ? 'S' : 'W');
                }
                cout << endl;
                return;
            }
        }
    }
    cout << -1 << endl;
}


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

int mod; 
const int N = 310;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

void upd(ll &a, ll b) {
    a = (a + b) % mod;
}

int n, nek;
ll f[N][N], C[N][N], g[N][N];

int main() {
    scanf("%d%d%d", &n, &nek, &mod);
    C[0][0] = 1;
    for(int i = 1 ; i <= n + 1 ; ++ i) {
        C[i][0] = 1;
        for(int j = 1 ; j <= n + 1 ; ++ j) {
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
        }
    }
    for(int j = 0 ; j <= nek ; ++ j) {
        f[1][j] = 1;
        g[1][j] = 1;
    }
    for(int j = nek ; j >= 0 ; -- j) {
        upd(g[1][j], g[1][j + 1]);
    }
    for(int i = 2 ; i <= n + 1 ; ++ i) {
        for(int j = 0 ; j <= nek ; ++ j) {
            for(int k = 1 ; k <= i - 1 ; ++ k) {
                if(i - 2 >= 0 && k - 1 >= 0) {
                    // for(int l = j + 1 ; l <= nek ; ++ l) {
                    //     upd(f[i][j], C[i - 2][k - 1] * f[i - k][j] % mod * f[k][l] % mod);
                    // }
                    upd(f[i][j], C[i - 2][k - 1] * f[i - k][j] % mod * g[k][j + 1] % mod);
                }
            }
            g[i][j] = f[i][j];
        }
        for(int j = nek ; j >= 0 ; -- j) {
            upd(g[i][j], g[i][j + 1]);
        }
    }
    printf("%lld\n", (f[n + 1][0] % mod + mod) % mod);
}


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


int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    char s[6];
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    l = list(map(int, input().split()))

    if 0 in l:
        print(0)
        return

    prod = 1
    for i in l:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 87848
package main

import (
	"fmt"
	"math"
	"strconv"
)

func isSquareNumber(a float64) bool {
	x := math.Sqrt(a)
	return x-math.Trunc(x) == 0
}

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	n, _ := strconv.ParseFloat(a+b, 64)

	if isSquareNumber(n) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
using namespace std;
int main(){
  int Num_mountains = 10;
  int heights[Num_mountains];
  for (int i = 0;i<Num_mountains;i++)
    cin >> heights[i];
  sort(heights,heights+Num_mountains,greater<int>());
  for(int i=0;i<3;i++)
    cout << heights[i] << endl;

}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
char s[N]; int dp[N * 1000][2], dp2[N * 1000][2], n, tmp[2][2][2];
typedef long long LL;
inline void work(int k, int t) {
	memset(dp, 0x3f, sizeof(dp)), memset(dp2, 0x3f, sizeof(dp));
	dp[1][0] = 0, dp[1][1] = 1, dp2[1][1] = 1;
	for (int i = 2, cur = 2, ls = 1; i <= n * k; i++) {
		if (ls == n + 1) ls = 1;
		if (cur == n + 1) cur = 1;
		if (s[ls] == s[cur]) {
			dp[i][0] = dp[i - 1][1], dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + 1;
			dp2[i][0] = dp2[i - 1][1], dp2[i][1] = min(dp2[i - 1][0], dp2[i - 1][1]) + 1;
		} else {
			dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]), dp[i][1] = dp[i][0] + 1;
			dp2[i][0] = min(dp2[i - 1][0], dp2[i - 1][1]), dp2[i][1] = dp2[i][0] + 1;
		}
		ls++, cur++;
	}
	tmp[t][0][0] = dp[n * k][0], tmp[t][0][1] = dp[n * k][1];
	tmp[t][1][0] = dp2[n * k][0], tmp[t][1][1] = dp2[n * k][1];
}
LL f[1000010][2];
int main() {
	int k; scanf("%s%d", s + 1, &k), n = strlen(s + 1);
	if (s[1] != s[n]) {
		work(1, 0);
		printf("%lld\n", min(dp[n][0], dp[n][1]) * (LL)k);
		return 0;
	}
	work(1000, 0), work(k % 1000, 1);
	if (k < 1000) {
		printf("%lld\n", min(tmp[1][0][0], tmp[1][0][1]));
		return 0;
	}
	memset(f, 0x3f, sizeof(f)), f[1][0] = tmp[0][0][0], f[1][1] = tmp[0][0][1]; int cur = 1;
	for (int i = 2; i <= k / 1000; i++) {
		cur++;
		f[cur][0] = min(f[cur - 1][0] + tmp[0][1][0], f[cur - 1][1] + tmp[0][0][0]);
		f[cur][1] = min(f[cur - 1][0] + tmp[0][1][1], f[cur - 1][1] + tmp[0][0][1]);
	}
	if (k % 1000) {
		cur++;
		f[cur][0] = min(f[cur - 1][0] + tmp[1][1][0], f[cur - 1][1] + tmp[1][0][0]);
		f[cur][1] = min(f[cur - 1][0] + tmp[1][1][1], f[cur - 1][1] + tmp[1][0][1]);
	}
	printf("%lld\n", min(f[cur][0], f[cur][1]));
}

Measured memory_bytes: 17536
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String[] split = input.split(" ");
        int a = Integer.parseInt(split[0]);
        int b = Integer.parseInt(split[1]);

        if (a % 2 == 0 || b % 2 == 0) {
            System.out.print("Even");
        } else {
            System.out.print("Odd");
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main(){
  int d;
  cin >> d;
  if(d==25) cout << "Christmas";
  else if(d==24) cout <<"Christmas Eve";
  else if(d==23) cout <<"Christmas Eve Eve";
  else if(d==22) cout <<"Christmas Eve Eve Eve";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int N, A, B;
  cin >> N >> A >> B;
  int x = A * N;
  if (x < B)
  cout << x << endl;
  if (x > B)
  cout << B << endl;
  if (x == B)
  cout << B << endl;
  
}


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

long long fgcd(long long a, long long b) {
  long long x=min(a, b), y=max(a, b);
  if (y%x==0) return x;
  return fgcd(x, y%x);
}

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  long long lcm=c/fgcd(c, d)*d;
  cout << b-a-b/c+a/c-b/d+a/d+b/lcm-a/lcm << endl;
}

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

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
     
        char[] c = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        String S;
        int A, B;
        boolean answer = false;
      
        A = sc.nextInt();
        B = sc.nextInt();
        S = sc.next();
        
         String[] sol = S.split("-");
         if(sol.length != 2){
             System.out.println("No");
             return;
         }
         for(int k = 0; k<=1; k++){
             for(int i = 0; i<sol[0].length(); i++){
                 for(int j = 0; j<c.length; j++){
                    if(sol[0].charAt(i) == c[j])
                        answer = true;
                        continue;
                 }
             }
         }

        if(sol[0].length() != A || sol[1].length() != B || answer == false)
            System.out.println("No");
        
        else
            System.out.println("Yes");
     }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x;
    cin >> x;
    ll n=100;
    int cnt=0;
    while(n<x)
    {
        n+=n*0.01;
        cnt++;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d", &a,&b,&c);
	
	 if (a < b){
		if (b < c){
			printf("Yes\n");
		}
		else { printf("No\n"); }
	}
	else 	 {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 2616
fun main (args : Array<String>) {
	val d = readLine()
	val D : Int = d!!.toInt()
	return if (D == 25) {
		println("Christmas")
	} else if (D == 24) {
		println("Christmas Eve")
	} else if (D == 23) {
		println("Christmas Eve Eve")
	} else {
		println("Christmas Eve Eve Eve")
	}
}

Measured memory_bytes: 31744
#include<stdio.h>
const long mod = 1000000007l;
int N, A[1<<18];
long sum = 0, ans = 0;
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &A[i]);
		sum += A[i];
	}
	for(int i=0; i<N; i++){
		sum -= A[i];
		ans += sum % mod * A[i] % mod;
		ans %= mod;
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 2488
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TenkaBeginner2019B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());

            char s = S[K - 1];

            string ans = "";
            for(int i = 0; i < N; i++)
            {
                if (S[i] == s) ans += s;
                else ans += "*";
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
def examB():
    s = S()
    for i,j in enumerate(s):
        if j=="A":
            right = i
            break
    for i,j in enumerate(s[::-1]):
        if j=="Z":
            left = i
            break
    ans = len(s)-right-left
    print(ans)


import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 4012
N = int(input())
X_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(min(X_ls), max(X_ls) + 1):
    val = 0
    for j in X_ls:
        val += (i - j) ** 2
    if rst == -1:
        rst = val
    else:
        rst = min(rst, val)
print(rst)

Measured memory_bytes: 9152
#include<stdio.h>
#include<memory.h>
int main()
{
	long long int a[101][21];
	int n,i,i2,b[101];
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &b[i]);
	}
	memset(a,0,sizeof(a));
	a[0][b[0]] = 1;
	for (i = 0; i < n-2; i++){
		for (i2 = 0; i2 <= 20; i2++){
			if (a[i][i2] != 0){
				if (b[i + 1] + i2 <= 20){
					a[i + 1][b[i + 1] + i2] += a[i][i2];
				}
				if (i2 - b[i + 1] >= 0){
				a[i + 1][i2 - b[i + 1]] += a[i][i2];
			}
			}
		}
		
		
	}
	/*for (i = n - 2; i >= 0; i--){
		for (i2 = 0; i2 <= 20; i2++){
			printf("%3d", a[i][i2]);
		}
		printf("\n");
	}
	printf("\n");*/
	printf("%lld\n", a[n - 2][b[n - 1]]);
	return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define root sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : ' ');
  }
  // os << '}';
  return os;
}

int main()
{

  ll n, y;
  cin >> n >> y;
  int a = 10000, b = 5000, c = 1000, z;
  rep(i, n)
  {
    rep(j, n)
    {
      z = n - (i + j);
      if (0 <= z && z <= n && a * i + b * j + c * z == y)
      {
        cout << i << ' ' << j << ' ' << z << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    vector<int> c(1000005,0);
    vector<int> done(1000005,0);
    rep(i,n){
        if(done[a[i]]==1){
            c[a[i]]++;
            continue;
        }
        done[a[i]]=1;
        for(int j=a[i];j<1000005;j+=a[i]){
            c[j]++;
        }
    }
    int ans = 0;
    rep(i,n){
        if(c[a[i]]==1)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11588
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;

int main() {
  int d,n;
  cin >> d >> n;
  int m=pow(100,d);
  if(n<100) cout << pow(100,d) * n << endl;
  else cout << (int)pow(100,d) * 101 << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
 
  char S[10];
  char pre_S[10];
  
  scanf("%s", S);
  
  if (strcmp(S, "Sunny") == 0){
  
    printf("Cloudy");
  
  }else if (strcmp(S, "Cloudy") == 0){
  
    printf("Rainy");
    
  }else if (strcmp(S, "Rainy") == 0){
  
    printf("Sunny");
  }
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include <set> 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip> 
using namespace std;
int i,j,k,m,n,f[100010],g[100010],p[100010],q[100010],ans,w,d; 
int main(){

	while(1){
		ans=0;
		cin>>w>>d;
		if (w==0 && d==0) break;
		for(i=1;i<=w;i++) {
			cin>>f[i];
			ans+=f[i];
		}
		for(i=1;i<=d;i++){
			cin>>g[i];
			ans+=g[i];
		}
		memset(p,0,sizeof(p));
		memset(q,0,sizeof(q));
		
		for(i=1;i<=w;i++)
			for(j=1;j<=d;j++){
				if(f[i]==g[j]&&p[i]==0&&q[j]==0){
					ans=ans-f[i];
					p[i]=1;
					q[j]=1;
						
				}
			}
			
			
				
			
		cout<<ans<<endl;
			
		
		
	}


	return 0;
} 

Measured memory_bytes: 1956
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();

        var ans = 700;
        if (s[0] == 'o') ans += 100;
        if (s[1] == 'o') ans += 100;
        if (s[2] == 'o') ans += 100;
        Console.WriteLine(ans);
    }
}


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

using namespace std;

int main(){
  int h, w;
  int c[10][10];
  long long d[10];
  bool used[10];
  long long total=0;
  cin >> h >> w;
  for (int i=0;i<10;i++) {
    for (int j=0;j<10;j++) {
      cin >> c[i][j];
    }
  }
  for (int i=0;i<10;i++) {
    d[i] = c[i][1];
    used[i] = false;
  }
  used[1] = true;
  for (int i=0;i<10;i++) {
    int min_idx;
    int min_val = 1000000;
    for (int j=0;j<10;j++) {
      if (!used[j] && d[j] < min_val) {
	min_val = d[j];
	min_idx = j;
      }
    }
    used[min_idx] = true;
    for (int j=0;j<10;j++) {
      if (!used[j] && d[min_idx] + c[j][min_idx] < d[j]) {
	d[j] = d[min_idx] + c[j][min_idx];
      }
    }
  }
    
  for (int i=0;i<h;i++) {
    for (int j=0;j<w;j++) {
      int w;
      cin >> w;
      if (w == -1) {
	continue;
      }
      total += d[w];
    }
  }
  cout << total << endl;
  return(0);
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define ll long long
#define int long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> p;
signed main(){
    int n;
    cin>>n;
    vector<int>p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]--;
    }
    vector<bool>b(n+3,false);
    for(int i=0;i<n;i++){
        if(i==p[i]){
            b[i]=true;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(b[i]){
            ans++;
            if(b[i+1]==true){
                i++;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {

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

        int t[] = new int[5];
        t[0] = scan.nextInt();
        t[1] = scan.nextInt();
        t[2] = scan.nextInt();
        t[3] = scan.nextInt();
        t[4] = scan.nextInt();
        int g;

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4 - i; j++) {
                if (t[j] < t[j + 1]) {
                    int temp = t[j];
                    t[j] = t[j + 1];
                    t[j + 1] = temp;

                }
            }
        }

        System.out.println(t[0] + " " + t[1] + " " + t[2] + " " + t[3] + " " + t[4]);

    }
}



Measured memory_bytes: 26216
main = do
  n <- readLn :: IO Integer
  print $ minimum [maximum [f a,f b] | a<-[1..sq n], let b = div n a, a*b==n]
  where
    f 0 = 0
    f x = 1 + (f (div x 10))
    sq = truncate . sqrt . fromIntegral


Measured memory_bytes: 1020
N, M = map(int, input().split())

AB = [None] * N
for i in range(N):
    AB[i] = list(map(int, input().split()))

AB.sort(key = lambda ab: ab[0])

ans = 0
for ab in AB:
    a, b = ab
    c = min(M, b)
    ans += c*a
    M -= c
    if M == 0:
        break

print(ans)




Measured memory_bytes: 29020
#include <iostream>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

struct ModCalc{
        const long long MOD = 1e9+7;

        long long Permutation(long long n, long long r){
                long long tmp = 1;
                long long i = n;
                while(i!=n-r){
                        tmp *= i;
                        tmp %= MOD;
                        --i;
                }
                return tmp;
        }

        long long Factorial(long long x){
                long long tmp = 1;
                long long i = 1;
                while(i<=x){
                        tmp *= i;
                        tmp %= MOD;
                        ++i;
                }
                return tmp;
        }

        long long FastPow(long long x, long long p){
                if(p==1) return x;
                if(p%2==0){
                        long long sr = FastPow(x, p/2);
                        return (sr*sr)%MOD;
                }else{
                        long long sr = FastPow(x, (p-1)/2);
                        return ((x*sr)%MOD*sr)%MOD;
                }
        }

        long long Combination(long long n, long long r){
                return (Permutation(n,r)*FastPow(Factorial(r),MOD-2))%MOD;
        }
};

int main(){
        ll n,a,b,ans;
        cin >> n >> a >> b;
        ModCalc mc;
        ans = mc.FastPow(2, n) - 1;
        ans -= mc.Combination(n,a);
        if(ans<0) ans += MOD;
        ans -= mc.Combination(n,b);
        if(ans<0) cout << ans+MOD << endl;
        else cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();

            long c1 = (long) Math.pow((N + K / 2) / K, 3);
            long c2 = (long) Math.pow(N / K, 3);
            if (K % 2 == 0) {
                out.println(c1 + c2);
            } else {
                out.println(c2);
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int a[5];
    int x=0,tmp=0;
    int sum=0;
    for(int i=0;i<5;i++){
        cin>>a[i];
        if(a[i]%10==0){
            sum+=a[i];
        }else{
            sum+=(a[i]/10+1)*10;
            x=10-a[i]%10;
        }
        tmp=max(x,tmp);
    }
    cout<<sum-tmp<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int n,m;
string s[99];
int d[99][99];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
main()
{
	while(cin>>m>>n,n)
	{
		for(int i=0;i<2*n-1;i++)for(int j=0;j<2*m-1;j++)d[i][j]=1e9;
		cin.ignore();
		for(int i=0;i<2*n-1;i++)getline(cin,s[i]);
		d[0][0]=1;
		queue<pair<int,int> >P;
		P.push(make_pair(0,0));
		while(!P.empty())
		{
			int x=P.front().first,y=P.front().second;P.pop();
			for(int r=0;r<4;r++)
			{
				int tx=x+dx[r],ty=y+dy[r];
				if(tx<0||ty<0||tx>=2*n||ty>=2*m||s[tx][ty]=='1')continue;
				tx+=dx[r],ty+=dy[r];
				if(d[tx][ty]<1e9)continue;
				d[tx][ty]=d[x][y]+1;
				P.push(make_pair(tx,ty));
			}
		}
		cout<<(d[2*n-2][2*m-2]<1e9?d[2*n-2][2*m-2]:0)<<endl;
	}
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

int main(){
  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);
  vector<string> res;
  for (int i = 0; i + m <= n; i++) {
    bool all = true;
    string tmp = s;
    
    for (int j = i; j < i + m; j++) all &= (s[j] == '?' || s[j] == t[j-i]);

    if (all) {
      for (int j = 0; j < n; j++) if (s[j] == '?') tmp[j] = 'a';
      //cout << tmp << endl;
      for (int j = i; j < i + m; j++) tmp[j] = t[j-i];
      //cout << tmp << endl;
      res.emplace_back(tmp);
    }
    
  }
  sort(res.begin(), res.end());
  
  if (res.empty()) cout << "UNRESTORABLE" << endl;
  else cout << res.front() << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="TLE")
            tle++;
        else if(s=="WA")
            wa++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<ll> p(n), c(n);
  REP(i, n) cin >> p[i], p[i]--;
  REP(i, n) cin >> c[i];
  ll ans = -INF;
  REP(si, n){
    ll x = si;
    vector<ll> s;
    ll total = 0;
    while(1){
      x = p[x];
      s.emplace_back(c[x]);
      total += c[x];
      if(x == si) break;
    }
    ll l = s.size();
    ll now = 0;
    REP(i, l){
      now += s[i];
      if(i+1 > k) break;
      ll t = now;
      if(total > 0){
        ll e = (k-i-1)/l;
        t += total*e;
      }
      chmax(ans, t);
    }
  }
  cout << ans << endl;
  return 0;
}

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

vector<int> prime;


void makePrime(){
  bool p[100010];
  rep(i,100010) p[i] = true;
  p[0] = false;
  p[1] = false;
  for(int i = 2; i * i < 100010; i++ ){
    if(p[i] == false) continue;
    int x = 2;
    while(x*i < 100010){
      p[x*i] = false;
      x++;
    }
  }

  rep(i,100010){
    if(p[i]) prime.push_back(i);
  }
  //cerr << prime.size() << endl;
}

ll m,a,b;

void solve(){
  ll ans = 0;
  pair<ll,ll> ans_p;
  rep(i,prime.size()){
    ll p = prime[i];
    for(int j = i; j < prime.size(); j++){
      ll q = prime[j];
      if(a*q > p*b) break;
      if(p*q > m) break;
      if( ans < p*q ){
        ans = p*q;
        ans_p = {p,q};
      }
    }
  }
  cout << ans_p.first << " " << ans_p.second << endl;
}

int main(){
  makePrime();
  while(true){
    cin >> m >> a >> b;
    if(m == 0) break;
    solve();
  }
  return 0;
}



Measured memory_bytes: 3216
_, nCities = map(int, input().split())
a = sorted([list(map(int, input().split())) + [i] for i in range(nCities)])
ret = [None] * nCities
prevPref = -1
order = 1
for pref, _ ,idx in a:
    if pref == prevPref:
        order += 1
    else:
        prevPref = pref
        order = 1
    ret[idx] = str(pref).zfill(6) + str(order).zfill(6)
print('\n'.join(ret))

Measured memory_bytes: 34100
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
  vector<int>x={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << x[k-1] << endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    vector<ll> p;
    p.push_back(0);
    for(ll i = 0; i < n; i++){
        ll a;
        cin >> a;
        p.push_back(a);
    }
    p.push_back(0);
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(p[i]==i && p[i+1]!=i){
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int N, A;
int x[55];

typedef long long ll;

ll dp[55][2510];

int main() {

	int i, j, k;

	scanf("%d %d",&N,&A);

	int ma = 0;

	for (i = 1; i <= N; i++) {
		scanf(" %d",&x[i]);
		ma += x[i];
	}

	dp[0][0] = 1ll;

	for (k = 1; k <= N; k++) {
		for (i = k - 1; i >= 0; i--) {
			for (j = 0; j <= ma; j++) {
				dp[i + 1][j + x[k]] += dp[i][j];
			}
		}
	}

	ll ans = 0;
	for (i = 1; i <= N; i++) {
		ans += dp[i][A*i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define mod 1000000007
#define INF (ll)9999999999999999

#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;


int main() {
	int n;
	cin >> n;
	vi a(n);
	rep (i,n) cin>>a[i];

	int o=0, d4=0, e=0;

	rep (i, n) {
		o += a[i]&1;
		if (a[i]%4==0) d4+=1;
		else e += !(a[i]&1);
	}

	if (o > d4+1)
		return log("No"), 0;
	if (e > 0)
		if (o > d4) return log("No"), 0;

	log("Yes");

	return 0;
}



Measured memory_bytes: 640
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,K;
    in >> N >> K ;
    ll c = 0, a= 0;
    double b;
    //vector<ll> A(N);
    //string s;
    //in >> s;
    //vector<string> s;
    //s.resize(N);
    ll tmp;

    N=N%K;
    

    for(;;){

        tmp = N;
        N = abs(tmp-K);
        if(N >= tmp){
            out << tmp << endl;
            break;
        }
    }
    
    

    
}

Measured memory_bytes: 256
a, b, c = gets.split.map(&:to_i)

if a == b && b == c && a.even?
  puts -1
  exit
end

n = 0
while a.even? && b.even? && c.even?
  a_t = a/2
  b_t = b/2
  c_t = c/2
  a = b_t + c_t
  b = a_t + c_t
  c = a_t + b_t
  n += 1
end
puts n


Measured memory_bytes: 1788
Q = int(input())
ans = 0
INF = 10 ** 5
is_prime = [1] * INF
rui = [0] * (INF + 1)
def eratorasu():
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2, INF):
        if is_prime[i] == 0:
            continue
        for j in range(i * 2, INF, i):
            is_prime[j] = 0
    return

eratorasu()
sosu = [0] * INF
for i in range(INF):
    if is_prime[i] == 1 and is_prime[(i + 1) // 2] == 1:
        sosu[i] = 1

rui = [0] * (INF + 1)
for i in range(INF):
    rui[i + 1] = rui[i] + sosu[i]

for i in range(Q):
    l, r = map(int, input().split())
    ans = rui[r + 1] - rui[l]
    print(ans)

Measured memory_bytes: 7876
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;

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

    static class TaskD {
        final int[] dx = new int[]{1, 0, 0, -1};
        final int[] dy = new int[]{0, 1, -1, 0};
        private Pair<Integer, Pair<Integer, Integer>> now;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int H = in.nextInt();
            int W = in.nextInt();
            char[][] S = new char[H][];
            for (int i = 0; i < H; i++) {
                S[i] = in.next().toCharArray();
            }
            Integer[][] vis = new Integer[H][W];
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    vis[i][j] = (int) 1e9;
                }
            }
            Queue<Pair<Integer, Pair<Integer, Integer>>> que = new ArrayDeque<>();
            que.add(Pair.MakePair(1, Pair.MakePair(0, 0)));
            while (!que.isEmpty()) {
                now = que.poll();
                if (vis[now.second.first][now.second.second] <= now.first) {
                    continue;
                }
                vis[now.second.first][now.second.second] = now.first;
                for (int d = 0; d < 4; d++) {
                    int nx = now.second.first + dx[d];
                    int ny = now.second.second + dy[d];
                    if (0 <= nx && nx < H && 0 <= ny && ny < W && S[nx][ny] == '.') {
                        que.add(Pair.MakePair(now.first + 1, Pair.MakePair(nx, ny)));
                    }
                }
            }
            if (vis[H - 1][W - 1] < (int) 1e9) {
                int cnt = 0;
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        if (S[i][j] == '#') {
                            cnt++;
                        }
                    }
                }
                out.println(H * W - cnt - vis[H - 1][W - 1]);
            } else {
                out.println(-1);
            }
        }

    }

    static class Pair<T1, T2> {
        public T1 first;
        public T2 second;

        public Pair(T1 f, T2 s) {
            this.first = f;
            this.second = s;
        }

        public static <T1, T2> Pair MakePair(T1 f, T2 s) {
            return new Pair<T1, T2>(f, s);
        }

    }
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
 
int n, q;
vector<int> edge[300004];
long long x[300004];
long long counter[300004];
bool visit[300004];
 
void dfs(int here, long long add){
	visit[here] = 1;
	counter[here] = add;
	for(int there : edge[here])
		if(!visit[there])
			dfs(there, add + x[there]);
}
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n>>q;
	for(int i = 0;i<n-1;i++){
		int a, b;
		cin>>a>>b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	memset(x, 0, sizeof(x));
	memset(visit, 0, sizeof(visit));
	memset(counter, 0, sizeof(counter));
	for(int i = 0;i<q;i++){
		int p, a;
		cin>>p>>a;
		x[p] += a;
	}
	dfs(1, x[1]);
	for(int i = 1;i<=n;i++)	cout<<counter[i]<<' ';
	return 0;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
 
int N,M,A,B,C,K;
char s,t;

signed main() {
    IOS();
    cin>>s;
    if(s=='A')cout<<'T'<<endl;
    else if(s=='T')cout<<'A'<<endl;
    else if(s=='C')cout<<'G'<<endl;
    else cout<<'C'<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
result=0
if H==1 or W==1:
    result=1
elif W%2==0:
    result = (W/2)*H
else:
    if H%2==0:
        result=W*(H/2)
    else :
        result=W*(H-1)/2+(W+1)/2
print(str(round(result)))


Measured memory_bytes: 3060
#include <iostream>
using namespace std ;
int main()
{
  double num1 , num2 ;
  
  cin >> num1 >> num2 ;
  
  if((num1+num2)/2 > ((int)num1+(int)num2)/2){
    cout <<((int)num1+(int)num2)/2+1 <<endl ;
  }
  else if ((num1+num2)/2 == ((int)num1+(int)num2)/2){
    cout << ((int)num1+(int)num2)/2 <<endl ;
  }
  return 0 ;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while (x->left != NIL) x = x->left;
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;

  if(k < u->key) return treeSearch(u->right, k);

  else return treeSearch(u->right, k);

}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y == NIL) root = z;
  else if (z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);

    printf(" ");
    printf("%d", u->key);

    inorder(u->right);
  }
}

void preorder(Node u){
  if (u != NIL) {
    printf(" ");
    printf("%d", u->key);

    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<bool> visited;
vector<ll> tour;
void dfs(ll s,vector<vector<ll> > &graph)
{
    visited[s]=true;
    tour.push_back(s+1);
    for(ll i=0;i<4;i++)
    {
        if(graph[s][i] && !visited[i])
        {dfs(i,graph);tour.push_back(s+1);}
    }
}
int main()
{
    vector<vector<ll> > graph(4,vector<ll> (4,0));
    ll a,b;
    visited.resize(4,false);
    for(ll i=0;i<3;i++)
    {
        cin>>a>>b;
        graph[a-1][b-1]=1;
        graph[b-1][a-1]=1;
    }
    dfs(0,graph);
    ll sum = 0;
    for(ll i=0;i<4;i++)
    {
        sum+=tour[i];
    }
    /*for(ll i=0;i<7;i++)
    cout<<tour[i];
    cout<<"\n";*/
    if(sum == 10)
    cout<<"YES";
    else
    cout<<"NO";
    return 0;
}

Measured memory_bytes: 764
hoge = ["FizzBuzz" if i % 15 == 0 else("Fizz" if i % 3 == 0 else("Buzz" if i % 5 == 0 else str(i))) for i in range(10001)]

while True:
    m, n = map(int, input().split())
    if m == 0:
        break
    man = list(range(1, m+1))
    game = [input() for _ in range(n)]
    idx = 0
    for i in range(n):
        if game[i] != hoge[i+1]:
            del man[idx]
            if len(man) == 1:
                break
        else:
            idx += 1
        idx %= len(man)
    print(*man)

Measured memory_bytes: 9328
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll hashCnt[1000005];

int main() {
	scanf("%lld", &N);
	ll temp = N;
	ll cnt = 1;
	hashCnt[N]++;
	while(hashCnt[temp] != 2) {
		if(temp % 2 == 0) {
			temp = temp / 2;
		}
		else {
			temp = (3 * temp) + 1;
		}
		hashCnt[temp]++;
		// cout << temp << " ";
		cnt++;
	}
	printf("%lld\n", cnt);


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int a, b, k; cin >> a >> b >> k;
    rep(i, k) {
        if(i & 1) {
            if(b & 1) {
                -- b;
            }
            b /= 2;
            a += b;
        } else {
            if(a & 1) {
                -- a;
            }
            a /= 2;
            b += a;
        }
    }
    cout << a << " " << b << endl;
}

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

Measured memory_bytes: 256