akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <cctype>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	int h1 {in}, h2 {in}, k1 {in}, k2 {in}, a {in}, b {in}, c {in}, d {in};
	auto calc = [&](int i, int y) {
		return i * a + i / 10 * c + y * b + y / 20 * d;
	};
	int h = calc(h1, h2), k = calc(k1, k2);
	outl(h == k ? "even" : h > k ? "hiroshi" : "kenjiro");
}


Measured memory_bytes: 2536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(int argc, char *argv[]){

	int a, b;

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

	if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)
		printf("Possible\n");
	else
		printf("Impossible\n");

	return 0;
}


Measured memory_bytes: 128
# l,r,d =map(int, input().split()))
#i = list(map(int, input().split()))
s= input()
#s = [int(input()) for i in range(3)]

    #2次元配列n行d列
# n,d =map(int, input().split())
# x=[]
# for i in range(n):
#     x.append(list(map(int, input().split())))

    # print (xx[0][0])
    # print (xx[0][1])

n = len(s)
ss =('s')
ess =('es')


if s[n-1]=='s':
    print(s+ ess)
else :
    print(s + ss)


Measured memory_bytes: 9084
N = int(input())
A = [0, 0]+list(map(int, input().split()))+[0, 0]
skip = N-2*(N//2)+1
dp = [[-10**18]*(skip+1) for _ in range(N+4)]

for i in range(2):
    for j in range(skip+1):
        dp[i][j] = 0

for i in range(2, N+4):
    for j in range(skip+1):
        dp[i][j] = max(dp[i][j], dp[i-2][j]+A[i])
        
        if i>=3 and j+1<=skip:
            dp[i][j+1] = max(dp[i][j+1], dp[i-3][j]+A[i])
        
        if i>=4 and j+2<=skip:
            dp[i][j+2] = max(dp[i][j+2], dp[i-4][j]+A[i])

print(dp[N+3][skip])

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

int main() {
  vector<int> a, b, c;

  rep(i, 3) {
    int foo;
    cin >> foo;
    a.push_back(foo);
  }
  rep(i, 3) {
    int foo;
    cin >> foo;
    b.push_back(foo);
  }
  rep(i, 3) {
    int foo;
    cin >> foo;
    c.push_back(foo);
  }

  int n;
  cin >> n;
  vector<int> B;

  rep(i, n) {
    int foo;
    cin >> foo;
    B.push_back(foo);
  }

  vector<vector<int> > cand = {a,
                               b,
                               c,
                               {a[0], b[0], c[0]},
                               {a[1], b[1], c[1]},
                               {a[2], b[2], c[2]},
                               {a[0], b[1], c[2]},
                               {a[2], b[1], c[0]}};

  for (auto row : cand) {
    int count = 0;
    for (auto num : row) {
      if (find(B.begin(), B.end(), num) != B.end()) {
        count++;
      }
    }

    if (count == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

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

        int n = sc.nextInt();
        int d1 = 0;
        int d2 = 0;
        boolean[] boo = new boolean[n];
        boolean result = false;

        for(int i = 0; i < n; i++){
            d1 = sc.nextInt();
            d2 = sc.nextInt();

            if(d1 == d2){
                boo[i] = true;
            }
            else{
                boo[i] = false;
            }
        }

        for(int i = 0; i < n-2; i++){
            if(boo[i] && boo[i+1] && boo[i+2]){
                result = true;
            }
        }

        if(result == true){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }    
}

Measured memory_bytes: 36012
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 7;
const int mod = 1e9+7;
int a[12];
int n;
char s[N];
int main()
{
    cin>>s+1;
    int n=strlen(s+1);
    for(int i=1;i<=n-1;i++){
        if(s[i]==s[i+1]){
            cout<<i<<' '<<i+1<<endl;
            break;
        }
        else if(i<n-1){
            if(s[i]==s[i+2]){
                cout<<i<<' '<<i+2<<endl;
                break;
            }
        }
        if(i==n-1)cout<<"-1 -1"<<endl;
    }
}


Measured memory_bytes: 384
S = input ()
Z = ''.join(list(reversed(S)))
Z = Z.replace('resare', '')
Z = Z.replace('esare', '')
Z = Z.replace('remaerd', '')
Z = Z.replace('maerd', '')
z = len (Z)
if z == 0:
    print ('YES')
else:
    print ('NO')

Measured memory_bytes: 9664
/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define mp make_pair
#define sz size()
#define eps 1e-8

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN();

int main(){

    string a,b;
    cin >> a >> b;

    REP(i,b.sz)
        P("%c%c",a[i],b[i]);

    if(a.sz > b.sz) P("%c",a[a.sz-1]);

    P("\n");

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pt pair<ll , ll>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define double long double
int MAGIC = 400;
const int mod = 998244353;

const int MAX = 500005;
int x , y;
int f(int x)
{
	if(x == 1)
		return 300000;
	if(x == 2)
		return 200000;
	if(x == 3)
		return 100000;
	return 0;
}
int main()
{
	cin >> x >> y;
	cout << (x == 1 && y == 1) * 400000 + f(x) + f(y);
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int a, b;
    cin >> a >> b;
    cout << (b % a == 0 ? a + b : b - a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int N;
  long long a[100010];
  int i;
  long long s=1;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%lld",&a[i]);
  }
  int zero=0;
  for(i=0;i<N;i++){
    if(a[i]==0){
      zero=zero+1;
    }
    if(zero>0){
      printf("0\n");
      return 0;
    }
  }
  for(i=0;i<N;i++){
    if(a[i]<=1000000000000000000/s){
      s=s*a[i];
    }
    else{
      printf("-1\n");
      return 0;
    }
  }
  printf("%lld",s);
  return 0;
}


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

#define ll long long

using namespace std;

inline int read() {
  int s = 0, t = 1; char ch = getchar();
  while (ch < '0' || ch > '9') {if (ch == '-') t = -1; ch = getchar();}
  while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
  return s * t;
}



int main() {
	int a, b, c, ans = 0;
	a = read(), b = read(), c = read();
	ans = max(ans, a * 10 + b + c);
	ans = max(ans, a + b * 10 + c);
	ans = max(ans, a + b + c * 10);
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 5000500
  using namespace std;
string S,T,U="";
int nxt[MAXN],match[MAXN];
void pre_next()
{
  int j=-1;
  nxt[0]=-1;
  for(int i=0;i<T.size();i++)
  {
   while(j!=-1&&T[i]!=T[j]) j=nxt[j];
   nxt[i+1]=++j;
  }
}
void KMP()
{
  int j=0;
  for(int i=0;i<U.size();i++)
  {
    while(j!=-1&&U[i]!=T[j]) j=nxt[j];
    j++;
    if(j==T.size()) match[(i+1-T.size())%(S.size())]=1;
  }
}
vector<int>v[MAXN];
queue<int>q;
int in[MAXN],vis=0,f[MAXN];
#define pb(x) push_back(x)
void wor()
{
  for(int i=0;i<S.size();i++) 
   if(match[i])
   {
    int ed=(i+T.size())%S.size();
    v[i].pb(ed);
    in[ed]++;
   }
  for(int i=0;i<S.size();i++) if(!in[i]) q.push(i);
  while(q.size())
  {
    vis++;
    int pos=q.front(); q.pop();
    for(int i=0;i<v[pos].size();i++)
    {
     int to_=v[pos][i]; 
     f[to_]=max(f[to_],f[pos]+1);
     if(--in[to_]==0) q.push(to_);
    }
  }
  if(vis!=S.size()) printf("-1\n");
   else 
   {
    int ans=0;
    for(int i=0;i<S.size();i++)
     ans=max(ans,f[i]);
    printf("%d\n",ans);
   }
   return;
}
int main()
{
  cin>>S>>T;
  while(U.size()<max(S.size(),T.size())*2) U+=S;
  
  pre_next();
  KMP();

  wor(); 
  return 0;
}

Measured memory_bytes: 147400
import sys
n=int(input())
a = list(map(int,input().split())) 
flg=True
for i ,item in enumerate(a):
    if not(item&1): 
        if(item%3==0 or item % 5==0):
            continue
        else:
            flg=False
        
if flg:
    print("APPROVED")
else:
    print("DENIED")

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll N, D, A;
  cin >> N >> D >> A;
  vector<pll> xh(N);
  rep(i, N) cin >> xh[i].F >> xh[i].S;

  sort(all(xh));

  ll ans = 0;

  ll b = 0;
  queue<pll> minus;

  rep(i, N) {
    int x = xh[i].F;
    int h = xh[i].S;

    while (!minus.empty()) {
      if (x >= minus.front().S) {
        b -= minus.front().F;
        minus.pop();
      } else {
        break;
      }
    }

    if (h <= b) {
      //
    } else {
      ll cnt = (h - b) / A + ((h - b) % A ? 1 : 0);
      ans += cnt;
      b += A * cnt;
      minus.push(mp(A * cnt, x + 2 * D + 1));
    }
  }

  cout << ans << endl;
}


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

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var list = text.Split(' ').ToList().Select(d => int.Parse(d)).ToList();

            var n = list[0];
            var x = list[1];

            text = Console.ReadLine();
            list = text.Split(' ').ToList().Select(d => int.Parse(d)).ToList();

            var pos = 0;
            for(int i = 0; i < n; i++)
            {
                pos = pos + list[i];
                if (pos == x){
                    Console.WriteLine((i + 2).ToString());
                    return;
                }
                else if (pos > x){
                    Console.WriteLine((i + 1).ToString());
                    return;
                }
            }

            Console.WriteLine((n + 1).ToString());
        }
    }
}


Measured memory_bytes: 13396
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

K = input_one_number()
S = input()

if len(S) <= K:
	print(S)
else:
	print(S[:K]+"...")

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <complex>

using namespace std;

typedef complex<double> Point;

const double EPS = 1e-8;

int n;
Point data[300];

int calc(Point& a, Point& b){
  int res = 0;
  double d = abs(b - a) / 2.0;
  Point ab = (b - a) / (2.0 * d);
  if(d < 1){
    Point o = ab * d;
    d = sqrt(1.0 - d * d);
    o += Point(d * ab.imag() + a.real(), -d * ab.real() + a.imag());
    for(int i=0;i<n;i++) if(abs(o - data[i]) < 1.0 + EPS) res++;
  }
  return res;
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++) cin >> data[i].imag() >> data[i].real();
    int ans = 1;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        ans = max(ans, calc(data[i], data[j]));
        ans = max(ans, calc(data[j], data[i]));
      }
    }
    cout << ans << endl;
  }
}

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

