akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int h, n;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		h -= a;
	}
	if (h <= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint k;
    cin >> k;
    vector<vector<lint>> run(10), run2(10), run3(10);
    vector<lint> ret;
    for (int i = 0; i < 10; ++i) {
        run[i].push_back(i);
        if (i)
            ret.push_back(i);
    }
    for (lint i = 1; i < 11; ++i) {
        lint tens = 1;
        for (int j = 0; j < i; ++j) {
            tens *= 10;
        }
        for (lint j = 0; j < 10; ++j) {
            for (int k = max(0LL, j - 1); k <= min(9LL, j + 1); ++k) {
                for (auto &r : run[k]) {
                    run2[j].push_back(j * tens + r);
                    if (j)
                        ret.push_back(run2[j].back());
                }
            }
        }
        swap(run, run2);
        run2.assign(10, vector<lint>());
    }
    sort(ret.begin(), ret.end());
    cout << ret[k - 1] << "\n";
    return 0;
}

Measured memory_bytes: 15084
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

    
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int n,k;
    cin >> n >> k;
    if(k == 1) {
        print(0);
        return 0;
    }
    print(n - k);

}

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

int main(){
    string s,t;
    getline(cin,s);
    getline(cin,t);
    int ans = 0,i,j,count;
    if(s.find(t) == string::npos){
        i  = 0;
        ans = t.length();
        for(i = 0;i<=s.length()-t.length();++i){
                int j = 0;
                count = 0;
                for(int p = i;p<s.length(), j<t.length();p++,j++){
                    if(s[p] != t[j]){
                        count++;
                    }
                }
                ans = min(count,ans);
        }
        
    }
    cout<<ans;
    return 0;
}

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

//リストじゃできなかった。頑張ったけど、終わった。
class Node
{
    public:
        int key;
        Node* next;
};

class List
{
    private:
        Node* head;
        Node* now;
        Node* prev;
        Node* target;
    public:
        int cnt;
        List();
        void Insert( int k );
        void Erase( int k );
        void showA();
        void showB();
};

List::List()
{
    cnt = 0;
    head = NULL;
    now = NULL;
}

void List::Insert( int k )
{
    Node* p = new Node;
    if( head == NULL )
    {
        head = p;
        now = p;
        target = head;
        p -> key = k;
        p -> next = head;
        cnt++;
        return;
    }
    
    now -> next = p;
    now = p;

    p -> key = k;
    p -> next = head;
    cnt++;

    return;
}

void List::Erase( int k )
{
    Node* dt;

    for( int i = 1; i < k % cnt; i++ )
    {
        prev = target;
        target = target -> next;
    }

    if( k % cnt == 0 )
    {
        int rep = k - 1;
        while( rep-- )
        {
            prev = target;
            target = target -> next;
        }
    }

    if( k == 1 )
        prev = now;

    dt = target;
    if( dt == head )
        head = dt -> next;

    prev -> next = dt -> next;
    target = target -> next;

    cnt--;
    delete dt;
}

void List::showA()
{
    cout << head -> key << endl;
    return;
}

void List::showB()
{
    cout << head -> key << " ";
    Node* p = head -> next;

    while( p != head )
    {
        cout << p -> key << " ";
        p = p -> next;
    }

    cout << endl;
    return;
}

int main()
{
    int n, k, m;

    while( cin >> n >> k >> m )
    {
        if( n + k + m == 0 )
            break;

        List l;
        for( int i = 0; i < n; i++ )
            l.Insert( i + 1 );

        l.Erase(m);
        while( l.cnt != 1 )
            l.Erase(k);
        
        l.showA();
    }
    return 0;
}


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

namespace AtCoder2020Ned
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long k = long.Parse(input[1]);

            long Answer =Sub(n,k);
            
            Console.Write(Answer);
            Console.Read();
        }
         public static long Sub(long n,long k)
        {
            for (;;)
            {
                n = n % k;
                if (k == 1)
                {
                    return 0;
                }
                else if (n < Math.Abs(n - k))
                {
                    return n;                    
                }
                n = Math.Abs(n - k);
            }
        }
    }
}


Measured memory_bytes: 27500
#include <stdio.h>
using namespace std;

class BinaryTree
{
private:
	class Node
	{
	public:
		Node ()
		{
			this->parent = NULL;
			this->left = NULL;
			this->right = NULL;
		}

		int item;
		Node* parent;
		Node* left;
		Node* right;
	};

