akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
ll e10 = 1e10 + 10;
double EPS = 1e-10;
 
int main() {
	int N; cin >> N;
	vector<vector<int> > G(N);
	rep(i, N - 1) {
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	vector<int> d(N, -1);
	priority_queue<i_i, vector<i_i>, greater<i_i> > pq;
	int K; cin >> K;
	while (K--) {
		int v, p; scanf("%d%d", &v, &p);
		v--;
		d[v] = p;
		pq.push(i_i(p, v));
	}
	while (!pq.empty()) {
		i_i p = pq.top(); pq.pop();
		int u = p.second;
		for (int v: G[u])
			if (d[v] == -1) {
				d[v] = d[u] + 1;
				pq.push(i_i(d[v], v));
			}
	}
	rep(u, N)
		for (int v: G[u])
			if (abs(d[u] - d[v]) != 1) {
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;
	rep(u, N) printf("%d\n", d[u]);
}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define f0(i, a, n) for(i = a; i < n; i++)
#define f1(i, a, n) for(i = a; i <= n; i++)
#define tc(t) int t;cin >> t;while(t--)
#define ini(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define ll long long int
#define vi vector<int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define M 1e9+7
#define rr return 0
#define endl '\n'

using namespace std;

void solve() {
    ll n, d, i, x, y, cnt = 0;
    cin >> n >> d;
    f0(i, 0, n) {
        cin >> x >> y;
        if(ceil( sqrt( (x * x) + (y * y) ) ) <= d ) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

int main () {
    IOS;
    solve();
    rr;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;

	string s;
	cin >> s;
	s.push_back('Z');

	vector <int> v;
	int cnt = 1;
	for (int ii = 0; ii < n; ++ii){
		if (s[ii] != s[ii+1]){
			v.push_back(cnt);
			cnt = 1;
		} else {
			cnt++;
		}
	}

	int limit = v.size();
	int ans = v[0];
	int idx = 1;
	cnt = 0;
	while (idx < limit) {
		//1回目
		ans += v[idx];
		idx++;
		if (idx == limit){
			break;
		}
		//2回目
		ans += v[idx];
		idx++;
		if (idx == limit){
			break;
		}
		cnt++;
		if (cnt == k){
			break;
		}
	}
	ans--;

	for (int ii = idx; ii < limit; ++ii){
		ans += v[ii] - 1;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >> N;
  
  int A = 0;
  int B = 0;
  
  
  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());
  
  for (int i = 0; i < N; i++) {
    
    if(i % 2 == 0) {
      
      A = A + a.at(0);
      
      a.at(0) = 0;
      sort(a.begin(), a.end());
      reverse(a.begin(), a.end());
      
    }else if (i % 2 == 1) {
      
      B = B + a.at(0);
      
      a.at(0) = 0;
      
      sort(a.begin(), a.end());
      reverse(a.begin(), a.end());
    }
    
  }
  cout << A - B << endl;
  
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll X, Y;
    cin >> X >> Y;

    cout << X+Y/2 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
now = 0
temp = {}
ans = []
for _ in range(N):
    a = input()
    if now == 1 or now == 0:
        ans.append(a)
    try:
        temp[a] += 1
        if temp[a] > now:
            ans = [a]
            now = temp[a]
        elif temp[a] == now:
            ans.append(a)
    except:
        temp[a] = 1

ans.sort()
for v in ans:
    print(v)

Measured memory_bytes: 33416
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n,k; cin >> n >> k;
    vector<int> a(n);
    int index, minn, tmp;
    rep(i,n) {
        cin >> tmp;
        if (tmp == 1 ) {
            index = i;
        }
    }
    if (n <= k) {
        cout << 1 << endl;
        return 0;
    }
    cout << (n-2) / (k-1) + 1<< endl; 
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' ';pr(b);}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' ';pr(b,c);}
template<C T,C T2,C T3,C T4>void pr(T a,T2 b,T3 c,T4 d){cout<<a<<' ';pr(b,c,d);}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  priority_queue<P> que;
  rep(i,m) {
    int x;
    cin >> x;
    que.push(P(x,i));
  }
  int ans=0,k=-1;
  while(!que.empty()) {
    P p=que.top();que.pop();
    if(k==p.S) {
      if(!que.empty()) {
        P q=que.top();que.pop();
        q.F--;p.F--;
        k=p.S;
        if(p.F) que.push(p);
        if(q.F) que.push(q);
      } else {
        ans++;
        p.F--;
        if(p.F) que.push(p);
      }
    } else {
      p.F--;
      k=p.S;
      if(p.F) que.push(p);
    } 
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 256
# Problem D - RGB Triplets

# input
N = int(input())
S = list(input())

# initialization
r_count = 0
g_count = 0
b_count = 0
exception_count = 0

# a, b, c count
for i in range(N):
    if S[i]=='R':
        r_count += 1
    elif S[i]=='G':
        g_count += 1
    elif S[i]=='B':
        b_count += 1
ans_1 = r_count * g_count * b_count

# exception count
for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2 * j - i
        if k>=N:
            continue
        if not S[i]==S[j] and not S[j]==S[k] and not S[i]==S[k]:
            exception_count += 1

# output
ans = ans_1 - exception_count
print(ans)


Measured memory_bytes: 9200
class Node
  attr_reader :id
  attr_accessor :parent
  protected :parent=

  def initialize(id)
    @id = id
    @children = []
  end

  def children
    @children.to_enum
  end

  def add_child(child)
    @children << child
    child.parent = self
  end

  def type
    if @parent.nil?
      'root'
    elsif @children.empty?
      'leaf'
    else
      'internal node'
    end
  end

  def depth
    if frozen?
      @depth
    else
      _depth
    end
  end

  private def _depth
    @parent.nil? ? 0 : @parent.depth + 1
  end

  def parent_id
    @parent.nil? ? -1 : @parent.id
  end

  alias_method :_freeze, :freeze
  private :_freeze

  # Freeze from its root to its all leaves.
  def freeze
    return @parent.freeze if @parent
    freeze_self_and_children
  end

  protected def freeze_self_and_children
    @depth = _depth
    _freeze
    @children.freeze
    @children.each { |child| child.freeze_self_and_children }
  end
end

class NodeRepository
  include Enumerable

  def initialize
    @store = {}
  end

  def each(&block)
    Enumerator.new do |y|
      @store.sort.each { |kv| y << kv }
    end.each(&block)
  end

  def [](id)
    @store[id] ||= Node.new(id)
  end
end
repo = NodeRepository.new

n = gets.chomp.to_i
n.times do
  id, _, *child_ids = gets.chomp.split(' ').map(&:to_i)
  parent = repo[id] # To create a node when children is none.
  child_ids.each { |c_id| parent.add_child(repo[c_id]) }
end

repo.first[1].freeze

repo.each do |_, node|
  puts "node #{node.id}: parent = #{node.parent_id}, " +
       "depth = #{node.depth}, #{node.type}, " +
       "[#{node.children.map(&:id).join(', ')}]"
end



Measured memory_bytes: 44112
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

N=10**9 + 7
n,K=sep()
s=0
for k in range(K,n+2):
    s= (s + (k*(n-k+1))%N + 1)%N
print(s)




Measured memory_bytes: 63364
n = int(input())
i = input()

i = i.split()
for item in range(len(i)):
    i[item] = int(i[item])

totn = 0
totp = 0

countp = 0
countn = 0

for x in range(len(i)):
    totp += i[x]
    totn += i[x]

    if x %2 == 1:
        if totn == 0:
            countn += 1
            totn = 1
        elif totn < 0:
            countn += abs(totn) + 1
            totn = 1

        if totp == 0:
            countp += 1
            totp = -1
        elif totp > 0:
            countp += abs(totp) + 1
            totp = -1

    if x %2 == 0:
        if totn == 0:
            countn += 1
            totn = -1
        elif totn > 0:
            countn += abs(totn) + 1
            totn = -1

        if totp == 0:
            countp += 1
            totp = 1
        elif totp < 0:
            countp += abs(totp) + 1
            totp = 1

count = min(countn, countp)
print(count)

Measured memory_bytes: 11652
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dre_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dre_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	while(1){
		int n,m;
		/*static*/ vector<P1> G[10010];
		
		scanf("%d%d",&n,&m); if(n==0&&m==0)break;
		rep(i,m){
			int u,v,d,c;
			scanf("%d%d%d%d",&u,&v,&d,&c);
			G[u].pb(mp1(v,d,c));
			G[v].pb(mp1(u,d,c));
		}
		
		/*static*/ int d[10010]; rep(i,10010)d[i]=INF; d[1]=0;
		/*static*/ bool used[10010]; rep(i,10010)used[i]=false;
		rpque(P) que; que.push(P(0,1));
		vector<int> cost[10010];
		
		while(!que.empty()){
			P p=que.top(); que.pop();
			if(!used[p.sc]){
				rep(i,G[p.sc].size()){
					P1 ed=G[p.sc][i];
					if(d[ed.fr]>d[p.sc]+ed.sc.fr){
						d[ed.fr]=d[p.sc]+ed.sc.fr;
						que.push(P(d[ed.fr],ed.fr));
						cost[ed.fr].clear();
						cost[ed.fr].pb(ed.sc.sc);
					}
					else if(d[ed.fr]==d[p.sc]+ed.sc.fr){
						cost[ed.fr].pb(ed.sc.sc);
					}
				}
				used[p.sc]=true;
			}
		}
		
		int ret=0;
		for(int i=2;i<=n;i++){
			int ans=INF;
			rep(j,cost[i].size()){
				ans=min(ans,cost[i][j]);
			}
			ret+=ans;
		}
		
		cout<<ret<<endl;
	}
}

Measured memory_bytes: 2752
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n-1];
        for (int i = 0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0;i<n;i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0;i<n-1;i++) {
            c[i] = sc.nextInt();
        }

        int ans = 0;
        for (int  i= 0;i< n;i++) {
            ans += b[a[i]-1];
            //System.out.println(ans);
            
            if (i> 0 && a[i] - a[i-1] == 1) {
              //System.out.println(c[a[i-1]-1]);
              ans += c[a[i-1]-1];
            }
            
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 28 21:42:33 2016

@author: you
"""

n = int(input())
a = list(map(int, input().split()))
colornum = 0
colorflag = [0,0,0,0,0,0,0,0]
rainbow = 0
maxvalue = 0
minvalue = 0
for i in range(n):
    if colorflag[0] == 0 and a[i] < 400:
        colornum = colornum + 1
        colorflag[0] = 1
    elif colorflag[1] == 0 and a[i] >= 400 and a[i] < 800:
        colornum = colornum + 1
        colorflag[1] = 1
    elif colorflag[2] == 0 and a[i] >= 800 and a[i] < 1200:
        colornum = colornum + 1
        colorflag[2] = 1
    elif colorflag[3] == 0 and a[i] >= 1200 and a[i] < 1600:
        colornum = colornum + 1
        colorflag[3] = 1
    elif colorflag[4] == 0 and a[i] >= 1600 and a[i] < 2000:
        colornum = colornum + 1
        colorflag[4] = 1
    elif colorflag[5] == 0 and a[i] >= 2000 and a[i] < 2400:
        colornum = colornum + 1
        colorflag[5] = 1
    elif colorflag[6] == 0 and a[i] >= 2400 and a[i] < 2800:
        colornum = colornum + 1
        colorflag[6] = 1
    elif colorflag[7] == 0 and a[i] >= 2800 and a[i] < 3200:
        colornum = colornum + 1
        colorflag[7] = 1
    elif a[i] >= 3200:
        rainbow = rainbow + 1
for j in range(8):
    if colorflag[j] == 1:
        minvalue = minvalue + 1
maxvalue = minvalue + rainbow
if minvalue == 0:
    minvalue = 1
    maxvalue = rainbow
print(minvalue,maxvalue)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n, m);
	vector<int> h(n), ans(n);
	cin >> h;
	inc(i, m) {
		IN(int, a, b);
		a--; b--;
		if(h[a] <= h[b]) { ans[a] = 1; }
		if(h[b] <= h[a]) { ans[b] = 1; }
	}
	OUT(count(ALL(ans), 0));
}


Measured memory_bytes: 4048
import sys
sys.setrecursionlimit(300000)

H, W = map(int, input().split())
S = [input() for y in range(H)]
visited = [[False] * W for y in range(H)]

def color(y, x):
    if y < 0 or H <= y or x < 0 or W <= x or visited[y][x]:
        return "@"
    else:
        return S[y][x]


def dfs(y, x):
    b = 0
    w = 0
    nxt = "n"
    if color(y, x) == ".":
        w = 1
        nxt = "#"
    elif color(y, x) == "#":
        b = 1
        nxt = "."
    
    visited[y][x] = True
    if color(y - 1, x) == nxt:
        _b, _w = dfs(y - 1, x)
        b += _b
        w += _w
    if color(y + 1, x) == nxt:
        _b, _w = dfs(y + 1, x)
        b += _b
        w += _w
    if color(y, x - 1) == nxt:
        _b, _w = dfs(y, x - 1)
        b += _b
        w += _w
    if color(y, x + 1) == nxt:
        _b, _w = dfs(y, x + 1)
        b += _b
        w += _w

    return (b, w)

    
ans = 0
for y in range(H):
    for x in range(W):
        b, w = dfs(y, x)
        ans += b * w

print(ans)

Measured memory_bytes: 138704
#include <bits/stdc++.h>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;

long long n, ans;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	long long p[n];
	REP(i, 0, n) cin >> p[i];
	sort(p, p + n, greater<long long>());
	ans += p[0];
	n -= 2;
	long long i = 1, t = n/2;
	while (i <= t) {
		ans += p[i] * 2;
		i++;
	}
	if (n % 2) ans += p[i];
	cout << ans;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, M;
int L[110000], R[110000], imos[110000];

signed main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        imos[L[i]]++;
        imos[R[i] + 1]--;
    }
    for (int i = 1; i <= N; i++)imos[i] += imos[i - 1];
    int ans = 0;
    for (int i = 1; i <= N; i++)if (imos[i] == M)ans++;
    cout << ans << endl;

}

Measured memory_bytes: 2560
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main()
{
	string s;
	cin >> s;
	int n = s.length();
	if(s[n-1] == 's') s+="es";
	else s+="s";
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

def make_divisors(n):
   divisors = []
   for i in range(1, int(n**0.5)+1):
       if n % i == 0:
           divisors.append(i)
           if i != n // i:
               divisors.append(n//i)
   divisors.sort(reverse=True)
   return divisors
x = M // N
l = make_divisors(M)
# print(l)
for i in l:
    if i <= x:
        print(i)
        break

Measured memory_bytes: 5388
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(){
    int n;
    cin>>n;
string s;
cin>>s;
int cnt=0,m=0;
for (int i=0;i<n;i++){
    if (s[i]=='I')
        cnt++;
        if (cnt>m)
            m=cnt;
   if (s[i]=='D')
        cnt--;


}
cout<<m<<endl;
return 0;
}


Measured memory_bytes: 256
#H = int(input())
H,N = list(map(int,input().split()))
#H = sorted(list(map(int,input().split())))
AB = [list(map(int,input().split())) for i in range(N)]
dp = [float('inf') for i in range(H)]
dp[0] = 0
for i in range(N):
    for j in range(H):
        if j-AB[i][0] >= 0:
            dp[j] = min(dp[j],dp[j-AB[i][0]]+AB[i][1])
ans = float('inf')
for i in range(N):
    for j in range(max(0,H-AB[i][0]),H):
        if dp[j] != float('inf') and j+AB[i][0] >= H:
            ans = min(ans,dp[j]+AB[i][1])
print(ans)

Measured memory_bytes: 50908
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 100000 + 10;
int res[120*120];
int a[120*120];
int h,w,n;

int ne(int p) {
    int r = p / w;
    int c = p % w;
    if (r % 2 == 0) {
        if (c < w-1) return p+1;
        return p+w;
    } else {
        if (c == 0) return p + w;
        return p - 1;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin >> h >> w >> n;

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

    int p = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < a[i]; j++)
            res[p] = i, p = ne(p);
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << res[i*w + j] + 1 << " ";
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}



Measured memory_bytes: 3096
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	In := ReadLineInt()
	PerSocket, Goal := In[0], In[1]

	Current := 1
	Result := 0
	for {
		if Current >= Goal {
			break
		}
		Result++
		Current--
		Current += PerSocket
	}

	fmt.Println(Result)
}

/////////////////////////////////////////

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}


Measured memory_bytes: 640
Q,H,S,D=map(int,input().split())
N=int(input())
print((N//2)*min(Q*8, H*4, S*2, D)) if N%2==0 else print(((N-1)//2)*min(Q*8, H*4, S*2, D)+min(Q*4, H*2, S))


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

struct data {
  int p;
  string s;
};

bool operator<(const data &l, const data &r) {
  if(l.s != r.s) return l.s > r.s;
  return l.p < r.p;
}

int n, a, s, g;
string dummy;
vector<vector<string>> dist;
vector<data> edge[50];
priority_queue<data> pq;

string solve();

int main() {
  dummy += 'z' + 1;
  while(1) {
    cin >> n >> a >> s >> g;
    if(n + a + s + g == 0) break;
    for(int i = 0; i < a; ++i) {
      int x, y;
      string st;
      cin >> x >> y >> st;
      edge[x].push_back({y, st});
    }
    dist.assign(n, vector<string>(500, dummy));
    cout << solve() << endl;
    for(int i = 0; i < n; ++i)
      edge[i].erase(edge[i].begin(), edge[i].end());
  }
  return 0;
}

string solve() {
  pq.push({s, ""});
  dist[s][0] = "";
  while(pq.size() > 0) {
    data now = pq.top();
    pq.pop();
    if(dist[now.p][now.s.size()] < now.s) continue;
    for(int i = 0; i < edge[now.p].size(); ++i) {
      data nextp = now;
      nextp.p = edge[now.p][i].p;
      nextp.s += edge[now.p][i].s;
      if(nextp.s.size() >= 500) continue;
      if(dist[nextp.p][nextp.s.size()] > nextp.s) {
        dist[nextp.p][nextp.s.size()] = nextp.s;
        pq.push(nextp);
      }
    }
  }
  string ans = dummy;
  for(int i = 0; i < 500; ++i) ans = min(ans, dist[g][i]);
  if(ans == dummy || ans.size() > 240) return "NO";
  return ans;
}


Measured memory_bytes: 25032
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  int a[10]={},n,ans=0;
  std::cin >> n;

  for(int i=0; i<n; i++){
    int p; std::cin >> p;
    if(p<=399) a[0]=1;
    else if(p<=799) a[1]=1;
    else if(p<=1199) a[2]=1;
    else if(p<=1599) a[3]=1;
    else if(p<=1999) a[4]=1;
    else if(p<=2399) a[5]=1;
    else if(p<=2799) a[6]=1;
    else if(p<=3199) a[7]=1;
    else  a[8]++;
  }

  for(int i=0; i<8; i++){
    ans+=a[i];
  }
  if(ans==0) std::cout << "1" << ' ';
  else std::cout << ans << ' ';

  std::cout << ans+a[8] << '\n';

  return 0;
}


Measured memory_bytes: 256
// ※※※ 解答不能 ※※※
// square1001氏.
// https://atcoder.jp/contests/code-festival-2016-qualc/submissions/1304529
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int H, W, cost[309][309], dp[309][309]; char s[309][309];
int main(){
    scanf("%d %d", &H, &W);
    rep(i, H) scanf("%s", s[i]);
    int ret = 0;
    repx(i, 1, W){
        rep(j, H) rep(k, H) cost[j + 1][k + 1] = cost[j][k] + (s[j][i - 1] == s[k][i] ? 1 : 0);
        rep(j, H + 1){
            rep(k, H + 1){
                dp[j][k] = (j ? dp[j - 1][k] + cost[j][k] : (k ? 1012345678 : 0));
                if(k) dp[j][k] = min(dp[j][k], dp[j][k - 1] + cost[j][k]);
            }
        }
        ret += dp[H][H];
    }
    printf("%d\n", ret);
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 21:31:49 2020

@author: NEC-PCuser
"""
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr


if __name__ == "__main__":
    N = int(input())
    if N == 1:
        print(0)
    else:
        b = factorization(N)
        ans = 0
        for i in range(0, len(b)):
            j = 1
            while b[i] - j >= 0:
                b[i] = b[i] - j
                j += 1
                ans += 1
        print(ans)
                
            
    

Measured memory_bytes: 9484
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
# print(max(c.values()))
ans = []
w = max(c.values())
for k, v in sorted(c.items()):
    if v == w:
        ans += [k]
# print(ans)
# print(sorted(ans))
for i in ans:
    print(i)

Measured memory_bytes: 46832
parseInt(x) = parse(Int,x)

parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    A = readline() |> split |> parseMap
    sort!(A)
    if A[1]==5 && A[2]==5 && A[3]==7
        println("YES")
    else
        println("NO")
    end
end

main()


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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLineInt();

            Console.WriteLine(Math.Ceiling(s*1.0 / 2));
            ReadLine();
        }

        /// <summary>
        /// コンビネーション
        /// </summary>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13140
/*#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
int i,j,m,n,ans=0,l;
static int r[2001][2001][2]={0};
char s[4001],t[4001];
scanf("%d%d",&m,&n);
scanf("%s",s);
scanf("%s",t);
for(i=0;i<=m;i++){
for(j=0;j<=n;j++){
for(l=0;l<2;l++){
if(l==0){
if(s[i]=='I')
r[i+1][j][1]=max(r[i+1][j][1],r[i][j][0]+1);
if(t[j]=='I')
r[i][j+1][1]=max(r[i][j+1][1],r[i][j][0]+1);
}
else{
if(s[i]=='O'&&r[i][j][1]!=0)
r[i+1][j][0]=max(r[i+1][j][0],r[i][j][1]+1);
if(t[j]=='O'&&r[i][j][1]!=0)
r[i][j+1][0]=max(r[i][j+1][0],r[i][j][1]+1);
}
}
}
}
for(i=0;i<=m;i++){
for(j=0;j<=n;j++){
ans=max(ans,r[i][j][1]);
}
}
printf("%d\n",ans);
return 0;
}
*/
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n,i,l=-1,r,ans=0,u=0;
static int ilm[1000001]={0};
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&r);
if(r!=l){
ilm[u]++;
l=r;
}
else{
u++;
ilm[u]++;
l=r;
}
}
if(u<3){
for(i=0;i<=u;i++)
ans+=ilm[i];
}
for(i=0;i<u-1;i++)
ans=max(ans,ilm[i]+ilm[i+1]+ilm[i+2]);
printf("%d\n",ans);
return 0;
}



