akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int x, a;
  cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;
typedef long double ld;
#define inf 1e18


llint a,b,c;
void solve(){
	cin >> a >> b >> c;
  llint d=c-a-b;
  if(d>0 && d*d>4*a*b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
A=[]
B=[]
a=0
i=0
for c in input():
 if"\\"==c:
  A+=[i]
 elif"/"==c and A:
  j=A.pop()
  t=i-j
  a+=t
  while B and B[-1][0]>j:
   t+=B[-1][1];B.pop()
  B+=[(j,t)]
 i+=1
print(a)
if B:print(len(B),*list(zip(*B))[1])
else:print(0)


Measured memory_bytes: 6500
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        """
        :param int size:
        """
        self._bit = [0] * size
        self._size = size

    def add(self, i, w):
        """
        i 番目に w を加える
        :param int i:
        :param int w:
        """
        x = i + 1
        while x <= self._size:
            self._bit[x - 1] += w
            x += x & -x

    def sum(self, i):
        """
        [0, i) の合計
        :param int i:
        """
        ret = 0
        while i > 0:
            ret += self._bit[i - 1]
            i -= i & -i
        return ret

    def __len__(self):
        return self._size


def median(A):
    return list(sorted(A))[len(A) // 2]


def test(A):
    N = len(A)
    M = []
    for l in range(N):
        for r in range(l + 1, N + 1):
            M.append(median(A[l:r]))
    print(median(M))


def less_than(k):
    arr = [0] * (N + 1)
    for i, b in enumerate(B):
        arr[i + 1] = 1 if b >= k else -1
    cum = cumsum(arr)
    base = min(cum)
    for i in range(len(cum)):
        cum[i] -= base

    # 中央値が k より小さくなる [l, r] の数
    # →[l, r] の総和がマイナスになる組み合わせの数
    # →転倒数
    bit = BinaryIndexedTree(size=max(cum) + 1)
    count = 0
    for i, c in enumerate(cum):
        count += i - bit.sum(c + 1)
        bit.add(c, 1)

        # 中央値が k より小さくなる数が半分より多ければ答えは k より小さい
        # NH2 = (N+1)C2
        if count > (N + 1) * N // 2 / 2:
            return True
    return False


def compress(li, origin=0):
    """
    座圧
    :param li:
    :param int origin:
    :rtype: list of int
    """
    *ret, = map({v: i + origin for i, v in enumerate(sorted(set(li)))}.__getitem__, li)
    return ret


def argsort(li, key=None, reverse=False):
    return [i for _, i in sorted(
        [(a, i) for i, a in enumerate(li)], key=(lambda t: key(t[0])) if key else None, reverse=reverse
    )]


def cumsum(it):
    """
    累積和
    :param collections.Iterable it:
    :return:
    """
    cs = 0
    ret = []
    for v in it:
        cs += v
        ret.append(cs)
    return ret


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
# test(A)

indices = argsort(A)

# 座圧
B = compress(A)

lo = 0
hi = N
while abs(lo - hi) > 1:
    mid = (lo + hi) // 2
    if less_than(B[indices[mid]]):
        hi = mid
    else:
        lo = mid
print(A[indices[lo]])


Measured memory_bytes: 103936
N, K = map(int, input().split())
SUNUKE = {n+1:0 for n in range(N)}

def skip():
  input()

def okashi():
  okashi_list = map(int, input().split())
  for i in okashi_list:
    SUNUKE[i] += 1

for i in range(K):
  skip()  # お菓子の種類は無視
  okashi()
  
print(len([k for k, v in SUNUKE.items() if v == 0]))


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


int main()
{
	ll A,B,C,K;
	cin>>A>>B>>C>>K;
	ll ans=0;
	ans+=min(K,A);
	K=max(K-A,(ll)0);
	K=max(K-B,(ll)0);
	ans-=K;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3552
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if(S == "Sunny"){
        print("Cloudy");
    }else if(S == "Cloudy"){
        print("Rainy");
    }else{
        print("Sunny");
    }

    
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
neighbor = Array.new(N+1){Hash.new}
M.times do |i|
    a, b = gets.split.map(&:to_i)
    neighbor[a][b] = true
end

(2..(N-1)).each do |i|
    if neighbor[1][i] && neighbor[i][N]
        puts 'POSSIBLE'
        exit
    end
end
puts 'IMPOSSIBLE'

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

typedef pair<ll, ll> LP;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<LP> ab(n);
	REP(i, n){ cin >> ab[i].first >> ab[i].second; }
	sort(ab.begin(), ab.end(), [](const pair<int, int>& lhs, const pair<int, int>& rhs) {
             return lhs.second < rhs.second; });
    ll sum = 0;
    REP(i, n){
    	sum += ab[i].first;
    	if (sum > ab[i].second){ cout << "No" << endl; return 0; }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main () {
  long long x;
  cin >> x;
  long long a = x / 11ll;
  long long b = x % 11ll;
  a *= 2ll;
  if (0ll < b) a ++;
  if (b > 6ll) a ++;
  cout << a << endl;
}


Measured memory_bytes: 256
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%mod;
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int main(){
  itn m; cin >> m;
  int k; cin >> k;
  int mx=rui(2,m)-1;
  if((m==1&&k==1)||mx<k){
    cout << -1 << endl;
    return 0;
  }
  if(m==1&&k==0){
    cout << "0 0 1 1" << endl;
    return 0;
  }
  deque<int> q;
  q.push_back(k);
  rep(i,mx+1){
    if(i==k) continue;
    q.push_back(i);
    q.push_front(i);
  }
  q.push_back(k);
  while(q.size()){
    int ans=q.front();
    q.pop_front();
    cout << ans << " ";
  }cout << endl;
}

Measured memory_bytes: 4680
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;
int long long ll;

int main() {

    string str;
    int ans=0;
    cin >> str;

    rep(i,str.length()) {
        if (str[i] == '+') {
            ans += 1;
        } else {
            ans -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    
    static final int MAX = (int)1e9 + 7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
        }
        
        int[] dp = new int[h+1];
        Arrays.fill(dp, MAX);
        dp[0] = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<h; j++){
                int idx = Math.min(h, j+a[i]);
                dp[idx] = Math.min(dp[idx], dp[j]+b[i]);
            }
        }
        
        System.out.println(dp[h]);
    }
}

Measured memory_bytes: 38940
n   = gets.to_i
ary = gets.split.map(&:to_i).sort.reverse

i, h, w = 0, 0, 0

while i < n - 1
  if ary[i] == ary[i + 1]
    if h == 0
      h = ary[i]
      i += 1
    else
      w = ary[i]
      break
    end
  end
  i += 1
end

puts h * w


Measured memory_bytes: 10096
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int a, b;
	scanf("%d%d", &a, &b);
	if (0 < a)printf("Positive\n");
	else if (0 <= b && a <= 0)printf("Zero\n");
	else {
		if ((abs(b - a) + 1) & 1)printf("Negative\n");
		else printf("Positive\n");
	}

	Please AC;
}


Measured memory_bytes: 256
def read_values():
    return map(int, input().split())


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


def main():
    S = input()
    N = len(S)

    i = 1
    prev = S[0]
    res = N
    for s in S[1:]:
        if prev != s:
            res = min(res, max(i, N - i))
        prev = s
        i += 1
    
    print(res)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
string s;
int ans;
cin>>s;
int j=s.size();
for(int i=0;i<=s.size()/2;i++)
{
j--;
if(s[i]!=s[j])
{cout<<"No";
system("pause");
return 0;
}}
cout<<"Yes";
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>

struct Card{
  char c,v;
  Card():c(0),v(0){}
  Card(const Card &card):c(card.c),v(card.v){}
  Card& operator=(const Card &card){
    c = card.c;
    v = card.v;
    return (*this);
  }
  bool operator==(const Card &card){
    return c==card.c&&v==card.v;
  }
  bool operator!=(const Card &card){
    return !((*this)==card);
  }
};

int main(){
  int n;
  std::cin>>n;
  std::vector<Card> vec1(n),vec2(n);
  for(int i=0;i<n;++i){
    char c,v;
    std::cin>>c>>v;
    vec1[i].c=c,vec1[i].v=v;
    vec2[i].c=c,vec2[i].v=v;
  }

  for(int i=0;i<n;++i){
    for(int j=n-1;j>=i+1;--j)
      if(vec1[j].v<vec1[j-1].v) std::swap(vec1[j],vec1[j-1]);
  }
  for(int i=0;i<n;++i){
    int minj=i;
    for(int j=i+1;j<n;++j)
      if(vec2[j].v<vec2[minj].v) minj = j;
    std::swap(vec2[i],vec2[minj]);
  }

  std::cout<<vec1[0].c<<vec1[0].v;
  for(int i=1;i<n;++i) std::cout<<" "<<vec1[i].c<<vec1[i].v;
  std::cout<<"\nStable"<<std::endl;

  std::cout<<vec2[0].c<<vec2[0].v;
  for(int i=1;i<n;++i) std::cout<<" "<<vec2[i].c<<vec2[i].v;
  int i;
  for(i=0;i<n;++i)
    if(vec1[i]!=vec2[i]) break;
  if(i==n){
    std::cout<<"\nStable"<<std::endl;
  }else{
    std::cout<<"\nNot stable"<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 3104
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

H,W=mint()
S=[input() for _ in range(H)]

ans=0
for s in product(range(H),range(W)):
    if S[s[0]][s[1]]=='#':
        continue
    q=deque([s])
    d=[[-1]*W for _ in range(H)]
    d[s[0]][s[1]]=0
    while len(q)>0:
        i,j = q.popleft()
        for x,y in [(i-1,j),(i+1,j),(i,j-1),(i,j+1)]:
            if 0<=x<H and 0<=y<W and S[x][y]=='.' and d[x][y]<0:
                d[x][y]=d[i][j]+1
                q.append((x,y))
    for i in range(H):
        for j in range(W):
            ans=max(ans,d[i][j])
print(ans)

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

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  vector<ll> pt(40,1);
  for(int i = 1; i < 40; i++) pt[i] = pt[i-1] * 2;
  multiset<ll> ms;
  rep(i,n) ms.insert(a[i]);
  sort(a,a+n,greater<ll>());
  int ans = 0;
  rep(i,n) {
    auto itr = ms.find(a[i]);
    if(itr != ms.end()) {
      ms.erase(itr);
      for(int j = 39; j >= 0; j--) {
        ll v = pt[j] - a[i];
        itr = ms.find(v);
        if(itr != ms.end()) {
          ans++;
          ms.erase(itr);
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  // vector<int> A(N);
  // rep(i, N) cin >> A.at(i);

  int now;
  int prev;
  int max;
  int min;
  ll ans = 1000;

  int slope = 0;
  rep(i, N) {
    if (i == 0) {
      cin >> prev;
      now = prev;
      max = prev;
      min = prev;
      continue;
    }

    prev = now;
    cin >> now;
    if (now < prev) {
      if (slope == 0) {
        slope = -1;
      }
      if (slope > 0) {
        ans += (ans / min) * (max - min);
        slope = -1;
      }
      min = now;
    };
    if (now > prev) {
      if (slope == 0) {
        slope = 1;
      }
      if (slope < 0) {
        min = prev;
        slope = 1;
      }
      max = now;
    };

    if (i == N - 1 && slope == 1) {
      ans += (ans / min) * (now - min);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
struct LowestCommonAncestor {
    int n, sn;
    vector<int> id, vs, dep;
    vector<pair<int, int>> node;
    LowestCommonAncestor(vector<vector<int>> g, int root = 0)
        : n(sz(g)), id(n), vs(n * 2 - 1), dep(n * 2 - 1) {
        int k = 0;
        dfs(root, -1, 0, k, g);
        sn = 1;
        while (sn < sz(dep)) {
            sn *= 2;
        }
        node.assign(2 * sn - 1, make_pair(INF, INF));
        for (int i = 0; i < sz(dep); i++) {
            node[sn + i - 1] = make_pair(dep[i], i);
        }
        for (int i = sn - 1; i >= 1; i--) {
            node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }
    void dfs(int now, int pre, int d, int &k, const vector<vector<int>> &g) {
        id[now] = k;
        vs[k] = now;
        dep[k++] = d;
        for (int nxt : g[now]) {
            if (nxt == pre) continue;
            dfs(nxt, now, d + 1, k, g);
            vs[k] = now;
            dep[k++] = d;
        }
    }
    pair<int, int> query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = sn;
        if (r <= a || b <= l) return make_pair(INF, INF);
        if (a <= l && r <= b) return node[k];
        auto vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        auto vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
    int get(int u, int v) {
        int l = min(id[u], id[v]);
        int r = max(id[u], id[v]) + 1;
        return vs[query(l, r).second];
    }
    int depth(int u) {
        return dep[id[u]];
    }
    int dist(int u, int v) {
        return depth(u) + depth(v) - 2 * depth(get(u, v));
    }
};
int main() {
    int n;
    cin >> n;
    vector<int> cnt(26, INF);
    rep(i, n) {
        string s;
        cin >> s;
        vector<int> now(26, 0);
        for (char c : s) {
            now[c - 'a']++;
        }
        rep(i, 26) {
            chmin(cnt[i], now[i]);
        }
    }
    rep(i, 26) {
        if (cnt[i] == INF) continue;
        while (cnt[i]--) cout << (char)(i + 'a');
    }
    cout << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int i,j,m,n,a,b,k,s,c,d;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        if(a>b)
        {
            if(c>d)
                printf("%d\n",b+d);
            else
                printf("%d\n",b+c);
        }
        else
        {
            if(c>d)
                printf("%d\n",a+d);
            else
                printf("%d\n",a+c);
        }

    }
    return 0;
}


Measured memory_bytes: 128
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define LARGE_PRIME_NUM 1000000007
typedef long long ll;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>

using namespace std;

int main() {
	string s;
	cin >> s;

	int first = stoi(s.substr(0, 2));
	int second = stoi(s.substr(2, 2));
	
	string ans = "";
	if (first > 0 && first <= 12 && second > 0 && second <= 12) {
		ans = "AMBIGUOUS";
	} else if (first > 0 && first <= 12) {
		ans = "MMYY";
	} else if (second > 0 && second <= 12) {
		ans = "YYMM";
	} else {
		ans = "NA";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

struct N{
	int t,b,n,s,e,w;              // top bottom north south east west
	void roll(int d) {
		int tmp;
		if(d==0) {
			tmp=t; t=s; s=b; b=n; n=tmp;
		}else if(d==1) {
			tmp=t; t=e; e=b; b=w; w=tmp;
		}else if(d==2) {
			tmp=t; t=n; n=b; b=s; s=tmp;
		}else {
			tmp=t; t=w; w=b; b=e; e=tmp;
		}
	}
};


int main() {
  string a[] = {"north", "west", "south", "east"};
  map<string, int> mp;
  REP(i,4) mp[a[i]] = i;
  int n;
  while(cin>>n,n) {
    N dice;
    dice = (N){1,6,2,5,4,3};
    REP(i,n) {
      string s;
      cin >> s;
      dice.roll(mp[s]);
    }
    cout << dice.t<<endl;
  }
}

Measured memory_bytes: 0
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const long long MOD = 998244353;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


void solve(long long n, long long m, long long k){

    auto mpow = [](auto x, i64 y){
     auto z = x;
     decltype(x) val = y & 1 ? x : decltype(x)(1);
     while(z *= z, y >>= 1)
      if(y & 1)
       val *= z;
     return val;
    };

    auto calc_fact = [mpow]{
     constexpr int N = 3e5;
     vector<mint> fact(N + 1, 1);
     vector<mint> inv(N + 1, 1);
     for(int i = 1; i < N; ++i){
      fact[i + 1] = fact[i] * (i + 1);
      inv[i + 1] = mpow(fact[i + 1], MOD - 2);
     }
     return make_pair(fact, inv);
    };
    vector<mint> fact, inv;
    tie(fact, inv) = calc_fact();


    auto ncr = [&fact, &inv](int n, int r){
     if(n < 0 || r < 0 || n < r)
      return mint(0);
     return fact[n] * inv[r] * inv[n - r];
    };

    mint ans = 0;

    for(int i = 0; i <= k; ++i){
        mint pat = ncr(n - 1, i);
        pat *= mpow(mint(m - 1), n - i - 1);
        ans += pat;
    }
    cout << ans * m << endl;

}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	double n,m,d;
	cin>>n>>m>>d;
	printf("%.12f\n",(d==0?1:2)*(n-d)*(m-1)/n/n);
}

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

int main(){
  ll k,a,b;
  cin >> k >> a >> b;
  ll bis = 1;
  ll m = 0;
  if( a+1 >= b ){
    cout << k+1 << endl;
    return 0;
  }else{
    rep(i,k){
      if( i == k-1 ){
        if( m != 0 ){
          m--;
          bis += b;
        }else{
          bis++;
        }
        break;
      }
      if( bis < a && m == 0 ){
        bis++;
      }else if( bis >= a && m == 0 ){
        m++;
        bis -= a;
      }else if( m != 0 ){
        m--;
        bis += b;
      }else{
        bis++;
      }
    }
  }
  cout << bis << endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

ld ComputeArg(ld x1,ld y1,ld x2,ld y2){
	ld dot=x1*x2+y1*y2;
	ld cosRad=dot/sqrt(Sq(x1)+Sq(y1))/sqrt(Sq(x2)+Sq(y2));
	return acosl(cosRad);
}

ld ComputeRad(ld arg1,ld arg2,ld len){
	arg1/=2;
	arg2/=2;
	ld p=ld(1)/tanl(arg1);
	ld q=ld(1)/tanl(arg2);
	return len/(p+q+2);
}

int main(){
	ll x1=read(),y1=read(),x2=read(),y2=read(),x3=read(),y3=read();
	ld arg1=ComputeArg(x2-x1,y2-y1,x3-x1,y3-y1),arg2=ComputeArg(x1-x2,y1-y2,x3-x2,y3-y2),arg3=ComputeArg(x1-x3,y1-y3,x2-x3,y2-y3);
	ld ans=0;
	chmax(ans,ComputeRad(arg1,arg2,sqrt(Sq(x2-x1)+Sq(y2-y1))));
	chmax(ans,ComputeRad(arg2,arg3,sqrt(Sq(x3-x2)+Sq(y3-y2))));
	chmax(ans,ComputeRad(arg3,arg1,sqrt(Sq(x1-x3)+Sq(y1-y3))));
	cout<<fixed<<setprecision(19)<<ans<<endl;
}


Measured memory_bytes: 384
import collections
n,m = map(int,raw_input().split(' '))

costs = [map(int, raw_input().split(' ')) for _ in range(n)]
costs.sort(key = lambda x:-x[0])
q = collections.deque(costs)
r = 0
while(m):
	u,v = q.pop()
	t = min(v,m)
	m -=t
	r += t * u
print r

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bellman_ford(N: int, edges: list, src: int) -> list:
    """ ベルマンフォード(頂点数, 辺集合(0-indexed), 始点) """

    # 頂点[ある始点からの最短距離] (経路自体を知りたい時はここに前の頂点も持たせる)
    res = [INF] * N
    res[src] = 0
    # 各辺によるコストの置き換えを頂点数N-1回繰り返す
    for _ in range(N-1):
        for u, v, cost in edges:
            # INFからは更新しない
            if res[u] == INF:
                continue
            if res[v] > res[u] + cost:
                res[v] = res[u] + cost
    tmp = res[:]
    # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする
    for _ in range(N-1):
        for u, v, cost in edges:
            if res[u] == INF:
                continue
            if res[v] > res[u] + cost:
                # 検出した負閉路はすぐに-INFにする
                res[v] = -INF
    for i in range(N):
        if tmp[i] != res[i]:
            res[i] = -INF
    return res

N, M, P = MAP()
edges = []
for i in range(M):
    a, b, c = MAP()
    a -= 1; b -= 1
    edges.append((a, b, P-c))

res = bellman_ford(N, edges, 0)

if res[N-1] != -INF:
    print(max(-res[N-1], 0))
else:
    print(-1)


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

int main() {
	//freopen("input.txt", "r", stdin);
	int k;
	string s;
	cin >> k >> s;
	if (k >= s.size())
		cout << s;
	else {
		s.erase(k, s.size() - k + 1);
		cout << s << "...";
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> vec(h);
  for (int i = 0; i < h; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << "#" << vec.at(i) << "#" << endl;
  }
    for (int i = 0; i < w + 2; i++) {
    cout << "#";
  }
  cout << endl;
}
  

Measured memory_bytes: 256
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn simulate(a: usize, b: usize, c: usize, d: usize) -> bool {
    if a < b {
        return false;
    }
    if b > d {
        return false;
    }
    if c >= b - 1 {
        return true;
    }
    let mut seen = std::collections::HashSet::new();
    let mut a = a % b;
    let d = d % b;
    if d == 0 {
        if a > c {
            return false;
        } else {
            return true;
        }
    }
    seen.insert(a);
    loop {
        let n = (c - a) / d + 1;
        let na = a + n * d;
        if na > c && na < b {
            return false;
        }
        a = na % b;
        if seen.contains(&a) {
            return true;
        }
        seen.insert(a);
    }
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, t: usize);
    for _ in 0..t {
        parse!(it, a: usize, b: usize, c: usize, d: usize);
        if simulate(a, b, c, d) {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a, b, c, x, y, ans = 1e18 + 13;
int32_t main () {
    cin >> a >> b >> c >> x >> y;
    for (int i = 0; i <= 300000; i++) {
	int resx = max(0ll, x - i / 2), resy = max(0ll, y - i / 2);
	ans = min(ans, i * c + resx * a + resy * b);
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, a[maxn];
int main() {
    n = read();
    for (reg int i = 1; i <= n; i++) a[i] = read();
    sort(a + 1, a + n + 1);
    cout << a[n / 2 + 1] - a[n / 2] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main()
{
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    ll x = tx - sx;
    ll y = ty - sy;
    string s = "";
    s += string(x, 'R');
    s += string(y, 'U');
    s += string(x, 'L');
    s += string(y, 'D');
    s += 'D';
    s += string(x+1, 'R');
    s += string(y+1, 'U');
    s += 'L';
    s += 'U';
    s += string(x+1, 'L');
    s += string(y+1, 'D');
    s += 'R';
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-12;
const int N=2000+10,maxn=90000+10,inf=0x3f3f3f3f;

int a[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,z,w;
    cin>>n>>z>>w;
    for(int i=1;i<=n;i++)cin>>a[i];
    if(n!=1)cout<<max(abs(a[n]-w),abs(a[n]-a[n-1]))<<endl;
    else cout<<abs(a[1]-w)<<endl;
    return 0;
}
/********************

********************/


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long K;
	scanf("%lld",&K);

	vector<ll> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	cout << a[K - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int m,d;cin>>m>>d;
    int ans=0;
    for(int i=1;i<=d;i++){
        int d1=i%10;
        int d10=i/10;
        if(d1<2||d10<2)continue;
        int yay=d1*d10;
        if(yay>0&&yay<=m){ans++;}
    }
    cout<<ans;
}

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

vector< vector<int> >adj(100007);
vector<int>indegree(100007);
int dp[100007];

void dfs(int i)
{
	if(dp[i]!=0) //it is necessary because it is the dp part so that we do not repeat calculation of sub problems
		return;
	for(int j=0;j<adj[i].size();j++)
	{
		dfs(adj[i][j]);
		dp[i]=max(dp[i],1+dp[adj[i][j]]);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=n;i++)
	{
		indegree[i]=0;
		dp[i]=0;
	}
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		adj[x].emplace_back(y);
		indegree[y]++;
	}
	int ans=-1;
	for(int i=1;i<=n;i++)
	{
		if(indegree[i]==0)
		{
			dfs(i);
			ans=max(ans,dp[i]);
		}
	}
	cout<<ans<<endl;
return 0;
}

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


void solve(long long A, long long B, long long C){
  if(A==B)
    std::cout << C << std::endl;
  else if(A==C)
    std::cout << B << std::endl;
  else
    std::cout << A << std::endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

signed main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
    a[i]--;
  }

  int ans = 0;
  map<int, int> m;
  rep(i, N) {
    if (m.find(a[i]) != m.end()) {
      if (m[a[i]] == i)
        ans++;
    }

    m[i] = a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 7296
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    res = [i for i in range(1, n + 1, 2)]
    print("YES" if len(res) >= k else "NO")


if __name__ == '__main__':
    resolve()


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

int main(){
	int n,k;
	while(cin>>n>>k,n){
		int data[100];
		int ans=1;
		int tmp;
		for(int i=0;i<k;i++)cin>>data[i];
		for(int i=0;i<n;i++){
			for(int j=0;j<k;j++){
				cin>>tmp;
				data[j]-=tmp;
				if(data[j]<0)ans=0;
			}
		}
		if(ans)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		
	}
	
	return 0;
}


Measured memory_bytes: 1152
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce



sys.setrecursionlimit(2147483647)
INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
if n * 2 >= m:
    print(m // 2)
else:
    print(n + (m - (n * 2)) // 4)

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
string a; 
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>a;int len=a.size();
	if(!len%2)len--;
	for(int i=0;i<len;i+=2)
	cout<<a[i];
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#define maxn 100100
using namespace std;
bool cmp(int a,int b){
	return a<b;
}
int main(){
	int n,a[maxn],name[maxn],times[maxn];
	memset(name,0,sizeof(name));
	memset(times,0,sizeof(times));
	cin >> n;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);

	sort(a+1,a+1+n,cmp);
	//cout << "yes";/*
	name[1]=a[1];times[1]++;int cur=1;
	for (int i=2;i<=n;i++){
		if (a[i] == name[cur]) times[cur]++; 
			else {
				name[++cur]=a[i];
				times[cur]++;
			}
	}
	int tot=0;
	for (int i=1;i<=cur;i++) {
		times[i]%=2;
		if (!times[i]) tot ++;
	}
	if (tot%2==1) cout << cur-1; else cout << cur;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<P>zero;
    char prev = '1';
    int index;
  P hoge;
    for(int i = 0;i < n; i++){
        if(s[i] == '0'){
            if(prev == '1'){
                hoge.first = i;
            }
          if(i == n-1){
            hoge.second = i;
            zero.push_back(hoge); 
          }
        }
        if(s[i] == '1' && prev == '0'){
          hoge.second = i-1;
            zero.push_back(hoge); 
        }
        prev = s[i];
 
    }
    int ans = -1;
    int basyo = 0;
    int nagasa = zero.size();
    int last = min(k,nagasa);
  if(!zero.size()){
    cout << n << endl;
    return 0;
  }
  else{
    for(int i = 0; i < n; i++){
        if(i > zero[basyo].second && basyo < nagasa-1){
            basyo = basyo+1;
        }
      if(i == 6){
      }
        if(basyo+k-1 < nagasa-1){
            ans = max(ans,zero[basyo+k].first-i);
        }
        
        else{
            ans = max(ans,n-i);
        }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3952
#include <cstdio>
#include <vector>
using namespace std;

typedef long long ll;


ll a, b, c, d, n;

int main()
{
    scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
    ll dif = b-a;
    for (ll m = 0; m <= n-1; ++m)
    {
        ll lower = -d*m+(n-1-m)*c;
        ll upper = -c*m+(n-1-m)*d;
        if (dif >= lower && dif <= upper)
        {
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 128