akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

ll n,m,a[55];

ll dfs(ll x,ll y){//xはレベル，yは何層目か
    if(y<=x){//
        return 0;
    }else if(x==0){//レベル０はもちろん1枚しかないので
        return 1;
    }else{
        if(y-1<=a[x-1]){//層が左のx-1バーガーの範囲に収まった場合
            return dfs(x-1,y-1);
        }else if(y-1==a[x-1]+1){//層がちょうどxバーガーの真ん中の場合
            return dfs(x-1,a[x-1])+1;
        }else if(y!=a[x]){//層がxバーガー内部に収まった場合
            return dfs(x-1,a[x-1])+1+dfs(x-1,y-a[x-1]-2);
        }else{
            return dfs(x-1,a[x-1])*2+1;
        }
    }
}

int main(){
    cin>>n>>m;
    a[0]=1;
    for(int i=1;i<=n;i++){
        a[i]=a[i-1]*2+3;
    }
    cout<<dfs(n,m)<<endl;
    return 0;
}
    

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
K = int(input())
array = [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]
print(array[K-1])

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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	long long a;
	multiset<long long> memo={};
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		a*=-1LL;
		memo.insert(a);
	}
	pair<long long,int> bc[m];
	for (int i = 0; i < m; ++i)
	{
		cin>>bc[i].second>>bc[i].first;
		bc[i].first*=-1;
	}
	sort(bc,bc+m);
	int cnt=0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < bc[i].second; ++j)
		{
			memo.insert(bc[i].first);
		}
		cnt+=bc[i].second;
		if (cnt>=n)
		{
			break;
		}
	}
	cnt=0;
	long long ans=0LL;
	for (auto i = memo.begin(); i != memo.end(); ++i)
	{
		ans+=(*i)*-1LL;
		++cnt;
		if (cnt==n)
		{
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,x,sum;
    cin>>a>>b>>x;
    if(a%x==0) sum=a/x;
    else sum=a/x+1;
    c=b/x;
    cout<<c-sum+1<<endl;
    return 0;
}

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

using namespace std;

#define INF 999999999

struct yoko{
	int h, p, q;
	
	bool operator<(const yoko& a) const{
		return h > a.h;
	}
};

int main(){
	int ans, i, j, k, n, m, a;
	vector<yoko> mat(1000);
	while(1){
		cin >> n >> m >> a;
		if(!n) break;
		mat.clear();
		ans = a;
		for(i=0; i<m; i++){
			cin >> mat[i].h >> mat[i].p >> mat[i].q;
		}
		sort(mat.begin(), mat.begin()+m);
		for(j=0; j<m; j++){
			//cout << mat[j].h << " " << mat[j].p << " " << mat[j].q << endl;
			if(ans == mat[j].p){
				ans = mat[j].q;
			}
			else if(ans == mat[j].q){
				ans = mat[j].p;
			}
			//cout << ans << endl;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
using namespace std;

int main( ) {
    ll H,W,K;
    cin>>H>>W>>K;
    vector<string> S(H);
    rep(i,0,H) cin>>S[i];
    ll ans=0;
    rep(i,0,1<<H) {
        rep(j,0,1<<W) {
            ll count=0;
            rep(x,0,H) {
                rep(y,0,W) {
                    if(i>>x &1) continue;
                    if(j>>y &1) continue;
                    if(S[x][y]=='#') count+=1;
                }  
                
            }
            if(count==K) ans+=1;
        }
        
    }
    cout<<ans<<endl;
}

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

#define int long long

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

int N;
int A[100001] = {};

signed main() {
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        ans += A[i] / 2;
        if (A[i] % 2 == 1 && A[i + 1] > 0) {
            ans++;
            A[i + 1]--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
# D - Digits Parade
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
S = readline().decode().rstrip()
N = len(S)

dp = [0]*13
dp[0] = 1
# if S[0] == '?':
#     rem = pow(10,N,13)
#     for j in range(10):
#         t = rem*j%13
#         dp[t] += 1
# else:
#     s = int(S[0])
#     rem = pow(10,N,13)*s%13
#     dp[rem] += 1

for i in range(N):
    s = S[i]
    ndp = [0]*13
    rem = pow(10,N-i-1,13)
    if s == '?':
        for j in range(10):
            t = rem*j%13
            for k in range(13):
                ndp[(k+t)%13] += dp[k]
                ndp[(k+t)%13] %= MOD
    else:
        s = int(s)
        t = rem*s%13
        for k in range(13):
            ndp[(k+t)%13] += dp[k]
            ndp[(k+t)%13] %= MOD
    dp = ndp
print(dp[5]%MOD)

Measured memory_bytes: 68476
#include<bits/stdc++.h>
using namespace std;
int m,n;
double t[16][16],Q[17][16];
double dp[16][(1<<16)];

int main(){
  cin>>m>>n;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      cin>>t[i][j];
  for(int i=0;i<m;i++)Q[n][i]=1.0;
  
  for(int S=(1<<m)-1;S>=0;S--){
    for(int x=n-1;x>=0;x--){
      for(int i=0;i<m;i++){
        if(S>>i&1)continue;
        dp[x][S]=max(dp[x][S],Q[x+1][i]*t[i][x]+(1.0-t[i][x])*dp[x][S|(1<<i)]);
        Q[x][i]=dp[x][S|(1<<i)]*(1.0-t[i][x])+Q[x+1][i]*t[i][x];
      }
    }
  }
  printf("%.12f\n",dp[0][0]);  
  return 0;
}

Measured memory_bytes: 9444
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (0 <= x-r && W >= x+r && 0 <= y-r && H >= y+r){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
use std::io::*;
use std::str::FromStr;

fn main() {
    let (_, t): (usize, usize) = (read(), read());
    let mut a: Vec<i32> = (0..t).map(|_| read()).collect();
    a.sort();
    let mut sum = 0;
    for i in 0..t - 1 {
        sum += a[i];
    }
    println!(
        "{}",
        if sum + 1 >= a[t - 1] {
            0
        } else {
            a[t - 1] - sum - 1
        }
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      int a = scan.nextInt();
      int b = scan.nextInt();
      if( a < b ){
        System.out.println("a < b");
        }else if( a > b ){
        System.out.println("a > b");
        }else{
        System.out.println("a == b");
        }
     }
   }

Measured memory_bytes: 26308
using System;

class D
{
	static void Main()
	{
		Console.ReadLine();
		var s = Console.ReadLine();
		var c = Count(s, 'R');
		Console.WriteLine(c - Count(s[..c], 'R'));
	}
	static int Count(string s, char c) => s.Length - s.Replace(c.ToString(), "").Length;
}

Measured memory_bytes: 28872
#include<bits/stdc++.h>     //すべてのヘッダファイルをインクルード
using namespace std;        //stdの記述を省略する

int main(){
    int n, alice=0,bob=0;
    bool flag=true;
    cin >> n;

    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    while(!a.empty()){
        if(flag){
            alice+=a.at(0);
            flag=false;
        }else{
            bob+=a.at(0);
            flag=true;
        }
        a.erase(a.begin());
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
const ld eps = 1e-4;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int lsum = 0;
    REP(i,26) lsum += c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol(d);
    V<> loss(26,0);
    REP(i,d){
        V<pair<ld,ll>> score(26,{0.0,0});
        REP(j,26) score[j] = {v[i][j] + loss[j] + c[j] * eps, j};
        sort(rall(score));
        int r = score[0].second;
        sol[i] = r;
        REP(j,26){
            if(j == r) loss[j] = 0;
            else loss[j] += c[j];
        }
    }
    REP(i,26) loss[i] = 0;
    ll nowres = 0;
    REP(i,d){
        nowres += v[i][sol[i]];
        REP(j,26){
            if(j == sol[i]) loss[j] = 0;
            else loss[j] += c[j];
            nowres -= loss[j];
        }
    }
    int Q = 500000;
    random_device rnd;
    int newi, newsol, old;
    ll newres;
    while(Q--){
        newi = rnd() % 365;
        newsol = rnd() % 26;
        if(sol[newi] == newsol) continue;
        old = sol[newi];
        sol[newi] = newsol;
        REP(i,26) loss[i] = 0;
        newres = 0;
        REP(i,d){
            newres += v[i][sol[i]];
            REP(j,26){
                if(j == sol[i]) loss[j] = 0;
                else loss[j] += c[j];
                newres -= loss[j];
            }
        }
        if(newres <= nowres) sol[newi] = old;
        else nowres = newres;
    }
    REP(i,d) cout << sol[i] + 1 << '\n';
}


Measured memory_bytes: 3696
using System;
using System.Collections;
using System.Collections.Generic;

namespace _20190605 {
  class ProblemC {
    static void Main(string[] args) {
      int[] vals = Input.nums;
      int[] x = Input.nums;
      int n = vals[0] - vals[1] + 1;
      int min = 0;
      min = Math.Min(Math.Abs(x[0]) + Math.Abs(x[vals[1] - 1] - x[0]), Math.Abs(x[vals[1] - 1]) + Math.Abs(x[vals[1] - 1] - x[0]));
      for (int i = 1; i < n; i++) {
        int tmp = Math.Min(Math.Abs(x[i]) + Math.Abs(x[vals[1] - 1 + i] - x[i]), Math.Abs(x[vals[1] - 1 + i]) + Math.Abs(x[vals[1] - 1 + i] - x[i]));
        if (tmp < min) {
          min = tmp;
        }
      }
      System.Console.WriteLine(min);
    }
  }
  public class Input {
    public static string str => System.Console.ReadLine();
    public static string[] strs => str.Split(' ');
    public static char[] charArr => str.ToCharArray();
    public static int num => int.Parse(str);
    public static int[] nums => Array.ConvertAll(strs, int.Parse);
    public static long numL => long.Parse(str);
    public static long[] numLs => Array.ConvertAll(strs, long.Parse);
  }
}

Measured memory_bytes: 20320
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int ma[10][10];
    int x,y,d;
    char c;
    memset(ma,0,sizeof(ma));
    while(cin>>x>>c>>y>>c>>d){
//    for(int i=0;i<6;i++){
//        
//        cin>>x>>c>>y>>c>>d;
    
        ma[y][x]++;
        if(d==1){
            if(x>0){
                ma[y][x-1]++;
            }
            if(x<9){
                ma[y][x+1]++;
            }
            if(y>0){
                ma[y-1][x]++;
            }
            if(y<9){
                ma[y+1][x]++;
            }
        }
        else if(d==2){
            if(x>0){
                ma[y][x-1]++;
            }
            if(x<9){
                ma[y][x+1]++;
            }
            if(y>0){
                ma[y-1][x]++;
            }
            if(y<9){
                ma[y+1][x]++;
            }
            if(x>0&&y<9){
                ma[y+1][x-1]++;
            }
            if(x<9&&y>0){
                ma[y-1][x+1]++;
            }
            if(x>0&&y>0){
                ma[y-1][x-1]++;
            }
            if(x<9&&y<9){
                ma[y+1][x+1]++;
            }
        }
        else{
            if(x>0){
                ma[y][x-1]++;
            }
            if(x<9){
                ma[y][x+1]++;
            }
            if(y>0){
                ma[y-1][x]++;
            }
            if(y<9){
                ma[y+1][x]++;
            }
            if(x>0&&y<9){
                ma[y+1][x-1]++;
            }
            if(x<9&&y>0){
                ma[y-1][x+1]++;
            }
            if(x>0&&y>0){
                ma[y-1][x-1]++;
            }
            if(x<9&&y<9){
                ma[y+1][x+1]++;
            }
            if(x>1){
                ma[y][x-2]++;
            }
            if(x<8){
                ma[y][x+2]++;
            }
            if(y>1){
                ma[y-2][x]++;
            }
            if(y<8){
                ma[y+2][x]++;
            }
        }
    }
    int em=0,m=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(ma[i][j]==0)em++;
            m=max(m,ma[i][j]);
        }
    }
    cout<<em<<endl<<m<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (ll)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int dp[100500][3];

void solve(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
        dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c;
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 1408
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    la = [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]
    k = ri()
    print(la[k-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;

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

        int N = sc.nextInt();

        Long[] A = new Long[N+1];
        Long[] B = new Long[N];

        for(int i=0; i<=N; i++){
            A[i] = sc.nextLong();
        }

        for(int i=0; i<N; i++){
            B[i] = sc.nextLong();
        }

        Long count = 0L;
        for(int i=0; i<N; i++){
            Long current = A[i];
            Long next = A[i+1];
            if(current <= B[i]){
                B[i] -= current;
                A[i] = 0L;
            }else{
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] > 0){
                if(next <= B[i]){
                    B[i] -= next;
                    A[i+1] = 0L;
                }else{
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }

            count += current - A[i] + next - A[i+1];
        }

        println(count);
    }

    static void println(Object o){
        System.out.println(o);
    }
    static void print(Object o){
        System.out.print(o);
    }
}


Measured memory_bytes: 98532
#include<cstdio>
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
const int maxn = 110;
int a[maxn],n,ans=0,b[maxn];
int main() {
	cin>>n;
	for(register int i = 1;i<=n;++i) cin>>a[i];
	for(register int i = 1;i<=n;++i) {
		if(a[i]==a[i-1]) {
			for(register int j = 1;j<=10000;++j) {
				if(a[i-1]!=j&&a[i+1]!=j) {
					a[i]=j;
					ans++;
					break;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}


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

int main() {
    size_t n;
    cin >> n;
    vector<size_t> v( n );
    for ( size_t i = 0; i < n; ++i ) {
        cin >> v.at( i );
    }
    size_t i = 1;
    int cnt = 0;
    for ( size_t k = 0; k < n; ++k ) {
        i = v.at( i - 1 );
        ++cnt;
        if ( i == 2 )
            break;
    }
    if ( i == 2 )
        cout << cnt;
    else
        cout << -1;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	ll n,k; cin>>n>>k;
	vector<vector<ll>> sushi(n);
	rep(i,n){
		int t; ll d; cin>>t>>d; t--;
		sushi[t].PB(d);
	}
	rep(t,n){
		sort(RALL(sushi[t]));
		if(sushi[t].empty()) sushi[t].PB(-INF);
	}
	sort(RALL(sushi));

	ll tmp = 0LL;
	priority_queue<ll> que;
	rep(i,k){
		tmp+=sushi[i][0];
		reps(j,sushi[i].size()-1) que.push(sushi[i][j]);
	}
	for(int i=k;i<n;i++) rep(j,sushi[i].size()) que.push(sushi[i][j]);

	ll ans=tmp+k*k;
	for(ll x=k-1;x>=1;x--){
		ll a=sushi[x][0], b=que.top();
		if(a<b){
			que.pop(); tmp+=b;
			que.push(a); tmp-=a;
		}
		chmax(ans,tmp+x*x);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8696
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] info = line.split(" ");
		int N = Integer.parseInt(info[0]);
		int M = Integer.parseInt(info[1]);
		
		System.out.println(N*(N-1)/2 + M*(M-1)/2);
	}
}


Measured memory_bytes: 21076
/*  
    And solitare's the only game in town
    And every road that takes him
    Takes him down
    And by himself it's easy to pretend
    He'll never love again
    _________________________
    _________________________
    960 Hours of Solitude
    Quarantine_Day : 40
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 200005

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

    ll k;
    vl v(3);
    cin>>v[0]>>v[1]>>v[2]>>k;
    SORT(v);
    cout<<(v[0] + v[1] + ((1<<k) * v[2]))<<"\n";

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> jobs(n);
    for (int i = 0; i < n; i++) {
        cin >> jobs[i].first >> jobs[i].second;
    } 
    sort(jobs.begin(), jobs.end());
    int ans = 0;
    multiset<int, greater<int>> s;
    int j = 0;
    for (int i = 1; i <= m; i++) {
        while (j < n && jobs[j].first <= i) {
            s.insert(jobs[j].second);
            j++;
        }
        if (!s.empty()) {
            ans += *s.begin();
            s.erase(s.begin());
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5632
fun main(args: Array<String>) {
    val initials = mapOf(
            'M' to 0,
            'A' to 1,
            'R' to 2,
            'C' to 3,
            'H' to 4
    )
    val n = readLine()!!.toInt()
    val cnt = LongArray(5)
    repeat(n) {
        val s = readLine()!!
        if (s[0] in initials) {
            val i = initials[s[0]] ?: error("")
            cnt[i]++
        }
    }

    var ans = 0L

    for (i in 0..2) {
        for (j in i + 1..3) {
            for (k in j + 1..4) {
                ans += cnt[i] * cnt[j] * cnt[k]
            }
        }
    }

    println(ans)
}


Measured memory_bytes: 37192
#include <stdio.h>
#include <math.h>
int main(){
    double x1,x2;
    double y1,y2;
    scanf("%lf %lf",&x1,&y1);
    scanf("%lf %lf",&x2,&y2);
    x1-=x2;
    y1-=y2;
    printf("%lf\n",sqrt(x1*x1+y1*y1));
    return 0;
}


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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if(A % 2 == B % 2){
        cout << (B - A) / 2 << endl;
    }else{
        cout << min(A - 1, N - B) + 1 + (B - A - 1) / 2;
    }
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
#define pp pair<pii,pii>
const int hell =998244353;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}

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

int digitsum(int x)
{
  while(x>9)
    {  int ans=0;
       while(x!=0)
       {
        ans+=x%10;
        x/=10;
       }
       x=ans;
    }
    return x;
}

int pw(int a,int b)
{
  int x=a;
  rep(i,1,b){a=a*x;}
  return a;
}

int solve( ){

int n,k;
cin>>n>>k;
k--;
string s;
cin>>s;
rep(i,0,n)
{  
  if(i==k)
  {
    cout<<(char)(s[i]+32);
  }
  else
  {
    cout<<s[i];
  }

}


return 0;
}

signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    



  clock_t time_req;

    // Without using pow function
                                                                                                                   

    //cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

int issq(int x) {
	int l = 0;
	int r = 3e4;
	while (r - l > 1) {
		int m = (r + l) >> 1;
		if (m * m <= x) {
			l = m;
		} else {
			r = m;
		}
	}
	return l * l == x;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, d;
	cin >> n >> d;
	vector<vector<int>> a(n, vector<int> (d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int i1 = 0; i1 < n; i1++) {
		for (int i2 = i1 + 1; i2 < n; i2++) {
			int s = 0;
			for (int j = 0; j < d; j++) {
				s += (a[i1][j] - a[i2][j]) * (a[i1][j] - a[i2][j]);
			}
			ans += issq(s);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	while (1){
		cin >> a >> b;
		if (cin.eof()) break;
		if (a == b and a == 0) cout << 1 << endl;
		else cout << int(log10(a + b)) + 1 << endl;
	}
}


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

int main() {
  int N,X;
  cin >> N >> X;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  int base = 0;
  for(int j;j < N;j++) {
    base = base + vec.at(j);
  }
  sort(vec.begin(),vec.end());
  cout << N + ( X - base ) / vec.at(0) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 2000000000;
// const long MOD = 1000000007;

const int MAX_V = 101;

int d[MAX_V][MAX_V];
int V, E;

// https://ei1333.github.io/luzhiled/snippets/graph/warshall-floyd.html
void warshall_floyd() {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        if (d[i][k] == INF || d[k][j] == INF) {
          continue;
        }
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> V >> E;
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = INF;
      }
    }
  }
  for (int i = 0; i < E; i++) {
    int si, ti, di;
    cin >> si >> ti >> di;
    d[si][ti] = di;
  }

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

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

  return 0;
}


Measured memory_bytes: 3240
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS.sort()
counter=[]
count=1
for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    counter+=[count]
    count=1
    
counter+=[count]    
MAX=max(counter)
count=1

for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    count=1
  if count==MAX:
    print(listS[i])
    
if MAX==1:
  print(listS[-1])      

Measured memory_bytes: 20680
#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>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

struct SegT {
private:
	int sz; vector<ll> node;
	const ll init_c = 0;
public:
	SegT(int n) {
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
	}
	ll f(ll a, ll b) {
		return (a + b)%mod;
	}
	void update(int k, ll a) {
		k += sz - 1;
		node[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = f(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = sz;
		if (r <= a || b <= l)return init_c;
		else if (a <= l && r <= b)return node[k];
		else {
			ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
};

ll mod_pow(ll x, ll n) {
	ll ret = 1;
	while (n) {
		if (n % 2)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
ll dp[1 << 18][2][2];
void solve() {
	int n, m; cin >> n >> m;
	string s; cin >> s;
	if (s[0] == 'B') {
		rep(i, m) {
			if (s[i] == 'B')s[i] = 'R';
			else s[i] = 'B';
		}
	}
	vector<int> v;
	rep(i, m) {
		int le = i;
		while (i + 1 < m&&s[i + 1] == s[i])i++;
		v.push_back(i - le + 1);
	}
	if (v.size() == 1) {
		dp[0][0][0] = 1;
		dp[0][1][1] = 1;
		rep(i, n - 1) {
			rep(j, 2) {
				(dp[i + 1][0][j] += dp[i][0][j] + dp[i][1][j]) %= mod;
				dp[i + 1][1][j] += dp[i][0][j];
			}
		}
		ll ans = dp[n - 1][0][0] + dp[n - 1][1][0] + dp[n - 1][0][1];
		cout << ans % mod << endl; return;
	}
	if (n % 2) {
		cout << 0 << endl; return;
	}
	int d = n / 2;
	int x = v[0] / 2 + 1;
	for (int i = 0; i < v.size(); i += 2) {
		if (i + 1 == v.size())break;
		if (v[i] % 2) {
			x = min(x, v[i] / 2 + 1);
		}
	}
	if (x >= d) {
		ll ans = mod_pow(2, d) - 1;
		ans = ans * 2;
		ans = (ans + mod) % mod;
		cout << ans << endl;
	}
	else {
		SegT dp(d + 1);
		dp.update(0, 1);
		rep1(i, d - 1) {
			int le = i - x;
			le = max(le, 0);
			ll nex = dp.query(le, i);
			dp.update(i, nex);
		}
		ll ans = 0;
		rep(i, x) {
			ll z = dp.query(d - x, d - i); ans += z;
			if (ans >= mod)ans -= mod;
		}
		ans = ans * 2 % mod;
		cout << ans << endl;
	}

}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 8784
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define float double 
#define dg(x) cout<<#x<<" :"<<x;
#define dg_array(ar) for(auto x : ar) cout<<x<<" ";cout<<endl;
#define dg_2darray(ar) for(auto x : ar) {for(auto y : x) cout<< y<<" ";cout<<endl;}
#define endl '\n'
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
    int a, b;
    cin >> a >> b;
    if( b >= a )
        cout<< "unsafe";
    else
    {
        cout<<"safe";
    }
    
}

void testcase()
{
    int t;
    cin>>t;
    while(t--)
        solve();
}
int32_t main(){
	fast;
//    testcase();           
   solve();              
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long a, b, c, d; scan(a, b, c, d);
      long res = std::max((long)0, std::minmax({b - c, d - a, b - a, d - c}).first);
      printf("%ld\n", res);
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}
 

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

int main (){
    int a, b, q, w;
    while (~scanf("%d%d%d%d", &a, &b, &q, &w)){
        if (a+b > q+w)  puts("Left");
        else if (a+b == q+w)  puts("Balanced");
        else puts("Right");
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
    public static void main(String args[]){
        try{
            BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
            String str=reader.readLine();
            int time=Integer.parseInt(str);
            
            int h=time/3600;
            int m=(time%3600)/60;
            int s=time%60;
            
            System.out.println(h+":"+m+":"+s);
            
        }catch(IOException e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24260
from fractions import gcd    # 最大公約数: gcd(x, y)
from functools import reduce
def gcd_list(numbers):
    return reduce(gcd, numbers)

def main():
    n, x = map(int, input().split())
    num_list = list(map(int, input().split()))

    for i in range(n):
        num_list[i] = abs(num_list[i] - x)

    print(gcd_list(num_list))

if __name__ == '__main__':
    main()

Measured memory_bytes: 88172
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin>>N>>M;
  
  vector<int> road(N,0);
  vector<int> a(M);
  vector<int> b(M);
  
  for (int i=0;i<M;i++){
    cin>>a.at(i)>>b.at(i);
  }
  for(int i=0;i<M;i++){
    road.at(a.at(i)-1)++;
    road.at(b.at(i)-1)++;
  }
  for(int i=0;i<N;i++){
    cout<<road.at(i)<<endl;
  }
}

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

const int MOD = 1e9 + 7;
const int MAXN = 112345;

int n;
long long v[MAXN];
long long sum = 0LL;
long long ans[MAXN];

map<long long,long long> freq;
stack<pair<long long,long long> > st;

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	st.push(make_pair(0,0));
	
	cin >> n;
	for(int i = 1 ; i <= n ; i ++){
		cin >> v[i];
		freq[v[i]]++;
		sum += v[i];
		if(v[i] > st.top().second)
			st.push(make_pair(i, v[i]));
	}
	
	long long prev = 0LL;
	
	while(st.size() != 1){
		
		int id = st.top().first;
		int x = st.top().second;
		st.pop();
		
		long long middle = 0LL;
		long long cnt = 0LL;
		map<long long,long long> :: iterator it, jt;
		it = freq.lower_bound(st.top().second + 1);
		
		for( ; it != freq.end() ; it++){
          	cnt += it->second;
			if(it->first == x){
              	middle += (it->first - st.top().second) * (prev + it->second);
              	break;
            }
			middle += (it->first - st.top().second) * (it->second);
		}
		
		ans[id] = middle;
		prev += cnt;
	}
	
	for(int i = 1 ; i <= n ; i ++)
		cout << ans[i] << "\n";
	
	return 0;
}

Measured memory_bytes: 12956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    vector<ll> d(n);
    rep (i, n) {
        cin >> d[i];
    }
    vector<ll> e(100002, 0);
    rep(i, n) {
        e[d[i]]++;
    }
    if (d[0] != 0 || e[0] > 1) {
        cout << 0 << endl;
        exit(0);
    }
    ll ans = 1;
    ll mod = 998244353;
    bool flag = false;
    rep(i, 1, 100002) {
        if (flag) {
            if (e[i] > 0) {
                cout << 0 << endl;
                exit(0);
            }
        }
        else {
            if (e[i] == 0) {
                flag = true;
            }
            else {
                rep(j, e[i]) {
                    ans *= e[i-1];
                    ans %= mod;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    while(true) {
        int N = readln.chomp.to!int;
        if (N==0) break;
        int[][] ary = new int[][N];
        foreach(i; 0..N) {
            ary[i] = readln.split.to!(int[]);
        }
        ary.sort!"a[1]>b[1]";
        int sum = reduce!"a+b[0]"(0, ary);
        foreach(i; 0..N) {
            if (sum > ary[i][1]) {
                writeln("No");
                break;
            }
            sum -= ary[i][0];
            if (sum==0) writeln("Yes");
        }
    }
}

Measured memory_bytes: 2572
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = getLine >>= putStrLn . which "A" "a" . isUpper . head

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s; 
  	cin >> s;
	string hitachi = "";
	for (int i = 1; i <= 5; i++) {
		hitachi += "hi";
		if (hitachi == s) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

using namespace std;

int d;
string s;
const int mod = 1e9 + 7;

int dp[1000010][2][110];

int f(int pos, int flag, int sum) {
    if(pos == (int)s.size()) {
        if(sum == 0) return 1;
        return 0;
    }
    
    int lim = 9;
    if(flag) lim = s[pos] - '0';

    int  &ans = dp[pos][flag][sum];
    if(ans != -1) return ans;
    ans = 0;

    for (int i = 0; i <= lim; ++i) {
        if(flag and i == s[pos] - '0') ans += f(pos + 1, 1, (sum + i) % d);
        else ans += f(pos + 1, 0, (sum + i) % d);
        ans %= mod;
    }
    return ans;
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> s >> d;

    cout << (f(0,1,0) - 1 + mod) % mod<< "\n";
    return 0;
}


Measured memory_bytes: 863816
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=55;
const ll limit=1e16+1000;
ll k;
ll a[maxn];

bool check(int n){
	ll cur=n-1-k;
	REP(i,n)a[i]=cur;
	ll c=k/n,d=k%n;
	REP(i,n){
		if(i<=d){
			if(a[i]+(ll)(n+1)*(c+1)>limit)return false;
			a[i]+=(ll)(n+1)*(c+1);
		}
		else{
			if(a[i]+(ll)(n+1)*c>limit)return false;
			a[i]+=(ll)(n+1)*c;
		}
	}
	return true;
}

int main(){
	cin>>k;
	for(int i=2;i<=50;i++)
	if(check(i)){
		cout<<i<<endl;
		REP(j,i)cout<<a[j]<<" ";
		return 0; 
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov
//export PATH=PATH:~/.local/bin

int main(){
    cout<<setprecision(12);
    double long pi=3.1415926535897;
    double long a;
    cin >> a;
    double long b;
    cin >> b;
    long long h;
    cin >> h;
    long long m;
    cin >> m;
    m+=h*60;
    double long rad=11*m/360.0*pi;
    cout<<sqrt(a*a+b*b-2.0*a*b*cos(rad))<<endl;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define F first
#define S second
#define X real()
#define Y imag()
#define PB push_back 
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef complex<int> cld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut,pr> ppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
typedef vector<ppr> Vppr;
const int bitSIZE=1<<10;
const int SIZE=1+1e+5;
const int INF=1+1e+7;
const int SEGSIZE=3*1e+8;
bool need[bitSIZE][27];
char str[SIZE];
int num[SIZE];
int N,M;
int cards[27][10];
int minC[27],minN[10];
int DP[27][bitSIZE];
void calcNeed(int bit){
	REP(i,N){
		if(bit&(1<<num[i])) continue;
		else need[bit][str[i]-'A']=true;
	}
}
int solve(int bit){
	REP(i,27)
		REP(j,bitSIZE)
			DP[i][j]=INF;
	int bitnum=0;
	int grundy[10]={};
	int ingrund[10]={};
	DP[0][0]=0;
	REP(i,10){
		if(bit&(1<<i))
			grundy[bitnum++]=i;
	}
	REP(i,'Z'-'A'+1){
		if(need[bit][i])
			REP(k,1<<bitnum)
				REP(j,bitnum){
					DP[i+1][k|(1<<j)]=min(DP[i+1][k|(1<<j)],DP[i][k]+cards[i][grundy[j]]);
					DP[i+1][k]=min(DP[i+1][k],DP[i][k]+minC[i]);
				}
		else
			REP(k,1<<bitnum)
				DP[i+1][k]=DP[i][k];
	}
	int ans=INF;
	REP(i,1<<bitnum){
		int sum=0;
		REP(j,bitnum)
			if((i&(1<<j))==0)
				sum+=minN[grundy[j]];
		ans=min(ans,DP['Z'-'A'+1][i]+sum);
	}
	return ans;
}
int main(){
	cin >> N;
	char c;
	int n,cost;
	REP(i,N)
		cin >> str[i] >> num[i];
	REP(i,bitSIZE)
		calcNeed(i);
	REP(i,27)
		REP(j,11)
			cards[i][j]=INF;
	REP(i,'Z'-'A'+1)
		minC[i]=INF;
	REP(i,10)
		minN[i]=INF;
	cin >> M;
	REP(i,M){
		cin >> c >> n >> cost;
		cards[c-'A'][n]=min(cost,cards[c-'A'][n]);
		minC[c-'A']=min(minC[c-'A'],cost);
		minN[n]=min(minN[n],cost);
	}
	int ans=INF;
	REP(i,bitSIZE)
		ans=min(ans,solve(i));
	if(ans>=INF) cout << -1 << endl;
	else cout << ans << endl;

}

Measured memory_bytes: 1352
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int const MAXN=15;
int n;
vector<pair<int,int>> v[MAXN];
bitset<MAXN> b;
int ans=0;
void check(){
	for(int i=0;i<n;i++){
		if(b[i]==0)
			continue;
		for(auto p:v[i]){
			if(b[p.first]!=p.second)
				return;
		}
	}
	ans=max(ans,(int)b.count());
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;i++){
		int dec;
		cin>>dec;
		for(int j=0;j<dec;j++){
		int a, b;
		cin>>a>>b;
		v[i].push_back({a-1,b});
		}
	}
	int val=0;
	while(val<(1<<n)){
		b=val;
		check();
		val++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int a, b;
	cin >> a >> b;
	if (a == b) {
		for (int i = 0; i < a; ++i) {
			cout << a;
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < max(a, b); ++i) {
			cout << min(a, b);
		}
		cout << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int a;
    int b;
    
    scanf("%d %d",&a,&b);
    
    if (a < b) {
        printf("a < b\n");
    }else if (a > b){
        printf("a > b\n");
    }else if (a == b){
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580