	Node* root;

	void PreOrder (Node * node)
	{
		if (node != NULL)
		{
			printf (" %d", node->item);
			PreOrder (node->left);
			PreOrder (node->right);
		}
	}
	void InOrder (Node* node)
	{
		if (node != NULL)
		{
			InOrder (node->left);
			printf (" %d", node->item);
			InOrder (node->right);
		}
	}
	void DeletePostOrder (Node* node)
	{
		if (node != NULL)
		{
			DeletePostOrder (node->left);
			DeletePostOrder (node->right);
			delete node;
		}
	}
public:
	BinaryTree ()
	{
		this->root = NULL;
	}
	~BinaryTree ()
	{
		DeletePostOrder (root);
	}

	void Insert (int value)
	{
		Node* parentNode = NULL;
		Node* searchNode = root;

		Node* newNode = new Node;
		newNode->item = value;

		//???????????????????????????????????????
		while (searchNode != NULL)
		{
			parentNode = searchNode;

			if (newNode->item < searchNode->item)
			{
				searchNode = searchNode->left;
			}
			else
			{
				searchNode = searchNode->right;
			}
		}

		newNode->parent = parentNode;

		//????????????????????????
		if (parentNode == NULL)
		{
			root = newNode;
		}
		else
		{
			if (newNode->item < parentNode->item)
			{
				parentNode->left = newNode;
			}
			else
			{
				parentNode->right = newNode;
			}
		}
	}
	bool Find (int value)
	{
		Node* searchNode = root;

		while (searchNode != NULL)
		{
			if (searchNode->item == value)
			{
				return true;
			}
			//???
			if (value < searchNode->item)
			{
				searchNode = searchNode->left;
			}
			//???
			else
			{
				searchNode = searchNode->right;
			}
		}

		return false;
	}
	void Print ()
	{
		InOrder (root);
		printf ("\n");
		PreOrder (root);
		printf ("\n");
	}
};

int main ()
{
	int dataCount;
	scanf ("%d", &dataCount);

	BinaryTree binaryTree;

	for (int lp = 0; lp < dataCount; lp++)
	{
		char inputStr[10];
		scanf ("%s", inputStr);

		if (inputStr[0] == 'i')
		{
			int inputNum;
			scanf ("%d", &inputNum);

			binaryTree.Insert (inputNum);
		}
		else if (inputStr[0] == 'f')
		{
			int inputNum;
			scanf ("%d", &inputNum);

			bool isFind = binaryTree.Find (inputNum);

			if (isFind)
				printf ("yes\n");
			else
				printf ("no\n");
		}
		else
		{
			binaryTree.Print ();
		}
	}

	return 0;
}

Measured memory_bytes: 21460
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 11
int main(){
    int n,cnt=1;
    scanf("%d",&n);
    char S[n+1][STR];

    for(int i=0;i<n;i++){
        scanf("%s\n",S[i]);
    }
    qsort(S,n,sizeof(S[0]),strcmp);

    for(int i=1;i<n;i++){
        if(strcmp(S[i-1],S[i]) != 0){
            cnt += 1;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 5716
l,r=map(int,input().split())
mod=2019
l_mod=l%2019
ll=l//2019
r_mod=r%2019
rr=r//2019
if ll<rr:
    print(0)
else:
    ans=[]
    for i in range(l_mod,r_mod+1):
        for j in range(l_mod,r_mod+1):
            if i<j:
                ans.append((i*j)%2019)
    print(min(ans))

Measured memory_bytes: 75416
import java.util.*;

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

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

        double val = Math.log(n) / Math.log(k);

        if (val % 1 == 0) {
            val++;
        }

        System.out.println((int) Math.ceil(val));
    }
}


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

int n,m,q,ans=0;
vector<int>	a,b,c,d;

void dfs(vector<int> A){
  if(A.size() == n+1){
    int score=0;
    for(int i=0;i<q;i++){
      if(A.at(b.at(i))-A.at(a.at(i))==c.at(i)){
        score+=d.at(i);
      }
    }
    ans=max(ans,score);
    return;
  }
  
  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }
}

int main(){
  cin >> n >> m >> q;
  a=b=c=d=vector<int>(q);
  for(int i=0;i<q;i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }
  dfs(vector<int>(1,1));
  cout << ans;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){

    int h,m,s,S;
    
    cin >>S;
    
    h=S/(60*60);
    S=S-h*60*60;
    s=S%60;
    
    m=S/60;
    
    cout <<h<<":"<<m<<":"<<s<<endl;

}