int main()
{
    long long int n,i,j,k;
    cin>>n;

    long long int a[n][3];

    for(i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];

    long long int dp[3][n];

    for(i=0;i<n;i++)
        dp[0][i]=dp[1][i]=dp[2][i]=0;

    dp[0][0]=a[0][0];
    dp[1][0]=a[0][1];
    dp[2][0]=a[0][2];

    for(i=1;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            for(k=0;k<3;k++)
            {
                if(j!=k)
                {
                    dp[j][i]=max(dp[j][i],dp[k][i-1]+a[i][j]);
                }
            }
        }
    }

    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}


Measured memory_bytes: 4992
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for i in range(N):
  count+=min(A[i],B[i])
  if B[i]>A[i]:
    res=(B[i]-A[i])
    if A[i+1]>res:
      A[i+1]-=res
      count+=res
    else:
      count+=A[i+1]
      A[i+1]=0
print(count)

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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	int n,k; cin >> n >> k;
	double p=0;
	for(int i = 1; i <= n; i++){
		int j = 0;
		for(int m = i; m < k; m*= 2) j++;
//		cerr << j << " ";
		p += (1.0/(double)n) * pow(0.5, j);
//		cerr << p << endl;
	}
//	cerr << endl;
	printf("%.12f\n", p);

	return 0;
}



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