Measured memory_bytes: 3392
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
#include<numeric>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
        int n;
        cin >> n;
        string s[2];
        cin >> s[0] >> s[1];

        ll count = 3;
        int i = 0;
        char c = s[0][0];
        if (s[0][1] == c) { // 一番左が横
                s[0][1] = '0';
                count *= 2;
                i = 2;
        } else {
                s[1][0] = '0';
                i = 1;
        }
        s[0][0] = '0';

        // s0についてだけみる
        for (; i < n; i++) {
                char x = s[0][i];

                if (s[1][i] == x) { // 自分が縦棒
                        if (s[0][i-1] == s[1][i-1]) { // 左に縦棒
                                count *= 2;
                                count = count % 1000000007;
                        } else {
                                // 何もしない
                        }
                        s[0][i] = '0';
                        s[1][i] = '0';
                } else { // 自分が横棒
                        if (s[0][i-1] == s[1][i-1]) { // 左に縦棒
                                count *= 2;
                                count = count % 1000000007;
                        } else {
                                count *= 3;
                                count = count % 1000000007;
                        }
                        s[0][i] = '0';
                        s[0][i+1] = '0';
                        i++;
                }
        }
        cout << count << endl;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main () {
  long long N, K;
  cin >> N >> K;
  if (K % 2) {
    N /= K;
    long long kj = N * N * N;
    cout << kj << endl;
  }
  else {
    K /= 2;
    N /= K;
    long long a = N / 2;
    long long b = (N + 1) / 2;
    long long c = (long long)a * a * a;
    long long d = (long long)b * b * b;
    cout << c + d << endl;
  }
}



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



  
int main(){
  

  int64_t x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  
  vector<pair<int64_t,string>> data(a+b+c);

  
  for (int64_t i=0;i<a;i++){
    pair<int64_t,string> tmp;
    int64_t pi;
    cin>>pi;
    tmp=make_pair(pi,"red");
    data.at(i)=tmp;
  }
  
    for (int64_t i=0;i<b;i++){
    pair<int64_t,string> tmp;
    int64_t pi;
    cin>>pi;
    tmp=make_pair(pi,"green");
    data.at(a+i)=tmp;
  }
  
    for (int i=0;i<c;i++){
    pair<int,string> tmp;
    int64_t pi;
    cin>>pi;
    tmp=make_pair(pi,"no");
    data.at(a+b+i)=tmp;
  }
  
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  
  int64_t redcount=0;
  int64_t greencount=0;
  int64_t totalcount=0;
  int64_t answer=0;
  int64_t i=0;

  while (totalcount<x+y){
    if (data.at(i).second=="red"){
      if (redcount<x){
        answer+=data.at(i).first;
        redcount++;
        totalcount++;
          
      }
    }
    
    else if (data.at(i).second=="green"){
      if (greencount<y){
        answer+=data.at(i).first;
        greencount++;
        totalcount++;
      }
    }
    
    else {
      answer+=data.at(i).first;
      totalcount++;
    }
    
    i++;
    
  }
  
  cout<<answer<<endl;
  
  

    
  
 
  
}

    













Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
#define FIND(c, e) ((c).find(e) != (c).end())
#define NFIND(c, e) ((c).find(e) == (c).end())
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
template<class T> inline T max(T a,T b,T c){return max(max(a,b),c);}
template<class T> inline T min(T a,T b,T c){return min(min(a,b),c);}
const int  MOD = int( 1e9 ) + 7;
const int    N = int( 1e5 ) + 42;
const int LOGN = ceil(log(N) / log(2));
const double EPS = 1e-6;