Measured memory_bytes: 3096
import java.util.*;

public class Main{

    int n,m;
    int[][] e;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            if(n==0 && m==0) break;

            //a, b, w
            e = new int[m][3];
            for(int i=0; i<m; i++){
                int a = sc.nextInt(), b = sc.nextInt();
                int w = sc.nextInt();
                e[i] = new int[]{a-1,b-1,w};
            }

            Arrays.sort(e, new Comparator<int[]>(){
                    public int compare(int[] a, int[] b){
                        return a[2] - b[2];
                    }
                });
            int ans = Integer.MAX_VALUE;
            for(int i=0; i<m && m-i>=n-1; i++){
                ans = Math.min(ans, kruskal(i));
            }

            if(ans==Integer.MAX_VALUE) ans = -1;
            System.out.println(ans);
        }
    }

    int kruskal(int idx){
        init();

        int res = 0;
        for(int i=idx;i<m; i++){
            if(!same(e[i][0],e[i][1])){
                unite(e[i][0],e[i][1]);
                res = e[i][2];
            }
        }

        boolean same = true;
        for(int i=1; i<n; i++){
            if(!same(0,i)){
                same = false;
                break;
            }
        }

        if(same) return res-e[idx][2];
        else return Integer.MAX_VALUE;
    }

    int[] par, rank;
    void init(){
        par = new int[n];
        rank = new int[n];
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x){
        if(par[x]==x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) par[x] = y;
        else{
            par[y] = x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }
    boolean same(int x, int y){
        return find(x)==find(y);
    }

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

Measured memory_bytes: 13000
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cstdio>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
int a[100000+5];
int main()
{
    int n,sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<n;i++)
    {
        if(a[i]==i) {swap(a[i],a[i+1]);sum++;}
    }
    if(a[n]==n) sum++;
    printf("%d\n",sum);
    return 0;
}


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

