akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int n=0;
  cin >> S;
  for(int i=0;i<S.size()/2;i++){
      if(S[i]!=S[S.size()-i-1]){
          n++;
      }
  }
  cout << n;
}

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

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<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()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let tomorrow = if s == "Sunny".to_string() {
        "Cloudy"
    } else if s == "Cloudy".to_string() {
        "Rainy"
    } else {
        "Sunny"
    };
    println!("{}", tomorrow);
}


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


public class ABC116b
{
    public static void Main()
    {

        int s = int.Parse(Console.ReadLine());
        int cnt = 1;
        while (s > 4)
        {
            cnt++;
            if (s % 2==1)
            {
                s *= 3;
                s++;
            }
            else
            {
                s /= 2;
            }
            
        }
        int[] L = new int[100];//Lが小さいとs==3でバグる
        while (true)
        {
            
            if (L[s] == 1)
            {
                System.Console.WriteLine(cnt);
                Environment.Exit(0);
            }
            else
            {
                L[s] = 1;
                if (s % 2==1)
                {
                    s *= 3;
                    s++;
                }
                else
                {
                    s /= 2;
                }
               
            }
            cnt++;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <array>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>

using namespace std;
using ll = long long;

ll N;
vector<ll> A;

void input() {
    cin >> N;
    A.resize(N);
    for (auto& a : A) cin >> a;
}

ll gcd(ll a, ll b) {
    if (a > b)
        swap(a, b);
    ll r = a%b;
    while (r) {
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}

ll solve() {
    vector<ll> l(N), r(N);
    l[0] = A[0];
    r[N-1] = A[N-1];
    for (ll i = 1; i < N; i++) {
        l[i] = gcd(l[i-1], A[i]);
    }
    for (ll i = N-2; i >= 0; i--) {
        r[i] = gcd(r[i+1], A[i]);
    }
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll cans;
        if (i == 0)
            cans = r[i+1];
        else if (i == N-1)
            cans = l[i-1];
        else
            cans = gcd(l[i-1], r[i+1]);
        ans = max(ans, cans);
    }
    return ans;
}

int main() {
    input();
    cout << solve() << endl;
//    solve();

    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll>ch[100010];
ll n,a,b,deep[100010],lim;
void dep(ll now,ll cnt){
	deep[now]=cnt;
	for(ll i=0;i<ch[now].size();i++){
		ll nex=ch[now][i];
		if(deep[nex]!=-1){
			continue;
		}
		dep(nex,cnt+1);
	}
}
ll limnow;
void up(ll now){
	if(lim==deep[now]){
		limnow=now;
		return;
	}
	for(ll i=0;i<ch[now].size();i++){
		ll nex=ch[now][i];
		if(deep[nex]<deep[now]){
			up(nex);
		}
	}
}
ll ans=0;
void see(ll now,ll cnt){
	ans=max(ans,cnt);
	for(ll i=0;i<ch[now].size();i++){
		ll nex=ch[now][i];
		if(deep[nex]>cnt){
			see(nex,cnt+1);
		}
	}
}
int main() {
	cin>>n>>a>>b;
	a--;b--;
	for(ll i=0;i<n-1;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		ch[x].push_back(y);
		ch[y].push_back(x);
	}
	for(ll i=0;i<n;i++){
		deep[i]=-1;
	}
	dep(b,0);
//	for(ll i=0;i<n;i++){
//		cout << deep[i];
//	}
	lim=deep[a]/(-2)+deep[a];
	up(a);
//	cout << limnow;
//	cout << deep[limnow];
	see(limnow,deep[limnow]);
//	cout << ans<<endl;
	if(ans==1){
		cout << 0;
		return 0;
	}
	cout << ans-1;
	// your code goes here
	return 0;
}


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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (a, b) = [int(e) for e in lines[0].split(" ")]

    return (a, b)


def solve(a, b):

    return max(a - 2 * b, 0)


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

using namespace std;

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

  string s;
  int w;
  cin >> s >> w;
  int n = s.length();

  string ans;
  for (int i = 0; i < n; i += w) {
    ans += s[i];
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

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

typedef long long lint;
typedef pair<int,int> P;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main()
{

    int t[3];
    cin >> t[0] >> t[1] >> t[2];

    sort(t,t+3);

    int ans = t[0] + t[1];


    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int A; cin >> A;

    cout << n * n - A << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout
import math as m
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()

def tgcd(a, b, c):
	d = m.gcd(a, b)
	return m.gcd(d, c)    

def main():
	k = int(rl())
	ans = 0
	for a in range(1, k+1):
		for b in range(1, k+1):
			for c in range(1, k+1):
				ans += tgcd(a, b, c)
	stdout.write(str(ans));stdout.write("\n")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 70200
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<int> dp(N + 1, 1e9);
    vec<int> s = {1};

    int six = 1;
    int nin = 1;
    while (six * 6 <= N) {
        six *= 6;
        s.push_back(six);
    }
    while (nin * 9 <= N) {
        nin *= 9;
        s.push_back(nin);
    }
    sort(all(s));
    dp[0] = 0;
    for(auto e:s)for(int i=0;i<=N;++i){
        if(i+e>N) break;
        dp[i+e] = min(dp[i+e],dp[i]+1);
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 640
n=int(input())
a=[]
b=[]
for i in range(n):
  x=int(input())
  if x%10==0:
    b.append(x)
  else:
    a.append(x)
a.sort()
ans=sum(a)+sum(b)
if ans%10==0:
  if len(a)>0:
    ans-=a[0]
  else:
    ans=0
print(ans)

Measured memory_bytes: 38256
from collections import defaultdict


def main():
    s = map(lambda x: "".join(sorted(x)), open(0).read().split()[1:])
    d = defaultdict(lambda: 0)
    ans = 0
    for i in s:
        ans += d[i]
        d[i] += 1
    print(ans)
    return


main()


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

int main() {
	int a,b,c,count;
    cin >> a >> b >> c;
    if(a==b && b == c){
      count = 1;
    }
    else if(a==b || b==c || a==c){
      count = 2;
    }
    else{
      count = 3;
    }
    cout << count << endl;
}


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

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

            if (N % 10 == 3)
            {
                Console.WriteLine("bon");
            }
            else if (N % 10 == 0
                || N % 10 == 1
                || N % 10 == 6
                || N % 10 == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }

        }
    }
}


Measured memory_bytes: 27536
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 24 00:11:24 2019

@author: iwao_yuuki
"""

import math

n = int(input(""))
S = [int(x) for x in input().split()]

q = int(input(""))
T = [int(x) for x in input().split()]

cnt = 0
for i in T:
    head = 0
    tail = n-1

    while head <= tail:
        center = math.floor((head+tail)/2)

        if S[center] == i:
            cnt += 1
            break
        else:
            if S[center] < i:
                head = center + 1
            else:
                if S[center] > i:
                    tail = center - 1

print(cnt)


Measured memory_bytes: 17004
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 36
#define SG getchar()
using namespace std;
bool a[szxb];
signed main()
{
	char c;string ans("None");memset(a,false,sizeof(a));
	while((c=SG)-10){a[c-97]=true;}
	for(register int i(0);i<=25;i++){if(!a[i]){ans=(char(i+97));break;}}
	cout<<ans;
	return putchar(10),0;
}

Measured memory_bytes: 768
#include <stdio.h>

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

    //int min_val = X - K + 1;
    //int max_val = X + K - 1;

    for (int i = X - K + 1; i <= X + K - 1; i++) {
        printf("%d", i);
        if (i != X + K - 1)
            printf(" ");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,a;
  cin>>n>>k;
  a=0;
    vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < k; i++) {
    a+=vec.at(i);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
#include <functional>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<int>;
using Plane=vector<Point>;
using Polygon=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

enum {
    ONLINE_FRONT=-2,
    CLOCKWISE,
    ON_SEGMENT,
    COUNTER_CLOCKWISE,
    ONLINE_BACK,
};

int ccwise(Point a, Point b, Point c) {
    b -= a; c -= a;

    if (cross_prod(b, c) > 0) {
        return COUNTER_CLOCKWISE;
    } else if (cross_prod(b, c) < 0) {
        return CLOCKWISE;
    } else if (dot_prod(b, c) < 0) {
        return ONLINE_BACK;
    } else if (norm(b) < norm(c)) {
        return ONLINE_FRONT;
    } else {
        return ON_SEGMENT;
    }
}

Polygon convex_hull(Polygon g) {
    size_t V=g.size(), k=0;
    sort(g.begin(), g.end(), [](const Point &x, const Point &y) {
        return imag(x)!=imag(y)? imag(x)<imag(y) : real(x)<real(y);
    });

    Polygon chull(V<<1);
    for (size_t i=0; i<V; chull[k++]=g[i++])
        while (k >= 2) {
            int state=ccwise(chull[k-2], chull[k-1], g[i]);
            if (state == ONLINE_FRONT || state == COUNTER_CLOCKWISE)
                break;

            --k;
        }

    for (size_t i=V-2, t=k+1; ~i; chull[k++]=g[i--])
        while (k >= t) {
            int state=ccwise(chull[k-2], chull[k-1], g[i]);
            if (state == ONLINE_FRONT || state == COUNTER_CLOCKWISE)
                break;

            --k;
        }

    chull.resize(k-1);
    return chull;
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Polygon g(n);
    for (size_t i=0; i<n; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);
        g[i] = Point(x, y);
    }

    Polygon h=convex_hull(g);
    printf("%zu\n", h.size());
    for (size_t i=0; i<h.size(); ++i)
        printf("%d %d\n", real(h[i]), imag(h[i]));

    return 0;
}

Measured memory_bytes: 5516
#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;

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

  ll n, m;
  cin >> n >> m;

  vll as(m), cs(m);

  rep(i, m){
    ll b;
    cin >> as[i] >> b;
    rep(j, b){
      ll c;
      cin >> c;
      cs[i] |= (1 << (c-1));
    }
  }

  vvll dp(1 << n, vll(m + 1, INF));
  
  rep(i, m+1) dp[0][i] = 0;

  repLRE(i, 1, m){
    rep(s, 1 << n) dp[s][i] = dp[s][i-1];
    rep(s, 1 << n){
      chmin(dp[s | cs[i-1]][i], dp[s][i] + as[i-1]);
    }
  }
  
  ll ans = dp.back().back();
  if(ans == INF) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35324
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int factors(long long int a) {vector<long long int> v; set<long long int> s;for(long long int i=2; i*i<=a; i++){while(a%i==0){s.insert(i);v.push_back(i);a/=i;}}if(a>=2)v.push_back(a), s.insert(a); return int(s.size());}

set<long long int> pd(long long int n) 
{
	set<long long int > s; 
    for (int i=2; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            s.insert(i); s.insert(n/i);
        } 
    } 
    s.insert(n);
    return s;
} 
int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a;
	cin>>a;
	map<long long int, long long int > taken;
	while(1)
	{
		set<long long int> s=pd(a);
		int flag=0;
		for(auto const x: s)
		{
			int v=factors(x);
			if(v==1)
			{
				if(!taken[x])
				{
					taken[x]=1;
					a/=x;
					flag=1;
					//cout<<x<<" "<<a<<'\n';
					break;
				}
			}
		}
		if(!flag)
			break;
	}
	cout<<taken.size();
	return 0;
}

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

using namespace std;

int N;
int A[100];

void show() {
  for (int i = 0; i < N; i++) {
    cout << A[i] << (i == N-1 ? "\n" : " ");
  }
}

void solve() {
  show();
  for (int i = 1; i < N; i++) {
    int key = A[i];
    int j = i-1;
    while(j >= 0 && A[j] > key) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    show();
  }
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  solve();
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    set<char> p;
    rep(i,n){
        char a; cin>>a;
        p.insert(a);
    }
    if(p.size()==3){
        cout<<"Three"<<endl;
    }else{
        cout<<"Four"<<endl;
    }
}

Measured memory_bytes: 3640
r=0...gets.to_f
x,y=$<.map{|l|l.split.map &:to_i}
(1..3).map{|p|puts"%f"%r.map{|i|(x[i]-y[i]).abs**p}.reduce(:+)**(1.0/p)}
p r.map{|i|(x[i]-y[i]).abs}.max.to_f

Measured memory_bytes: 6200
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],4)[0];
  var M = myconv(input[0],4)[1];
  var X = myconv(input[0],4)[2];
  var costlist = myconv(input[1],4);
  
  var mass = new Array(N+1).fill(0);
  for(var i = 0; i < M; i++){
    mass[costlist[i]] = 1;
  }
  //myout(mass);
  var output1 = 0;
  var output2 = 0;
  for(var i = X+1; i <= N; i++){
    if(mass[i] == 1){
       output1++;
    }
  }
  for(var i = X-1; i >= 0; i--){
    if(mass[i] == 1){
       output2++;
    }
  }
  myout(Math.min(output1,output2));
}

Main(myin());


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

int main(){
    int a;
    cin>>a;
    int n=0;
    for(;;n++){
        if(n*(n+1)/2>=a) break; 
    }

    int p=n*(n+1)/2-a;
    p=n-p;
    string s="";
    int lef=0;
    for(int i=0;i<2*n;i++){
        if(p!=0 && i==p){
            s+="(";
        }
        else if(lef<n){
            s+=")";
            lef++;
        }else{
            s+="(";
        }
    }
    cout<<s<<endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N;
string S;
vector<vector<vector<int>>> ps;
int res[300010],res2[300010];

int win(int i,int j){
	if(i>j)swap(i,j);
	return S[j-i-1]=='0'?i:j;
}

void dfs(int k,int d,int v){
	if(d==N){
		res[v]=ps[d][k][0];
		return ;
	}

	int sz=ps[d][k].size();
	/*dbg(k); dbg(d); dbg(v);
	rep(i,sz){
		cout<<ps[d][k][i]<<" ";
	}
	cout<<endl;
	cout<<"---"<<endl;*/

	{
		vector<int> tmp;
		for(int i=0;i<sz-1;i+=2){
			tmp.push_back(win(ps[d][k][i],ps[d][k][i+1]));
		}
		ps[d+1][2*k]=tmp;
	}
	dfs(2*k,d+1,v);
	{
		vector<int> tmp;
		tmp.push_back(win(ps[d][k][0],ps[d][k][sz-1]));
		for(int i=1;i<sz-2;i+=2){
			tmp.push_back(win(ps[d][k][i],ps[d][k][i+1]));
		}
		ps[d+1][2*k+1]=tmp;
	}
	dfs(2*k+1,d+1,v|(1<<d));
}

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

  cin>>N>>S;
  vector<int> P(1<<N);
  rep(i,1<<N){
  	cin>>P[i];
  	P[i]--;
  }
  ps.resize(N+1);
  rep(i,N+1)ps[i].resize(1<<i);
  ps[0][0]=P;
  dfs(0,0,0);

  rep(i,1<<N){
  	cout<<res[((1<<N)-i+(1<<N))%(1<<N)]+1<<endl;
  }

  return 0;
}



Measured memory_bytes: 49488
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll a, v;
  cin >> a >> v;
  ll b, w;
  cin >> b >> w;
  ll t;
  cin >> t;
  if(v <= w){
    cout << "NO" << endl;
    return 0;
  }

  ll d = abs(a-b);
  ll wv = abs(w-v);
  ll co = (d+wv-1)/wv;
  if(co <= t) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3620
c = {
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}

n = int(input())
for i in range(n):
    pic,number = input().split()
    c[pic][int(number)-1]=1
for i in ['S','H','C','D']:
    for j in range(13):
        if c[i][j]==0:
            print(i,j+1)


Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    
    int ans = 0;
    for (char c : s) {
      if (c == '1') {
        ans++;
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
#include<cstdio>
#include<cstring>
using namespace std;
char str[200100];
int nex[200100][26];
int dp[200100];
int n;
int main(){
//	freopen("C.in","r",stdin);
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=0;i<26;i++)
		nex[n][i]=n+10;
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<26;j++)
			nex[i][j]=nex[i+1][j];
		nex[i][str[i+1]-'a']=i+1;
	}
	for(int i=n;i>=0;i--){
		dp[i]=300100;
		for(int j=0;j<26;j++)
			if(dp[nex[i][j]]+1<dp[i])
				dp[i]=dp[nex[i][j]]+1;
	}
	int h=0;
	while(h<=n){
		for(int i=0;i<26;i++)
		{
			if(dp[nex[h][i]]==dp[h]-1)
			{
				printf("%c",'a'+i);
				h=nex[h][i];
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 21504
import java.util.Scanner;

public class Main {

	final static String[] suits = {"S", "H", "C", "D"};
	final static int[] ranks = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};  
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);		
		boolean[][] exist = new boolean[suits.length][ranks.length];
		int n = scan.nextInt();
		
		for (int i = 0; i < n; i++) {
			String suit = scan.next();
			int rank = scan.nextInt();
			for (int j = 0; j < suits.length; j++) {
				if (suits[j].equals(suit)) {
					exist[j][rank-1] = true;
				}
			}
		}

		for (int i = 0; i < suits.length; i++) {
			for (int j = 0; j < ranks.length; j++) {
				if (!exist[i][j]) {
					System.out.println(suits[i] + " " + ranks[j]);
				}
			}
		}

		scan.close();
	}

}

Measured memory_bytes: 18080
import java.io.*;

class Main{

	  static public void main (String test[]) throws IOException {
	
	  	InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);                    //?????????

        String str = br.readLine();                                    //?????????
        int x=Integer.parseInt(str);
	  	
	  	
        System.out.println(x*x*x);
	  
      
	}
}

Measured memory_bytes: 24116
#include<stdio.h>
int selectionsort(int A[100],int n);
int A[100],out=0;
int main()
{
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  selectionsort(A,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",out);
  return 0;
}

int selectionsort(int A[],int n)
{
  int temp,i,j,mini;
  for(i=0;i<n-1;i++){
    mini = i;

    for(j=i+1;j<n;j++){
      if(A[j]<A[mini]) mini = j;
    }

      if(A[i]>A[mini]){
	temp = A[i];
	A[i] = A[mini];
	A[mini] = temp;
	out++;
      }
  }
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int N, A, B, C;
vector<int> l(N);

int dfs(int i, int a, int b, int c);
int main(int argc, char** argv){
  cin >> N >> A >> B >> C;
  for(int cnt0=0; cnt0<N; cnt0++){
    int tmp;
    cin >> tmp; l.push_back(tmp);
  }

  int ans;
  ans = dfs(0, 0, 0, 0);
  printf("%d", ans);
  return 0;
  
}


int dfs(int i, int a, int b, int c){
  if(i == N){
    int minABC;
    minABC = min(a, b); minABC = min(minABC, c);
    if(minABC > 0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
    else return 1e6;
  }
  
  int ret = dfs(i+1, a, b, c);
  ret = min(ret, dfs(i+1, a+l[i], b, c) + 10);
  ret = min(ret, dfs(i+1, a, b+l[i], c) + 10);
  ret = min(ret, dfs(i+1, a, b, c+l[i]) + 10);
  return ret;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll A,B,C,D,ans=0; cin>>A>>B>>C>>D;
  ans+=min(A,D);
  D-=A;
  D-=B;
  if(D>0) ans-=min(C,D);
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <complex>
const double pi = 3.14159265358979;
using namespace std;

double radians(int degree){
	return double(degree)/180*pi;
}

int main(void){
	int r, angle=0, direction=90;
	char c;
	complex <double> p(0, 0);
	while (true){
		cin>>r>>c>>angle;
		if (r==0 && angle==0) break;
		p += polar((double)r, radians(direction));
		direction -= angle;

	}
	cout<<(int)p.real()<<endl;
	cout<<(int)p.imag()<<endl;
	return 0;
}

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

int     main() {
        int H, W;
        cin >>H >>W;
        vector<vector<bool>> s(H+2, vector<bool> (W+2, false));
        for (int i=1; i<=H; i++)
                for (int j=1; j<=W; j++) {
                        char C;
                        cin >> C;
                        if ('#'==C)
                                s.at(i).at(j)=true;
                }
        for (int i=1; i<=H; i++)
                for (int j=1; j<=W; j++) {
                        if (!s.at(i).at(j)) continue;
                        if (s.at(i-1).at(j)) continue;
                        if (s.at(i+1).at(j)) continue;
                        if (s.at(i).at(j-1)) continue;
                        if (s.at(i).at(j+1)) continue;
                        cout <<"No" <<endl;
                        return 0;
                }
        cout <<"Yes" <<endl;
        return 0;
};

Measured memory_bytes: 256
(* unihernandez22
 * https://atcoder.jp/contests/abc139/tasks/abc139_a
 * implementation
 * *)

let rec count_eq s t i c =
    if i == String.length s then c
    else if s.[i] == t.[i] then count_eq s t (i+1) (c+1)
    else count_eq s t (i+1) c;;

Printf.printf "%d\n" @@
Scanf.scanf "%s\n%s\n" @@ fun s t ->
    count_eq s t 0 0;;
    



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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin >> n;
    map<string,int> m;
    loop(i,n){
        string str;
        cin >> str;
        m[str]++;
    }

    int mx = 0;
    for(pair<string,int> p : m){
        mx = max(mx , p.sc);
    }

    vector<string> ans;
    for(pair<string,int> p : m){
        if(p.sc == mx)
            ans.pb(p.fr);
    }

    sort(ALL(ans));
    for(auto str : ans)
        cout << str << endl;


    return 0;
}


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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    double d;
    cin >> d;
    double ans = sqrt(2)*d;
    ans = max(ans, (int)d+1.0);
    printf("%.10f\n", ans);
}



Measured memory_bytes: 3296
import sys
n = int(input())

works = []
for i in range(n):
    works.append(list(map(int, input().split())))
    
works.sort(key=lambda x: x[1])

time = 0
for a, b in works:
    time += a
    if b < time:
        print('No')
        sys.exit()

print('Yes')

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

int main(){
    using namespace std;
    unsigned long N, M, V, P;
    cin >> N >> M >> V >> P;
    --P;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    partial_sort(A.begin(), A.end() - P, A.end());
    A.erase(A.end() - P, A.end());
    N -= P;
    if(V <= P){
        cout << A.end() - lower_bound(A.begin(), A.end(), A.back() - min(A.back(), M)) + P << endl;
        return 0;
    }
    V -= P;
    vector<unsigned long> B(N);
    partial_sum(A.cbegin(), A.cend(), B.begin());
    const auto& check = [&N, &M, &V, &A, &B](unsigned long x) -> bool {
        return A[x] + M >= A.back() && (A[x] + M) * N >= B.back() - B[x] + M * V + A[x] * (x + 1);
    };
    auto L{0UL}, R{N};
    if(check(0))R = 0;
    while(L + 1 < R){
        auto m = (L + R) / 2;
        (check(m) ? R : L) = m;
    }
    cout << N - R + P << endl;
    return 0;
}

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

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

int p[51];

int main()
{
	int N, cnt = 0;
	bool ans = true;

	cin >> N;
	repc(i, 1, N) cin >> p[i];

	repc(i, 1, N) {
		if (p[i] == i) continue;

		cnt++;
		if (cnt >= 2) ans = false;

		if (p[p[i]] != i) ans = false;
		else {
			int tmp = p[i];
			p[i] = p[tmp];
			p[tmp] = tmp;
		}
	}

	cout << (ans ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int Wsum[n];
	int Esum[n];
	char s[n];
	int i;
	scanf("%s",&s);
	for(i=0;i<n;i++){
		Wsum[i] = 0;
		Esum[i] = 0;
	}
	
	if( s[0] =='E'){
		Esum[0] = 1;
		Wsum[0] = 0;
	}else{
		Esum[0] = 0;
		Wsum[0] = 1;
	}	
	for(i=1;i<n;i++){
		if(s[i]=='E'){
			Esum[i] += Esum[i-1]+1;
			Wsum[i] = Wsum[i-1];
		}else{
			Esum[i] = Esum[i-1];
			Wsum[i] = Wsum[i-1] + 1;
		}
	}
	int min = Esum[n-1]-Esum[0];
	for(i=1;i<n;i++){
		int cc = 0;
		cc += Wsum[i-1];
		cc += Esum[n-1] - Esum[i];
		if( min > cc ){
			min = cc;
		}
	}
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 2816
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>x;i--)
typedef long long ll;
using namespace std;

int main(){
    ll K;
    cin >> K;
    if (K%2==1){
        cout<<(K/2)*(K/2+1)<<endl;
        
    }
    else{
        cout<<(K/2)*(K/2)<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int H,W,C;
int tbl[10][10];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
bool visited[10][10];

void paint(int x,int y,int c){
  visited[y][x]=true;
  for(int i=0;i<4;++i){
    int mx = x+dx[i];
    int my = y+dy[i];
    if(mx>=W||my>=H||mx<0||my<0) continue;
    if(visited[my][mx]) continue;
    if(tbl[my][mx]==tbl[0][0]) paint(mx,my,c);
  }
  tbl[y][x]=c;
}

int calc(int x,int y){
  visited[y][x]=true;
  int ret = 1;
  for(int i=0;i<4;++i){
    int mx = x+dx[i];
    int my = y+dy[i];
    if(mx>=W||my>=H||mx<0||my<0) continue;
    if(visited[my][mx]) continue;
    if(tbl[my][mx]==tbl[0][0]) ret+=calc(mx,my);
  }
  return ret;
}

int solve(int depth){
  if(!depth){
    /*
    for(int i=0;i<H;++i){
      for(int j=0;j<W;++j) cout << tbl[i][j];
      cout << endl;
    }
    cout << endl;
    */    
    memset(visited,0,sizeof(visited));
    return calc(0,0);
  }
  int ret = 0;
  for(int i=1;i<=6;++i){
    if(depth==1&&i!=C) continue;
    int tmp[10][10];
    for(int y=0;y<H;++y) for(int x=0;x<W;++x) tmp[y][x]=tbl[y][x];
    memset(visited,0,sizeof(visited));
    paint(0,0,i);
    ret = max(ret,solve(depth-1));
    for(int y=0;y<H;++y) for(int x=0;x<W;++x) tbl[y][x]=tmp[y][x];    
  }
  return ret;
}

int main(){
  while(cin>>H>>W>>C,H||W||C){
    for(int i=0;i<H;++i)
      for(int j=0;j<W;++j) cin>>tbl[i][j];
    cout << solve(5) << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n)
	{
		int tmp;
		cin >> tmp;
		if (i % 2 == 0 && tmp % 2 == 1)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] array = new int[n];
        int[] ar = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = input.nextInt();
            ar[i] = array[i];
        }
        Arrays.sort(array);

        int i = 0, j = 0;
        int count = 0;
        while (i < array.length && j < array.length) {

            if (array[i] != ar[j]) {
                count++;
            }

            i++;
            j++;
        }
        if (count > 2) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int sum = a+b+c;
  if(sum >=22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

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

	ll ans = 1;

	if (t[n - 1] != a[0])ans *= 0;
	if (n >= 2) {
		if (a[0] > a[1] && t[0] != a[0])ans *= 0;
		if (t[n - 2] < t[n - 1] && t[n - 1] != a[n - 1])ans *= 0;
	}
	rep(i, n - 2) {
		if (t[i] < t[i + 1] && t[i + 1] > a[i + 1])ans *= 0;
		if (a[i + 1] > a[i + 2] && t[i + 1] < a[i + 1])ans *= 0;
		if (t[i] < t[i + 1] || a[i + 1] > a[i + 2])continue;
		ans *= min(t[i + 1], a[i + 1]);
		ans %= MOD;
	}

	cout << ans << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;

cin>>a>>b>>c>>d;

if(a*b>c*d){
    cout<<a*b;
}
else if(a*b<c*d){
    cout<<c*d;

}
else if((a*b)==(c*d)){
    cout<<a*b;
}
}

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

int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) {
        cout << S << '\n';
    } else {
        cout << S.substr(0, K) << "..." << '\n';
    }
    return 0;
}


Measured memory_bytes: 3604
#ifndef ONPC
  #define _FORTIFY_SOURCE 0
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("no-stack-protector")
  #pragma GCC optimize("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
  #pragma GCC optimize("fast-math")
#endif

#include <bits/stdc++.h>

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    int ans = n;
    int it = 0;
    n = n % k;
  	ans = min(n, ans);
    while (it < 1e6){
      n = abs(k - n);
      ans = min(ans, n);
      it++;
    }

    cout << ans << '\n';

    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int height[1000];
  height[1] = 1;
  for (int i = 2; i < 1000; i++){
    height[i] = height[i-1] + i;
    if (height[i-1] - a == height[i] - b){
      cout << height[i] - b << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())  # 標準入力
D = map(int, input().split())  # 嫌いな数字のリスト
D_str = list(map(str, D))
m = N
 
while True:
    for n in str(m):
        if n in D_str:
            break
    else: # breakされなかったら実行される
        print(m)
        break
    m += 1

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	int A, B; cin >> A >> B;
	int cnt[3] = {0};
	rep (i, N){
		int P; cin >> P;
		if (P <= A){
			++cnt[0];
		}else
		if (P >= A + 1 && P <= B){
			++cnt[1];
		}else
		if (P >= B + 1){
			++cnt[2];
		} // end rep
	} // end rep

	sort(cnt, cnt + 3);
	int res = cnt[0];
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
n = list(input())
def saiki(list_1,list_2,t): # 1 <= int t <= 3 
    for e in list_1:
        for b in [0,1]:
            if b == 0:
                list_2.append(e + "+" + n[t])
            elif b == 1:
                list_2.append(e + "-" + n[t])
    list_1.clear()
    if t < 3:
        return saiki(list_2,list_1,t+1)
    else:
        return list_2
list_1 = [n[0]]
list_2 = []
t = 1
list_3 = saiki(list_1,list_2,t)
for i in list_3:
    result = int(i[0])
    for j in [1,3,5]:
        if i[j] == "+":
            result += int(i[j+1])
        elif i[j] == "-":
            result -= int(i[j+1])
    if result == 7:
        print(i + "=7")
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	if(a+b > c+d) cout<<"Left" << endl;
	if(a+b== c+d) cout<<"Balanced"<<endl;
	if(a+b < c+d) cout<<"Right"<<endl;
	
	return 0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int T = sc.nextInt();
    int cnt = 1;
    int length = 0;
    for (int i = 0; i < N; i++) {
      length += sc.nextInt();
      if (length <= T) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
ll n; cin>>n;
ll x = n/100;
ll f = n%100;
if(x*5>=f) cout << 1 << endl;
else cout << 0 << endl;}

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

int main(){
	long long int h,w,n;
	cin>>h>>w>>n;
	
	map<int,map<int,int> > mp;
	
	vector<int> a(n);
	vector<int> b(n);
	
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		mp[a[i]][b[i]]++;
	}
	
	int tmp;
	
	map<int,map<int,int> > used;
	
	int x[]={-1,-1,-1,0,0,0,1,1,1};
	int y[]={-1,0,1,-1,0,1,-1,0,1};
	
	vector<int> ans(10,0);
	
	for(int i=0;i<n;i++){
		for(int j=0;j<9;j++){
			if(used[a[i]+x[j]][b[i]+y[j]]==0
				&&a[i]+x[j]>1
				&&b[i]+y[j]>1
				&&a[i]+x[j]<h
				&&b[i]+y[j]<w
			){
				tmp=0;
				for(int k=0;k<9;k++){
					tmp+=mp[a[i]+x[j]+x[k]][b[i]+y[j]+y[k]];
				}
				ans[tmp]++;
				used[a[i]+x[j]][b[i]+y[j]]=1;
			}
		}
	}
	
	long long int sum=0;
	for(int i=0;i<10;i++)sum+=ans[i];
	cout<<(h-2)*(w-2)-sum<<endl;
	for(int i=1;i<10;i++)cout<<ans[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 235392