void __answer()
{
    long long n, d, x, y, ans = 0;
    cin >> n >> d;
    for(int i = 0; i < n; ++i) {
        cin >> x >> y;
        ans += sqrt(x * x + y * y) <= d;
    }
    cout << ans << '\n';
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cout << setprecision(11) << fixed;
    #ifdef LOCAL
        freopen("TEST.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<string.h>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstdlib>
#include<vector>
#include<set>
#include<deque>
#include<queue>
#include<math.h>
#include<chrono>
#include<list>
#include<random>
#include<bitset>
#include<assert.h>
#include<ctime>
#include<cstdio>
#include <unordered_map>
using namespace std;
ifstream fi("zinput.txt");
ofstream fo("output.txt");
#define fast_input() {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
#define ll long long
#define For(i,n) for (int(i) = 0; (i)< (int)(n); (i)++)
#define For1(i,n) for (int(i) = 1; (i) <= (int)(n); (i)++)
#define Forlr(i,l,r) for (int(i) = (int)(l); (i) <= (int)(r); (i)++)
#define Forrl(i,r,l) for (int(i) = (int)(r); (i) >= (int)(l); (i)--)
#define all(a) a.begin(), a.end() 
#define pb push_back
#define pp pop_back
#define mp make_pair
#define PI 3.14159265
#define putno return cout <<"NO", 0;
#define putyes return cout <<"YES", 0;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef map<int, int> mii;
//const ll MOD = 1e9 + 7;
const int N = 1e5 + 5;
//DSU
/*
int p[ N], r[N];
void init(int n) {
	For(i, n) {
		p[i] = i;
	}
}
int get(int x) {
	if (p[x] != x) {
		p[x] = get(p[x]);
	}
	return p[x];
}
bool uni(int x, int y) {
	x = get(x); y = get(y);
	if (x == y) {
		return false;
	}
	if (r[x] >= r[y]) {
		p[y] = x;
	}
	else {
		p[x] = y;
	}
	if (r[x] == r[y]) {
		r[x]++;
	}
	return true;
}
*/

// So mu
/*
int power(int x, unsigned int y, int p)
{
	int res = 1; // Initialize result

	x = x % p; // Update x if it is more than or
	// equal to p

	while (y > 0)
	{
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res*x) % p;

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x*x) % p;
	}
	return res;
}
*/

// ReadHexa
/*
bitset<16400> b[4101];
void readHexa()
{
	For(i, n)
	{
		string st;
		cin>> st;
		For(j, m/4)
		{
			int x;
			if (st[j] >= 'A' && st[j] <= 'F')
				x = st[j] - 'A' + 10;
			else x = st[j] - '0';
			for (int k = 4; k; --k, x >>= 1)
				b[i][j * 4 + k] = x & 1;
		}
	}
}
*/

// nChoosek
/*
ll nChoosek(ll n, ll k)
{
	if (k > n) return 0;
	if (k * 2 > n) k = n - k;
	if (k == 0) return 1;

	ll result = n;
	for (ll i = 2; i <= k; ++i) {
		result *= (n - i + 1);
		result /= i;
	}
	return result;
}
*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
MIKUNO - 15/02/1999
*/
int n, m, k, cnt, rs, q;
int x, y;
//	priority_queue <ll, vector<ll>, greater<ll> > q;
//ll n, m, q, k, pos, t, cnt, rs1, check;
ll maxx = -1e9, minn = 1e9;
int ma = -1e9, mi = 1e9;
const int maxn = 2*N;
const ll MOD = 1e9 + 7;
string s;
int t1, t0;
int main()
{
	fast_input();
	cin >> n >> k;
	cin >> s;
	int t = 0;
	vector<pii> a;
	a.pb(mp(0, 0));
	For(i, s.length())
	{
		if (s[i] == '1')
		{
			t = i;
			while ( i < s.length() && s[i] == '1') i++;
			a.pb(mp(t, i - 1));
		}
	}
	a.pb(mp(n - 1, n - 1));
	if (a.size() <= k) cout << n;
	else
	{


		int rs = 0;
		for (int i = 0; i + k < a.size(); i++)
		{
			rs = max(rs, a[i + k].second - a[i].first + 1);
		}
		cout << rs;
	}
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define LLI long long int

const int _mx = 2e6;
int a[_mx + 5];

int main()
{
    // freopen("in.txt", "r", stdin);
    string s;
    LLI a, b, n, ans;
    stack<LLI> st;
    while (cin >> s)
    {
        if (s[0] == '+')
        {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(a + b);
        }
        else if (s[0] == '-')
        {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(b - a);
        }
        else if (s[0] == '*')
        {
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(a * b);
        }
        else
        {
            n = s[0] - '0';
            for (int j = 1; j < s.size(); j++)
                n = n * 10 + (s[j] - '0');
            st.push(n);
        }
    }
    cout << st.top() << endl;

    return 0;
}



Measured memory_bytes: 3216
import Data.Bits
import Data.List
import Control.Monad
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Control.Monad.ST
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy.Char8 as B
import Debug.Trace

main :: IO ()
main = do
  [x,a] <- map read.words <$> getLine :: IO [Int]
  print $ if x < a then 0 else 10


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(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,M,S,T;
bool dp[201][201][10];
const int K=9;

struct state{
  int u,v,j;
};

int merge(int j1,int j2){
  if((j1==0&&j2==1)||(j1==5&&j2==2)||(j1==7&&j2==3))return 0;
  if(j1==4&&j2==0)return 1;
  if(j1==0&&j2==6)return 2;
  if(j1==0&&j2==8)return 3;
  return -1;
}

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

  while(1){
    scanf("%d%d%d%d",&N,&M,&S,&T);
    if(N==0)break;
    S--;T--;
    rep(i,N)rep(j,N)rep(k,K)dp[i][j][k]=false;
    queue<state> que;
    rep(i,M){
      int a,b;
      char c;
      scanf("%d %d %c",&a,&b,&c);
      a--;b--;
      if(c=='+'||c=='*'){
        dp[a][b][4]=true;
        que.push((state){a,b,4});
      }else if(c=='('){
        dp[a][b][5]=true;
        que.push((state){a,b,5});
      }else if(c==')'){
        dp[a][b][6]=true;
        que.push((state){a,b,6});
      }else if(c=='['){
        dp[a][b][7]=true;
        que.push((state){a,b,7});
      }else if(c==']'){
        dp[a][b][8]=true;
        que.push((state){a,b,8});
      }else{
        dp[a][b][0]=true;
        que.push((state){a,b,9});
      }
    }

    while(que.size()){
      int u=que.front().u,v=que.front().v,j=que.front().j; que.pop();
      rep(x,N)rep(k,K){
        if(dp[x][u][k]){
          int nj=merge(k,j);
          if(nj==-1||dp[x][v][nj])continue;
          dp[x][v][nj]=true;
          que.push((state){x,v,nj});
        }
        if(dp[v][x][k]){
          int nj=merge(j,k);
          if(nj==-1||dp[u][x][nj])continue;
          dp[u][x][nj]=true;
          que.push((state){u,x,nj});
        }
      }
    }
    if(dp[S][T][0]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  return 0;
}



Measured memory_bytes: 5996
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

score = 0
flag = [0] * N

for i in range(N):
    if i < K:
        if T[i] == 'r':
            score = score + P
            flag[i] = 1
        elif T[i] == 's':
            score = score + R
            flag[i] = 1
        else:
            score = score + S
            flag[i] = 1
    elif i >= K:
        if T[i] == T[i - K] and flag[i - K] == 1:
            score = score
        elif T[i] == 'r':
            score = score + P
            flag[i] = 1
        elif T[i] == 's':
            score = score + R
            flag[i] = 1
        else:
            score = score + S
            flag[i] = 1

print(score)

Measured memory_bytes: 4084
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio> 
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rangeRep(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
struct Node
{
	int x, y, turn;
};
class Solve {
public:
	Solve() {};
	~Solve() {};

	void solver() {
		std::vector<int> results;
		std::array<std::array<int, 121>, 121> field;
		while (1) {
			int t, n;
			int startX, startY;
			field = { {0} };
			std::cin >> t >> n;
			if (!t && !n) break;

			//Setting obstacles
			rep(i, n) {
				int x, y;
				std::cin >> x >> y;
				field[y + 60][x + 60] = 1;
			}
			std::cin >> startX >> startY;
			field[startY + 60][startX + 60] = 1;

			//Breadth-first search
			std::queue<Node> q; //Remember coordinates
			int discoverdCount = 1;
			q.push(Node{ startX+60, startY+60, 0 });
			int dx[] = {1, 0, -1, -1, 0, 1};
			int dy[] = {0, -1, -1, 0, 1, 1};
			while (!q.empty()) {
				auto now = q.front(); q.pop();

				rep(i, 6) {
					auto next = now;
					next.x += dx[i]; next.y += dy[i]; next.turn++;

					//out of range
					if (next.x < 0 || next.x > 120 || next.y < 0 || next.y > 120) {
						continue;
					}
					//obstacle or discovered
					if (field[next.y][next.x]) {
						continue;
					}
					//OK
					discoverdCount++;
					field[next.y][next.x] = 1;
					//turn is over
					if (next.turn >= t) continue;
					q.push(next);
				}
			}
			results.push_back(discoverdCount);
		}

		for (auto& x : results) {
			std::cout << x << std::endl;
		}
	}
private:

};

int main() {
	Solve solve;
	solve.solver();
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    vll accum(n);
    accum[0] = a[0];
    REP(i,n) accum[i] = accum[i-1]+a[i];
    ll ans = inf_l;
    for (int i = 1; i <= n-1; i++) {
        ans = min(ans,abs(accum[i-1]-(accum[n-1]-accum[i-1])));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <string>
#define SIZE 200005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE];
int B[SIZE];
int n,sz;

bool check(int x)
{
	set <P> st;
	for(int i=0;i<sz;i++)
	{
		if(A[i]>=x) B[i]=1;
		else B[i]=0;
	}
	for(int i=0;i+2<sz;i++)
	{
		if(B[i]==B[i+1]) continue;
		if(B[i+2]==B[i+1]) continue;
		//B[i]!=B[i+1],B[i+1]!=B[i+2]
		int s=i;
		while(s+1<sz&&B[s+1]!=B[s]) s++;
		//i,i+1,i+2,...,s はギザギザ
		if((s-i+1)%2==0)
		{
			for(int j=i+1;j<s;j++)
			{
				if(j-i<s-j) B[j]=B[i];
				else B[j]=B[s];
			}
		}
		else
		{
			for(int j=i+1;j<s;j++) B[j]=B[i];
		}
		i=s;
	}
	return B[n-1]==1;
}
int main()
{
	scanf("%d",&n);
	sz=2*n-1;
	for(int i=0;i<sz;i++) scanf("%d",&A[i]);
	int l=0,r=sz+1;
	while(r-l>1)
	{
		int m=(l+r)/2;
		if(check(m)) l=m;
		else r=m;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 1920
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;

typedef long long ll ;
typedef long double ld ;


#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = ( int ) 1e5 + 10 ;

int n , a [ N ] , m , pos [ N ] , root [ N ] , comp = 1 ;  
vector < int > adj [ N ] ;
bool mark [ N ] ; 

void dfs ( int v ) {
	if ( mark [ v ] ++ ) return ;
	root [ v ] = comp ;
	for ( int u : adj [ v ] )
		dfs ( u ) ; 
}

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m ;
	for ( int i = 1 ; i <= n ; ++ i )
		cin >> a [ i ] ;
	for ( int j = 0 ; j < m ; ++ j ) {
		int u , v;
		cin >> u >> v ;
		adj [ u ] . push_back ( v ) ;
		adj [ v ] . push_back ( u ) ; 
	}
	for ( int i = 1 ; i <= n ; ++ i )
		if ( !mark [ i ] )
			dfs ( i ) , comp ++ ;
	for ( int i = 1 ; i <= n ; ++ i )
		pos [ a [ i ] ] = i ;
	int res = 0 ; 
	for ( int i = 1 ; i <= n ; ++ i ) {
		res += root [ i ] == root [ pos [ i ] ] ; 
	}
	cout << res << '\n' ; 
}


Measured memory_bytes: 10240