int main() {
	long long h, n, sum = 0; cin >> h >> n;
	for (int i = 0; i < n; i++) {
		long long tmp; cin >> tmp; sum += tmp;
	}
	cout << (sum >= h ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
# author:  Taichicchi
# created: 17.09.2020 23:35:32

import sys

a, b, c = map(int, input().split())


s = (c - a - b) ** 2 - 4 * a * b


if (s > 0) & (c - a - b > 0):
    print("Yes")
else:
    print("No")


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<Double> ary = new ArrayList<>();
		int i = 0;
		while (true){
			double num = k / Math.pow(2, i);
			if(num < 1){
				break;
			}
			ary.add(num);
			i++;
		}
		int[] coinNums = new int[n];
		int coinNum = ary.size();
		loop:
		for(int m = 1; m <= n; m++){
			while(ary.get(coinNum - 1) <= m ){
				coinNum--;
				if (coinNum == 0){
					break loop;
				}
			}
			coinNums[m - 1] = coinNum;
		}
		double ans = 0;
		for(int cn : coinNums){
			ans += 1 / (double)n / Math.pow(2, cn);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21332
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int i,n;
	bool flag=false,c[4];
	ll x,t,y,j,m=0ll,ans=0ll,d[4]={0ll,3ll,5ll,7ll};
	cin >> x;
	for(j=1ll; j<(1ll<<20); ++j){
		y = 0ll;
		fill(c,c+4,false);
		t = j;
		while(t){
			y *= 10ll;
			y += d[t%4];
			c[t%4] = true;
			t /= 4;
		}
		if((!c[0] && c[1] && c[2] && c[3] && y<=x)){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll m = min({a, b, c, d, e});
  ll cnt = (n - 1) / m + 1;
  ll ans = 5 + cnt - 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string a,b,c;
    cin >> a >> b >> c;
    //int lena,lenb,lenc;
    int lena=a.size();
    int lenb=b.size();
    int lenc=c.size();
   // printf("lena=%d,lenb=%d,lenc=%d",lena,lenb,lenc);
    char x='a';
    int counta=0,countb=0,countc=0;
    while(1){
        if (x=='a'){
            x=a[counta];
            counta++;
        }
        else if (x=='b'){
            x=b[countb];
            countb++;
        }
        else{
            x=c[countc];
            countc++;
        }
        //printf("%d %d %d\n",counta-1,countb-1,countc-1);
        if (lena==counta-1||countb-1==lenb||countc-1==lenc){
            break;
        }
    }
    if (counta-1==lena){
        printf("A\n");
    }
    else if (countb-1==lenb){
        printf("B\n");
    }
    else if (countc-1==lenc){
        printf("C\n");
    }
}

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

int main() {
    int N,Q;
    cin >> N >> Q;
    vector<int> a(N-1),b(N-1);
    for ( int i = 0; i < N-1; ++i){
        int c,d;
        cin >> c >> d;
        a.at(i) = c - 1;
        b.at(i) = d - 1;
    }

    
    vector<vector<int>> Graph;
    Graph.resize(N);
    for ( int i = 0; i < N-1; ++i){
        Graph[a.at(i)].push_back(b.at(i));
        Graph[b.at(i)].push_back(a.at(i));
    }

    
    vector<int> p(Q),x(Q);
    for ( int i = 0; i < Q; ++i){
        int q;
        cin >> q >> x.at(i);
        p.at(i) = q - 1;
    }
    
    // 頂点pの根に与えられるポイントx
    map<int,int> m;
    for ( int i = 0; i < Q; ++i){
        m[p.at(i)] = m[p.at(i)] + x.at(i);
    }
    
    
    vector<int> ans(N,0);
    vector<int> done(N,0);
    queue<int> que;
    que.push(0);
    while( que.size() ){
        int pos = que.front(); que.pop();
        //cout << "pos" <<  pos << endl;
        ans.at(pos) = ans.at(pos) + m[pos];
        //cout << ans.at(pos) << endl;
        done.at(pos) = 1;
        for ( int i = 0; i < Graph[pos].size(); ++i){
            int pos_next = Graph[pos][i];
            if ( done[pos_next] == 1 ) continue;
            m[pos_next] = m[pos_next] + m[pos];
            que.push(pos_next);
        }
    }

    
    for ( int i = 0; i < N; ++i){
        cout << ans.at(i) << " ";
    }
    cout << endl;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 28788
#include <stdio.h>
#include <math.h>

typedef struct{
  double x,y;
}Pos;
void calc_pos(int,Pos,Pos);
void Print(Pos);

int main(){
  Pos pos1,pos2;
  int n;
  pos1.x  =0.0;pos1.y=0.0;
  pos2.x=100.0;pos2.y=0.0;
  scanf("%d",&n);
  Print(pos1);
  calc_pos(n,pos1,pos2);
  Print(pos2);
  return 0;
}

void calc_pos(int n,Pos p1,Pos p2){
  Pos s,t,u;
  if(n==0){
    return;
  }

  s.x=(2.0*p1.x+p2.x)/3.0;
  s.y=(2.0*p1.y+p2.y)/3.0;
  t.x=(p1.x+2.0*p2.x)/3.0;
  t.y=(p1.y+2.0*p2.y)/3.0;

  u.x=(t.x-s.x)*cos(M_PI/3.0)-(t.y-s.y)*sin(M_PI/3.0)+s.x;
  u.y=(t.x-s.x)*sin(M_PI/3.0)+(t.y-s.y)*cos(M_PI/3.0)+s.y;

  calc_pos(n-1,p1,s);
  //print s
  Print(s);
  calc_pos(n-1,s,u);
  //print u
  Print(u);
  calc_pos(n-1,u,t);
  //print t
  Print(t);
  calc_pos(n-1,t,p2);
}

void Print(Pos p){
  printf("%f %f\n",p.x,p.y);
}



Measured memory_bytes: 2108
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e18
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    string s;
    cin >> s;
    if (s.substr(0, 7) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    else if (s.substr(s.size() - 7, 7) == "keyence") {
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 0; i <= 7; i++) {
        if (s.substr(0, i) + s.substr(s.size() - 7 + i, 7 - i) == "keyence") {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int N, T;
  cin >> N >> T;
  
  int ans = 1000000000;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) ans = min(ans, c);
  }
  if (ans == 1000000000) cout << "TLE" << endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
d,g=map(int,input().split())
l=[list(map(int,input().split())) for i in range(d)]

a=[]
for j in range(d):
  b=[]
  b.append((j+1)*100*l[j][0]+l[j][1])
  b.append(l[j][0])
  a.append(b)

c=[]
for k in range(2**d):
  c.append(format(k,'0'+str(d)+'b'))

e=[]
for m in range(len(c)):
  f=0;h=0;z=-1
  for n in range(d):
    if c[m][n]=='1':
      f+=a[n][0]
      h+=a[n][1]
    else:
      z=n+1
  e.append([f,h,z])

p=[]
for x in range(len(e)):
  if e[x][0]>=g:
    p.append(e[x][1])
  else:
    r=e[x][0];s=e[x][1]
    for y in range(a[e[x][2]-1][1]+1):
      r+=e[x][2]*100
      s+=1
      if r>=g:
        p.append(s)
        break

print(min(p))

Measured memory_bytes: 3188
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
#include <map>
#include <math.h>

using ll = long long;
using namespace std;

int main(){
    int a, b, c, sums;
    cin >> a >> b >> c;
    sums = a + b + c;

    int max_x = a;
    max_x = max(max_x, b);
    max_x = max(max_x, c);

    int m, mp;
    m = 3*max_x-sums;
    mp = 3*(max_x+1)-sums;

    if(m%2==0) out(m/2);

    else cout << (mp/2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main() {
	int n;
	cin>>n;
	int p,q,r;
	int a[n],b[n],c[n];
	int dp[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)
		{
			dp[i][j]=0;
		}
	}
	for(int i=0;i<n;i++)
	{
		cin>>p>>q>>r;
		a[i]=p;
		b[i]=q;
		c[i]=r;
	}
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(j==0)
			dp[i][j]=a[i]+max(dp[i-1][j+1],dp[i-1][j+2]);
			if(j==1)
			dp[i][j]=b[i]+max(dp[i-1][j-1],dp[i-1][j+1]);
			if(j==2)
			dp[i][j]=c[i]+max(dp[i-1][j-1],dp[i-1][j-2]);
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<stdio.h>
using namespace std;

signed main() {
  int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    	string s(a,'0');
    	string t(w-a,'1');
        string ans=s+t;
  		string S(a,'1');
  		string T(w-a,'0');
  		string Ans=S+T;
  for(int i=0;i<h;i++){
    if(i<b){
    	printf("%s\n",ans.c_str());
    }
    else{
    	printf("%s\n",Ans.c_str());
    }
  }
}

Measured memory_bytes: 1280
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

int main(void) {
	uint32_t a, b;

	scanf("%"PRIu32" %"PRIu32, &a, &b);

	printf("%"PRIu32, (b - a)*(b - a + 1)/2 - b);

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int i = 1;
    while(i<=n){
        int x = i;
        if(x%3==0){
            cout << " " << i;
        } else {
            while(x){
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
        ++i;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define MAX 111
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-15)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int n;
int a[MAX];

void solve(){
  int b[30]={};
  FOR(i,0,n){
    b[a[i]]++;
    priority_queue<pii> pq;
    FOR(j,0,26)pq.push(mp(b[j],j));
    pii t1=pq.top();pq.pop();
    pii t2=pq.top();pq.pop();
    if(t2.f+n-i-1<t1.f){
      cout<<char('A'+t1.s)<<" "<<i+1<<endl;
      return;
    }
  }
  cout<<"TIE"<<endl;
}

int main()
{
  while(cin>>n && n){
    FOR(i,0,n){
      char c;
      cin>>c;
      a[i]=c-'A';
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>

int main() {
    int n;
    std::cin >> n;
    int d[n];
    for(int i = 0; i < n; i++) {
        std::cin >> d[i];
    }

    int sum = 0;
    for(int i = 0; i < n - 1; i++) {
        for(int j = i + 1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }

    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	string A,B;
	bool flag=false;
	cin>>A>>B;
	if(A==B)flag=true;
	if(A.size()>B.size()||(A.size()==B.size()&&A>B&&!flag))cout<<"GREATER";
	else if(A.size()==B.size()&&flag)cout<<"EQUAL";
	else cout<<"LESS";
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{	ll H;
	cin >> H;
	ll ans = 0;
	while (H>1) {
		H /= 2;
		ans++;
	}
	ce((ll)pow(2,ans+1)-1)
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
   string s,w;
   cin >> s >> w;
   sort(s.begin(),s.end());
   sort(w.begin(),w.end());
   reverse(w.begin(),w.end());
   
   if(s<w){
     cout << "Yes" << endl;
   }
    else{
        cout << "No" << endl; 
    }
    return 0;
}


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

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main() {
    //
    int num;
    int kekka = 0;
    int cnt = 0;
    cin >> num;

    for (int i = 105; i <= num; i+= 2) {
        cnt = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) cnt++;
        }

        if (cnt >= 8) kekka++;
    }
    
    cout << kekka;
}

Measured memory_bytes: 3564
N=int(input())
K=int(input())
x=list(map(int,input().split()))
onewaysum=0
for i in range(N):
    if x[i]<=K-x[i]:
        onewaysum+=x[i]
    else:
        onewaysum+=K-x[i]
print(onewaysum*2) 

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

int main()
{
    string S;
    long long K;
    cin >> S >> K;
    for (int i = 0; i < min((long long)S.size(), K); i++)
    {
        if ('2' <= S[i])
        {
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cstdio>
#include <math.h>
#include <string>
#include <map>
#include <functional>
#include <algorithm>
#include <stack> 
#include <iomanip>
#include <stdio.h>
#include <set>
#include <array>
using namespace std; 

int main()
{
	int n, h, w;
	cin >> h >> w >> n;
	if (h > w) swap(h, w);
	cout << (n + w - 1) / w;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;




int main()
{
	map<int, int> data;

	int N;
	cin >> N;

	for (int i = 0; i < N; ++i)
	{

		int a;
		cin >> a;

		for (int j = -1; j <= 1; ++j)
		{
			int b = a + j;

			auto itr = data.find(b);

			if (itr != data.end())
			{
				data[b]++;
			}
			else
			{
				data[b] = 1;
			}

		}

	}

	int max = 0;
	int key = 0;

	for (auto itr = data.begin(); itr != data.end(); ++itr)
	{
		if (max < itr->second)
		{
			key = itr->first;
			max = itr->second;
		}
	}

	cout << data[key] << endl;

	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#define int long long
using namespace std;

signed main(){
	int n,a,ma = 0,ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a;
		if(a - ma >= 2){
			ans += (a - 1) / (ma + 1);
		}else ma = max(ma,a);
		if(!i) ma = 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void)
{
  string w;
  cin >> w;

  int a[27] = {0};
  for (int i = 0; i < w.length(); ++i)
  {
    a[w[i] - 'a']++;
  }

  bool even = true;

  for (int i = 0; i < 27; ++i)
  {
    if (a[i] % 2 != 0)
    {
      even = false;
    }
  }

  if (even)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 文入力 */
  char  *s;
  char  *t;
  s = (char *)malloc(sizeof(char) * 200001);
  t = (char *)malloc(sizeof(char) * 200001);
  scan = scanf("%s", s);
  scan = scanf("%s", t);
 
  /* プログラムを書く */
  int   n;
  int   result;
  
  n = 0;
  result = 0;
  while (s[n] != '\0')
  {
    if (s[n] != t[n])
    {
      s[n] = t[n];
      result++;
    }
    n++;
  }

  /* 数回答 */
  printf("%d", result);


  return (0);
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
 if (A + B == C + D){
   cout << "Balanced" << endl;
 }else if(A + B > C + D){
   cout << "Left" << endl;
 }else{
 cout << "Right" << endl;
 }
 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

int n, dp[10005];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = 1; (i + j) * (i + j) <= 2 * n; j++)
            for (int k = 1; (i + j) * (i + j) + (i + k) * (i + k) + (j + k) * (j + k) <= 2 * n; k++) {
                int t = (i + j) * (i + j) + (i + k) * (i + k) + (j + k) * (j + k);
                if (t % 2 == 0)
                    dp[t >> 1]++;
            }
    for (int i = 1; i <= n; i++)
        printf("%d\n", dp[i]);
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    ll i,o,t,j,l,s,z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    ll ans = 0;
    ans += o;
    if(i%2==1&&j%2==1&&l%2==1){
        ans+=3;
        i--; j--; l--;
        ans += (i/2)*2 + (j/2)*2 + (l/2)*2;
    }else if(i%2==0&&j%2==0&&l%2==0){
        ans += (i/2)*2 + (j/2)*2 + (l/2)*2;
    }else if((i+j+l)%2==1){
        ans += (i/2)*2 + (j/2)*2 + (l/2)*2;
    }else{
        if(i>0&&l>0&&j>0){
            ans += 3;
            i--; j--; l--;
            ans += (i/2)*2 + (j/2)*2 + (l/2)*2;
        }else{
            ans += (i/2)*2 + (j/2)*2 + (l/2)*2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int e = 5e5+6;
const int e1 = 5e5+2;


struct kien
{
    ll i, j, id, type;
};
kien a[e + e1];
ll n, q;
ll Bit[e];
ll res[e1];

bool lf(kien u, kien v)
{
    return (u.j < v.j || (u.j == v.j && u.type < v.type));
}

void bit(ll vitri, ll val)
{
    for(int i=vitri; i<=n; i += i & -i)
        Bit[i] += val;
}

ll getbit(ll vitri)
{
    ll ans = 0;
    for(int i=vitri; i>0; i -= i & -i)
    {
        ans += Bit[i];
    }
    return ans;
}

int main()
{
    cin >> n >> q;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i].i;
        a[i].j = i;
        a[i].type = -1;
    }
    map<ll,ll>last;
    for(int i=1; i<=q; i++)
    {
        cin >> a[i+n].i >> a[i+n].j;
        a[i+n].id = i;
    }
    sort(a+1, a+n+q+1, lf);
    for(int i=1; i<=q+n; i++)
    {
        if(a[i].type == -1)
        {
            bit(a[i].j, 1);
            if(last[a[i].i] > 0)
            {
                bit(last[a[i].i], -1);
            }
            last[a[i].i] = a[i].j;
        }
        else
        {
            res[a[i].id] = getbit(a[i].j) - getbit(a[i].i - 1);
        }
    }
    for(int i=1; i<=q; i++) cout << res[i] <<"\n";

}


Measured memory_bytes: 74088
n = int(input())
ans = 0
c = 0
for i in range(1,n+1):
    if i%2 == 0:
        c = 0
    else:
        for j in range(1,i+1):
            if i%j == 0:
                c += 1
    if c == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define FOR(i,x,n) for(int i=x;i<n;i++)
#define all(a) a.begin(),a.end()
ll mod=1e9+7;
using namespace std;
int main(){
    boost;
    int n;
    cin>>n;
    pi a(n);
    vi b(n);
    for(int i=0;i<n;i++)cin>>a[i].F,a[i].S=i;
    sort(all(a));
    for(int i=0;i<n;i++){
        if(a[n-1].S==i)cout<<a[n-2].F;
        else cout<<a[n-1].F;
        cout<<"\n";
    }
 
    return 0;
}

Measured memory_bytes: 3968
S=input()
unko=[0]*2019
tmp=0
num=1
for s in S[::-1]:
  s=int(s)
  tmp=(tmp+s*num)%2019
  num=(num*10)%2019
  unko[tmp]+=1
ans=0
ans+=(unko[0]+1)*unko[0]/2
for i in unko[1:]:
  ans+=i*(i-1)/2
print(int(ans))

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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define REP(i,n) FOR(i,0,n)

int A, B, K;

int main() {
  scanf("%d%d%d", &A, &B, &K);
  int AK = A + K - 1, BK = B - K + 1;

  if (AK >= BK) {
    FOR(i,A,B+1) printf("%d\n", i);
  }
  else {
    FOR(i,A,AK+1) printf("%d\n", i);
    FOR(i,BK,B+1) printf("%d\n", i);
  }

  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int a = 1;
  for (int i = 0; i < N; i++) {
    if (a * 2 < a + K) {
      a *= 2;
    }
    else {
      a += K;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
long long x[100010],y[100010],z[100010];
signed main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);

    long long  a,b,n,cnt=0,cc[100010]={};
    string s;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>x[i];
        if(x[i-1]==x[i]-1){
            cc[x[i-1]]=1;
        }
    }
    for(int i=1; i<=n; i++){
        cin>>y[i];
        cnt=cnt+y[i];
    }
    for(int i=1; i<n; i++){
        cin>>z[i];
        if(cc[i]==1){
            cnt=cnt+z[i];
        }
    }
    cout<<cnt<<'\n';
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  ll H, W; cin >> H >> W;

  if (H==1 || W==1) cout << 1 << endl;
  else if (H%2==1 && W%2==1) cout << (H*W+1)/2 << endl;
  else cout << (H*W)/2 << endl;

  return 0;
}


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

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

int main() {
  int n, k;
  cin >> n >> k;
  vector <char> v(k);
  rep(i, k) {
    cin >> v.at(i);
  }
  while (true) {
    string s = to_string(n);
    int tmp = 0;
    rep(i, s.size()) {
      rep(j, k) {
        if (s.at(i) == v.at(j)) {
          tmp++;
        }
      }
    }
    if (tmp == 0) {
      cout << n << endl;
      break;
    } else {
      n++;
    }
  }
}

Measured memory_bytes: 256
N,X,Y=map(int,input().split())
ans=[]
count=[0]*(N-1)
for i in range(1,N):
    for j in range(i+1,N+1):
        a=j-i
        a=min(a,abs(j-Y)+abs(i-X)+1)
        count[a-1]+=1
for i in range(0,N-1):
    print(count[i])

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int result = a - 1 ;
		if(b >= a) {
			result ++;
		}
		
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
function Main(i: string) {
  const ii = i.split("\n");
  const c = +ii[0];
  const nss = ii[1].split(" ");
  let v = 0;
  let even = true;

  while (even) {
    tryDivide();
    if (even) {
      v += 1;
    }
  }
  function tryDivide() {
    for (let i = 0; i < c; i++) {
      const n = +nss[i];
      if (n % 2 === 0) {
        nss[i] = (n / 2)+'';
      }
      else {
        even = false;
      }
    }
  }

	console.log(v);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7884
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import           Debug.Trace

split :: Int -> [Int] -> ([Int], [Int])
split p ws = go 0 [] ws
  where
    go _ !as [] = (reverse as, [])
    go !sumw !as (b:bs)
        | sumw + b > p = (reverse as, b : bs)
        | otherwise = go (sumw + b) (b : as) bs

allocate :: Int -> [Int] -> [[Int]]
allocate _ [] = []
allocate p ws
    | null r = [l]
    | otherwise = l : allocate p r
  where
    (l, r) = split p ws

solve :: Int   -- trucks
      -> [Int] -- weights
      -> Int   -- answer
solve k ws =
    let (l, r) = foldr (\w (a, b) -> (max w a, w + b)) (0, 0) ws
     in go l r
  where
    go :: Int -> Int -> Int
    go !l !r
        | l > r = l
        | t <= k = go l (m - 1)
        | otherwise = go (m + 1) r
      where
        m = (l + r) `div` 2
        t = length (allocate m ws)

main :: IO ()
main = do
    [n, k] <- fmap read . words <$> getLine :: IO [Int]
    ws <- fmap read . lines <$> getContents :: IO [Int]
    print $ solve k ws



Measured memory_bytes: 51004
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int cntnum(int y,int m,int d){
	int cnt=0;
	int n=(y-1)/3;
	cnt+=195*(2*n+(y-1)%3);
	cnt+=200*n;
	if(y%3!=0){
		int M=(m-1)/2;
		cnt+=(M+(m-1)%2)*20+M*19;
		cnt+=d;
	}
	else{
		cnt+=(m-1)*20;
		cnt+=d;
	}
	return cnt;
}
int main(){
	int n; cin >>n;
	for(int i=0;i<n;i++){
		int y,m,d; cin >>y>>m>>d;
		cout << 196471- cntnum(y,m,d) << endl;
		//cout << cntnum(696,4,19) << endl;
	}
}


Measured memory_bytes: 3072
s=input()
if len(s)%2==1:
    print("No")
else:
    swit=0
    for i in range(len(s)):
        if i%2==0:
            if s[i]!='h':
                swit=1
        else:
            if s[i]!="i":
                swit=1
    
    if swit==1:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, t, sum=0, count=0;
  cin >> a >> b >> t;
  
  for (int i = 1 ; i < 100; i++ ) {
      if (t < i*a) break;
      count += b;
  }
  
  cout << count << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	char c;
	cin>>c;
	
	cout<<(char)(c+1)<<endl;
	
    return 0;
}


Measured memory_bytes: 256
INPUT_NUM = 5
numbers = tuple(int(input()) for _ in range(INPUT_NUM))
dist_k = int(input())

can_direct_connect = True
for i in range(INPUT_NUM - 1):
    for j in range(INPUT_NUM - 1 - i):
        dist = numbers[j + i + 1] - numbers[i]
        if dist > dist_k:
            can_direct_connect = False
            break
    if not can_direct_connect:
        print(':(')
        break
else:
    print('Yay!')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

int main() {
  int n;
  cin>>n;
  int a[n];
  frn(i,n) cin>>a[i];
  int ans = 0;
  sort(a,a+n);
  fr(i,1,n) ans += a[i]-a[i-1];
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

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

  cout << b*(t/a) << endl;

}

Measured memory_bytes: 3644