int main()
{
  	int i;
	int n, x=0;
  	cin >> n;
  	int l[n], r[n];
  	for (i=0; i<n; i++) {
      cin >> l[n] >> r[n];
      x += r[n] - l[n] + 1;
    }
  	cout << x << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int INF = 1e9 + 1;

int main() {
    int N;
    cin >> N;
    vector<double> t(N), v(N);
    rep(i, N) cin >> t[i];
    rep(i, N) cin >> v[i];

    // 全体のT秒を求める
    int T = 0;
    rep(i, N) T += t[i];

    vector<double> maxV(2 * T + 1, (double) INF);

    // maxのスピードをv[i]で初期化
    int nowT = 0;
    rep(i, N) {
        rep(ti, t[i]) {
            int t1 = nowT + ti * 2;
            int t2 = nowT + ti * 2 + 1;
            chmin(maxV[t1], v[i]);
            chmin(maxV[t2], v[i]);
        }
        nowT += t[i] * 2;
        chmin(maxV[nowT], v[i]);
    }

    // 0秒とT秒は0(静止)
    maxV[0] = maxV[T * 2] = 0.0;

    // 前から比較
    rep(ti, 2 * T) maxV[ti + 1] = min(maxV[ti + 1], maxV[ti] + 0.5);

    // 後ろから比較
    for (int ti = 2 * T - 1; ti >= 0; ti--) maxV[ti] = min(maxV[ti], maxV[ti + 1] + 0.5);

    double ans = 0.0;
    // 区間ごとの台形の面積を足す
    rep(i, 2 * T) ans += (maxV[i] + maxV[i + 1]) * 0.5 / 2.0; // (上底 + 下底) * 高さ / 2

    printf("%.4f\n", ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;

struct point{
	Int j, i,step;
	point(Int i_, Int j_,Int s) :i(i_), j(j_),step(s){}
};

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

queue<point> que;
char tile[1001][1001];
int H, W;
bool ed[1001][1001];

point solve(char target)
{
	while (!que.empty()){
		point now(que.front());
		//ed[now.i][now.j] = true;
		que.pop();
		REP(i, 4){
			int x = now.j + dx[i];
			int y = now.i + dy[i];

			if (x < 0 || y < 0 || x > W || y > H || ed[y][x])
				continue;

			if (tile[y][x] == target){
				return point(y, x,now.step+1);
			}

			if (tile[y][x] != 'X'){
				que.push(point(y, x, now.step + 1));
				ed[y][x] = true;
			}
		}
	}
}

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	////////////ここから開始///////////
	int n(0);
	cin >> H >> W >> n;

	REP(i, 1001)REP(j, 1001){ tile[i][j] = 'X'; ed[i][j] = false; }

	REP(i, H)REP(j, W)cin >> tile[i][j];

	REP(i, H)REP(j, W){ if (tile[i][j] == 'S')que.emplace(i, j, 0); }

	for (int i = 0; i < n; ++i){
		REP(i_1, H + 1)REP(j_1, W + 1){ ed[i_1][j_1] = false; }
		point t = solve('1' + i);
		que = {};
		que.emplace(t);
	}

	cout << que.front().step << endl;

	return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5, MOD = 1e9+7;
int dp[N][N];
bool isEmpty[N][N];
int add(int x, int y){
	int res = x + y;
	if(res >= MOD)
		res -= MOD;
	return res;
}
int main(){
	int h, w;
	cin >> h >> w;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			char c;
			cin >> c;
			isEmpty[i][j] = (c == '.');
		}
	}
	dp[h-1][w-1] = 1;
	for(int i = h-1; i >= 0; --i){
		for(int j = w-1; j >= 0; --j){
			if(isEmpty[i][j]){
				dp[i][j] = add(dp[i][j], dp[i+1][j]);
				dp[i][j] = add(dp[i][j], dp[i][j+1]);
			}
		}
	}
	cout << dp[0][0];
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
 
 int a,b,x;
 cin >> a >> b;
  
 x = ( a + b ) / 2; 
 if((a + b) % 2 == 0){
   
   cout << x << endl;
 
 }
 if((a + b) % 2 == 1){
   
   cout << x + 1 << endl;
 }
 
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,color[20],ans;
set<string> s;
void backtrack(int i,int cur)
{
    if(i>n)
    {
        for(int j=1;j<=n;j++)
        {
            char c=color[j]+'a'-1;
            cout<<c;
        }
        cout<<'\n';
    }
    else
    {
        for(int j=1;j<=cur;j++)
        {
            color[i]=j;
            backtrack(i+1,max(cur,j+1));
        }
    }
}
void solve()
{
    cin>>n;
    backtrack(1,1);
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("STRWC.inp","r",stdin);
    //freopen("FORMMAU.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

struct Trie {
    int cnt[26] = {};
    Trie* child[26] = {};
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> all(n);
    for (auto& s : all)
        cin >> s;
    sort(all.begin(), all.end(), [](const auto& a, const auto& b){
        return a.size() > b.size();
    });
    Trie* root = new Trie;
    ll ans = 0;
    for (const auto& s : all) {
        Trie* ptr = root;
        bool ok = true;
        for (int i = (int)s.size() - 1; i > 0; i--) {
            if (!ptr->child[s[i] - 'a']) {
                ok = false;
                break;
            }
            ptr = ptr->child[s[i] - 'a'];
        }
        if (ok && ptr->cnt[s.front() - 'a']) {
            ans += ptr->cnt[s.front() - 'a'];
        }
        int count[26] = {};
        for (char x : s)
            count[x - 'a']++;
        ptr = root;
        for (int i = (int)s.size() - 1; i >= 0; i--) {
            if (!ptr->child[s[i] - 'a'])
                ptr->child[s[i] - 'a'] = new Trie;
            for (int j = 0; j < 26; j++)
                if (count[j])
                    ptr->cnt[j]++;
            ptr = ptr->child[s[i] - 'a'];
            count[s[i] - 'a']--;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 316620
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 200020
#define INF 200020
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    ll max_h = 0;
    ll s_h = 0;
    vector<ll> a(n,0);
    vector<ll> s(n,0);
    for(int i =0; i < n;i++){
        cin>>a[i];
        s[i] = a[i];
        if(a[i] > max_h){
            max_h = a[i];
        }else if(a[i] > s_h){
            s_h = a[i];
        }
    }
    for(int i =0; i<n; i++){
        ll ans;
        ll t = a[i];
        if(t == max_h){
            ans = s_h;
        }else{
            ans = max_h;
        }
        cout<< ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    map<ll, ll> m;
    vector<ll> sum(n+1, 0);
    for(int i = 0; i < n; i++)
    {
        sum[i+1] = sum[i] + a[i];
    }
    for(int i = 0; i <= min(n, k-1); i++)
    {
        ll cand = (sum[i]-i) % k;
        cand = (cand + k) % k;
        m[cand]++;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        ll cand = (sum[i]-i) % k;
        cand = (cand + k) % k;
        m[cand]--;
        ans += m[cand];
        if(k+i <= n)
        {
            ll add = (sum[k+i]-(k+i)) % k;
            add = (add + k) % k;
            m[add]++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 15104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main() {
	struct Item {
		int v, w;
	};
	Item it[101];
	int n, W;
	cin >> n >> W;
	for (int i = 1; i <= n; i++) {
		cin >> it[i].v >> it[i].w;
	}
	int mv;
	vector<int> comp;
	int v[101][10001];
    int c[101][10001];
	for (int i = 0; i <= n; i++) {
		c[i][0] = 0;
		v[i][0] = 0;
	}
	for (int i = 0; i <= W; i++) {
		c[0][i] = 0;
		v[0][i] = 0;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= W; j++) {
			c[i][j] = c[i - 1][j];
			v[i][j] = 0;
			if (it[i].w > j) continue;
			if (it[i].v + c[i - 1][j - it[i].w] > c[i - 1][j]) {
				c[i][j] = it[i].v + c[i - 1][j - it[i].w];
				v[i][j] = 1;
			}
		}
	}
	mv = c[n][W];
	for (int j = W, i = n; i >= 1; i--) {
		if (v[i][j]) {
			//cout << "i" << i << endl;
			comp.push_back(i);
			j -= it[i].w;
		}
	}
	cout << mv << endl;
	return 0;
}

Measured memory_bytes: 11060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n,d,x;
  cin >> n >> d >> x;
  vector<int> a=input(n);
  
  rep(i,n){
    x += 1+(d-1)/a[i];
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n;
  string s,ss,sss;
  cin>>a>>b>>n;
  ll minus=min(n,a);
  a-=minus;
  n-=minus;
  cout<<a<<" "<<max(0LL,b-n)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    long long int h, w, mn=100000000;
    cin >>h >> w;
    if(h%3==0 || w%3==0){
        mn = 0;
    }
    else{
        mn = min(mn, h);
        mn = min(mn, w);
        for(int i=1;i<w;i++){
            mn = min(mn, max(abs(i*h - (w-i)*(h/2)), max((w-i)*(h-(h/2))-i*h, (w-i)*(h-(h/2)) - (w-i)*(h/2))));
        }
        for(int i=1;i<h;i++){
            mn = min(mn, max(abs(i*w - (h-i)*(w/2)), max((h-i)*(w-(w/2))-i*w, (h-i)*(w-(w/2)) - (h-i)*(w/2))));
        }
    }
    cout << mn << endl;
}

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

const ll INF = 1001001001;

int main(){
  int n; cin>>n;
  vector<int>p(n);
  rep(i,n){
    cin>>p[i];
  }
  int ans =0;
  vector<int>dp(n);
  ans++;
  dp[0]=p[0];
  for(int i=1;i<n;i++){
    dp[i]=min(dp[i-1],p[i]);
    if(dp[i]==p[i]){
      ans++;
    }
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    string S;
    cin >> S;
    if (S.at(0) != 'A') {
        cout << "WA" << endl;
        exit(0);
    }
    int cnt = 0;
    for (int i = 1; i < S.size(); ++i) {
        if (2 <= i && i <= S.size() - 2 && S.at(i) == 'C') {
            cnt++;
        } else {
            if (S.at(i) < 'a' || 'z' < S.at(i)) {
                cout << "WA" << endl;
                exit(0);
            }
        }
    }
    cout << ((cnt == 1) ? "AC" : "WA") << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n;
  cin >> n;
  vector<ll> h(n, 0);
  for (ll i = 0; i < n; ++i) {
    cin >> h[i];
  }

  ll low = 0;
  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    if (h[i] >= low) {
      ans++;
      low = h[i];
    }
  }

  cout << ans << endl;

  return 0;
}

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

int comp( const void *a, const void *b ) {
    return( *((int *)b) - *((int *)a) );
}

int main( int argc, char *argv[] )
{
    int a,b,c,d;

    scanf( "%d %d %d %d", &a, &b, &c, &d );

    while( 1 ) {

        c -= b;
        if( c<=0 ) break;

        a -= d;
        if( a<=0 ) break;
    }

    if( c<=0 ) puts( "Yes" );
    else       puts( "No" );
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
bool comp(pair<long long int,long long int> A,pair<long long int,long long int> B)
{
    return A.first<B.first;
}
int dfs(int i,vector<int> &vis,vector<int> &dis,vector<int> adj[])
{
    for(auto it=adj[i].begin();it!=adj[i].end();it++)
    {
        if(!vis[*it])
        {
            vis[*it]=1;
            dis[i]=max(dis[i],1+dfs(*it,vis,dis,adj));
        }
        else
        {
            dis[i]=max(dis[i],1+dis[*it]);
        }
    }
    return dis[i];
}
int main() 
{
    long long int v,e;
    cin>>v>>e;
    vector<vector<char>> A(v,vector<char>(e));
    for(long long int i=0;i<v;i++)
    {
        for(long long int j=0;j<e;j++)
        {
            cin>>A[i][j];
        }
    }
    vector<vector<long long int>> dp(v,vector<long long int>(e,0));
    for(long long int i=0;i<dp.size();i++)
    {
        for(long long int j=0;j<dp[0].size();j++)
        {
            if(A[i][j]=='#')
            {
                continue;
            }
            if(i==0 && j==0)
            {
                dp[i][j]=1;
            }
            else if(i==0)
            {
                dp[i][j]=dp[i][j-1]%mod;
            }
            else if(j==0)
            {
                dp[i][j]=dp[i-1][j]%mod;
            }
            else
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[v-1][e-1];

}

Measured memory_bytes: 9088
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if (c > b || a > d) {
            System.out.println(0);
            return;
        }
        int start;
        int end;
        if (a > c) {
            start = a;
        } else {
            start = c;
        }
        if (b > d) {
            end = d;
        } else {
            end = b;
        }
        System.out.println(end - start);
    }

}


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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    c -= min(c, a - b);
    cout << c;
    
    return 0;
}

Measured memory_bytes: 764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int A, B; cin>>A>>B;
  int ans;
  if(A>=13){
    ans=B;
  }
  else if(A>=6){
    ans=B/2;
  }
  else{
    ans=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

n = int(input())

arr = []
s_arr = []

for i in range(n):
    a = int(input())
    arr.append(a)

s_arr=sorted(arr, reverse=True)

for a in arr:
    if a >= s_arr[0]:
        print(s_arr[1])
    else:
        print(s_arr[0])


Measured memory_bytes: 14112
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect

s=input()
n=len(s)
if s[0]==s[-1]:
    x=s[0]
    for i in range(2,len(s)-1,2):
        if s[i]!=x:
            if (n-3)%2==0:
                print("Second")
            else:
                print("First")
            break
    else:
        print("Second")
else:
    x=s[-1]
    y=s[0]
    for i in range(1,len(s),2):
        if s[i]!=x:
            if (n-2)%2==0:
                print("Second")
            else:
                print("First")
            break
    else:
        for i in range(2,len(s),2):
            if s[i]!=y:
                if (n-2)%2==0:
                    print("Second")
                else:
                    print("First")
                break
        else:
            print("Second")

Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int a[101];
int main()
{
 	int i,n,sum=0,w=0;
 	cin>>n;
 	for(i=1;i<=n;i++)
 	{
 		cin>>a[i];
	 }
	 sort(a+1,a+n+1);
	 for(i=1;i<=n;i++)
	 {
		sum+=a[i];  
    }
    if(sum%10!=0) 
    {
    	cout<<sum;
    	return 0;
	}
 	for(i=1;i<=n;i++)
 	{
 		if(a[i]%10!=0)
 		{
 			cout<<sum-a[i];
 			return 0;
		 }
	 }
	 cout<<0;
	 return 0;
}

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

int main()
{
	string s;
	cin >> s;
	bool ok = true;
	int cPlace = -1;
	if (s[0] != 'A')
	{
		ok = false;
	}
	for (int i = 1; i < s.length(); i++)
	{
		if (s[i] == 'C')
		{
			if (i < 2 || i == s.length() - 1)
			{
				ok = false;
				break;
			}
			if (cPlace == -1)
			{
				cPlace = i;
			}
			else
			{
				ok = false;
				break;
			}
		}
		else if ('A' <= s[i] && s[i] <='Z')
		{
			ok = false;
			break;
		}
	}
	if (cPlace == -1)
	{
		ok = false;
	}

	if (ok)
	{
		cout << "AC" << endl;
	}
	else
	{
		cout << "WA" << endl;
	}
	return 0;
}

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

using namespace std;


int main() {
	int n,index;
	cin >> n;
	int* a = new int[n];
	pair<int,int>* hyo = new pair<int,int>[n];
	int* rep = new int[n] ;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		hyo[i].first = i + 1 + a[i];
		hyo[i].second = i;
	}
	sort(hyo, hyo + n);
	rep[0] = 0;
	for (int i = 1;i < n;i++) {
		index = lower_bound(hyo, hyo + n, make_pair(i + 1 + a[i], i)) - hyo;
		if (index == 0) {
			rep[i] = 0;
		}
		else {
			if (hyo[index - 1].first == i + 1 + a[i]) {
				rep[i] = rep[hyo[index - 1].second] + 1;
			}
			else {
				rep[i] = 0;
			}
		}
	}
	long long cnt = 0;
	for (int i = 1;i < n;i++) {
		index = lower_bound(hyo, hyo + n, make_pair(i + 1 - a[i],i)) - hyo;
		if (index == 0) {
			
		}
		else {
			if (hyo[index - 1].first == i + 1 - a[i]) {
				cnt += (long long)rep[hyo[index - 1].second] + 1;
			}
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 6292
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

vvll to;
ll dfs(ll u){
  ll ret = 0;
  if(to[u].size() == 0) return 0;

  vll lst;
  for(ll v : to[u]){
    ll vval = dfs(v);
    lst.push_back(vval);
  }
  Sort(lst);
  rep(i, (ll)lst.size()){
    chmax(ret, lst[i] + (ll)lst.size()-i);
  }
  return ret;
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  to.resize(n);
  rep(i, n-1){
    ll a;
    cin >> a;
    a--;
    to[a].push_back(i+1);
  }

  ll ans = dfs(0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 16360
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}	
int a[32]={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};
signed main(){
	ic(n) ic(k) 
	if(n==1||k==1)c(1)
	else c((n*k+1)/2)
}
		




Measured memory_bytes: 256
x = input().split()

for i in range(len(x)):
    x[i] =int(x[i])

a,b,c=x
while a> b or b > c or a > c:
    if a > b:
        a,b = b,a
    if b > c:
        b,c = c,b
    if a>c:
        a,c=c,a
print(a,b,c)



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

int main() {
  int total;
  int num;
  int cnt = 0;
  int minCnt = 9999;
  cin >> total;
  
  for(int i = 0; i < total; i++){
    cin >> num;
    cnt = 0;
    // 2で割れる回数
    while(num % 2 == 0){
      cnt++;
      num /= 2;
    }
    
    // 最大回数超えていれば更新
    if(minCnt > cnt) minCnt = cnt;
  }
  
  cout << minCnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>

typedef long long ll;

using namespace std;

void solve(){
    int n;
    int room[4][3][10];
    cin >> n;
    int b[n], f[n], r[n], v[n];
    memset(room, 0, 4*3*10*4);
    for(int i = 0; i < n; i++){
        cin >> b[i] >> f[i] >> r[i] >> v[i];
        room[b[i]-1][f[i]-1][r[i]-1] += v[i];
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << room[i][j][k];
            }
            cout << endl;
        }
        if(i != 3){
            cout << "####################" << endl;
        }
    }
}

int main() {
    solve();
    return 0;
}

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

template<uint64_t m = 1000000007>
class ModInt {
public:
    ModInt(const uint64_t x): x(x) { }

    ModInt operator + (const ModInt y) const {
        return (x + y.x) % m;
    }

    ModInt operator * (const ModInt y) const {
        return (x * y.x) % m;
    }

    ModInt operator / (const ModInt y) const {
        auto i = y;
        i.inverse();
        return *this * i;
    }

    void operator += (const ModInt y) {
        *this = *this + y;
    }

    void operator *= (const ModInt y) {
        *this = *this * y;
    }

    void operator /= (const ModInt y) {
        *this = *this / y;
    }

    bool operator == (const uint64_t n) const {
        return x == n;
    }

    uint64_t data() const {
        return x;
    }

    void pow(uint64_t n) {
        ModInt y = 1;
        ModInt factor = x;

        while(n) {
            if(n & 1) {
                y *= factor;
            }
            factor *= factor;
            n >>= 1;
        }

        x = y.data();
    }

    void inverse() {
        const auto n = extended_gcd(x, m).first;
        x = mod_unsigned(n);
    }

private:
    uint64_t x;

    static std::pair<int64_t, int64_t> extended_gcd(const uint64_t a, const uint64_t b) {
        if(a == 0) {
            return std::make_pair(0, 1);
        }

        const auto p = extended_gcd(b % a, a);

        const auto s = p.first;
        const auto t = p.second;
        const int64_t q = b / a;

        return std::make_pair(t - s * q, s);
    }

    uint64_t mod_unsigned(const int64_t n) {
        if(n >= 0) {
            return n;
        }

        const auto y = (-n) / m + 1;
        return n + m * y;
    }
};

template<class T>
std::vector<T> read_vector(const uint64_t n) {
    auto v = std::vector<T>();
    v.reserve(n);

    for(uint64_t i = 0; i < n; ++i) {
        T t;
        std::cin >> t;
        v.push_back(t);
    }

    return v;
}

std::unordered_map<uint64_t, uint64_t> factor(uint64_t n) {
    auto result = std::unordered_map<uint64_t, uint64_t>();

    for(uint64_t p = 2; p * p <= n; ++p) {
        while(n % p == 0) {
            ++result[p];
            n /= p;
        }
    }

    if(n > 1) {
        result[n] = 1;
    }

    return result;
}

ModInt<> factor_to_int(const std::unordered_map<uint64_t, uint64_t> f) {
    ModInt<> result = 1;

    for(const auto kv: f) {
        ModInt<> p = kv.first;
        p.pow(kv.second);

        result *= p;
    }

    return result;
}

int main() {
    int n;
    std::cin >> n;

    const auto as = read_vector<uint64_t>(n);

    auto lcm = std::unordered_map<uint64_t, uint64_t>();

    for(const auto a: as) {
        const auto f = factor(a);

        for(const auto e: f) {
            const auto p = e.first;

            lcm[p] = std::max(lcm[p], e.second);
        }
    }

    const ModInt<> int_lcm = factor_to_int(lcm);

    ModInt<> answer = 0;

    for(const auto a: as) {
        answer += int_lcm / a;
    }

    std::cout << answer.data() << std::endl;

    return 0;
}


Measured memory_bytes: 1152
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<vector>
using namespace std;

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

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	int n; cin >> n;
	long long a[n];
	REP(i, n) cin >> a[i];

	long long x = a[0];
	long long y = 0;
	FOR(i, 1, n) y += a[i];
	long long ans = abs(x - y);

	FOR(i, 1, n - 1){
		x += a[i];
		y -= a[i];
		ans = min(ans, abs(x-y));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
bool used[90][90];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int m,n;
int max(int a,int b){return a>b?a:b;}
int dfs(int y,int x){
	used[y][x]=true;
	int ma=0;
	int i;
	for(i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=0&&nx<m&&ny>=0&&ny<n&&!used[ny][nx])ma=max(ma,dfs(ny,nx));
	}
	used[y][x]=false;
	return ma+1;
}
int main(){
	while(1){
	scanf("%d",&m);
	if(m==0)return 0;
	scanf("%d",&n);
	int i,j;
	for(i=0;i<n;i++)for(j=0;j<m;j++)used[i][j]=false;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			int x;
			scanf("%d",&x);
			if(x==0)used[i][j]=true;
		}
	}
	int ans=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(!used[i][j])ans=max(ans,dfs(i,j));
		}
	}
	printf("%d\n",ans);
	}
}
	

Measured memory_bytes: 1036
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;
 
int main() {
    string S;
    cin >> S;
    int ans = 1000000000;
    rep(i, S.size() - 2) {
        string str = "";
        rep(j, 3) str += S[i + j];
        int x = stoi(str);
        ans = min(abs(753 - x), ans);
    }
    cout << ans << endl;
    return 0;
}

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

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

const long long INF = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<char> state(N);

    for (int i = 0; i < N; i++) {
        cin >> state.at(i);
    }

    vector<int> west(N + 1);

    west.at(0) = 0;
    for (int i = 0; i < N; i++) {
        if (state.at(i) == 'W') {
            west.at(i + 1) = west.at(i) + 1;
        } else {
            west.at(i + 1) = west.at(i);
        }
    }

    long long min = INF;
    // i番目の人間がリーダーの場合
    for (int i = 1; i <= N; i++) {
        int change_num = west.at(i - 1) + (N - i) - (west.at(N) - west.at(i));
        if (change_num < min) {
            min = change_num;
        }
    }

    cout << min << endl;
}


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

int main() {
	int n;
	cin>>n;
	int a[n], b[n];
	for(int i = 0; i < n; i++){
	    cin>>a[i]>>b[i];
	}
	int c, f = 0;
	for(int i = 0; i <= n - 3; i++){
	    c = 0;
	    for(int j = 0; j < 3; j++){
	       if(a[i + j] == b[i + j])
	       c++;
	    }
	    if(c == 3){
	        cout<<"Yes";
	        f = 1;
	        break;
	    }
	}
    if(f == 0)
    cout<<"No";
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
const ll mod=1000000009;
const ll INF=(ll)1000000007*1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
map<string,int> mp;
int main(){
  int N; cin >> N; bool f=true;
  string x;
  rep(i,N){
    string s; cin >> s;
    if(mp[s]) f=false;
    mp[s]=1;
    if(i>0){
      if(s[0]!=x[x.length()-1]) f=false;
    }
    x=s;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int cnt = 0;
    for (int i = a; i <= b; ++i) {
        int tmp = i;
        int rev = 0;
        int rem;
        while (tmp != 0) {
            rem = tmp % 10;
            rev = rev * 10 + rem;
            tmp /= 10;
        }
        if (rev == i) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256