akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n;cin>>n;
  rep(ans, n+1){
    if((int)(ans * 1.08) == n){
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

k,x=MI()
l=[]

for i in range(x-k+1,x+k):
    if i >= -1000000 or i <= 1000000:
        l.append(i)
p2S(l)

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

ll fc(ll h, ll w){
  ll ans = 1001001001;
  rep2(i, 1, h){
    const ll s1 = w * i;
    ll s2, s3;
    int h2 = h - i;
    if(h2 % 2 == 0){
      s2 = h2/2 * w;
      ans = min(ans, abs(s1 - s2));
    }else{
      s2 = h2/2 * w;
      s3 = (h2/2+1)*w;
      ll mn = min({s1, s2, s3});
      ll mx = max({s1, s2, s3});
      ans = min(ans, abs(mx - mn));
    }

    if(w % 2 == 0){
      s2 = h2 * w / 2;
      ans = min(ans, abs(s1 - s2));
    }else{
      s2 = h2 * (w / 2);
      s3 = h2 * ((w+1)/2);
      ll mn = min({s1, s2, s3});
      ll mx = max({s1, s2, s3});
      ans = min(ans, abs(mx - mn));
    }
  }
  return ans;
}

int main(){
  int h, w;
  cin >> h >> w;
  ll ans = fc(h, w);
  ans = min(ans, fc(w, h));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> p;
    for(int i=0;i<n;i++){
        int val;
        cin>>val;
        p.push_back(val);
    }
    int ans=0;
    int mx = INT_MIN;
    for(int i=2;i<n;i++){
        int a[3];
        a[0] = p[i-2];
        a[1] = p[i-1];
        a[2] = p[i];
        sort(a,a+3);
        if(a[1]==p[i-1])
            ans++;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : ProjG.cpp
// Author      : Yong Kiat
// Version     :
// Copyright   : By Algotae.
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

int n, x, k, dp[100001];
vector<int> a;

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

    cin >> n >> k;
    for (int i = 0; i < n && cin >> x; i++) {
        a.push_back(x);
    }

    fill(dp, dp + n, 1000000001);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; i - j >= 0 && j <= k; j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(a[i - j] - a[i]));
        }
    }

    cout << dp[n - 1];

    return 0;
}


Measured memory_bytes: 1144
#include <iostream>

using namespace std;
int main(void){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            
            if((i < b) ^ (j < a)) cout << 1;
            else cout << 0;
            
        }
        cout << endl;
    }
    
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if (a <= 5){
    cout << 0 << endl;
  }
  else if (a <= 12){
    cout << b/2 << endl;
  }
  else{
    cout << b << endl;
  }
}

Measured memory_bytes: 3460
X = int(input())

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif X >= 1800:
    print(1)


Measured memory_bytes: 9116
s = input()

if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
elif s=="SAT":
    print(1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int main(){
    long long int N,D;
    scanf("%d",&N);
    scanf("%d",&D);
    long long int dplus= D*D;
    int x,y;
    long long int a,b;
    int i;
    long long int dist=0;
    int count=0;
    for(i=0;i<N;i++){
        scanf("%d",&x);
        scanf("%d",&y);
        a= abs(x);
        b= abs(y);
        dist = (a*a) + (b*b);
        if (dist<=dplus){
            count++;
        }
    } 
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1672
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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


int main(void){
    int a, b, c;

    cin >> a >> b >> c;

    cout << a * b / 2 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

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

  if(n*a >= b)
    cout << b << endl;
  else cout << n*a << endl;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N)
  cin >> a[i];
  REP(i, N)
  {
    if (a[i] % 2 == 1)
    {
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}

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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  string s;
  map<string, int> ans;
  cin >> n;
  rep(i, 0, n){
    cin >> s;
    ans[s] ++;
  }
  cin >> n;
  rep(i, 0, n){
    cin >> s;
    ans[s] --;
  }
  int maxv = 0;
  for(auto x : ans){
    maxv = max(maxv, x.second);
  }
  cout << maxv << '\n';
  return 0;
}


Measured memory_bytes: 3632
char a[2][204];n,m,i,j,c,p;main(s){for(;i=scanf(m="%d %[^\n] %[^\n]",&n,a,a+1)>2;printf(m<n?"%d\n":"NA\n",m))for(;~i;m>c?m=c:0)for(j=i--,c=p=0;s=a[j][p+p]-50,c<n&&!s|n+~p;)p+=p<n&&s?~s|a[j][p+p+2]-49?j=!j,++c,2:1:-1;}

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

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

	int N, M, a[100000], b[100000];
	pair<int, int> sec[100000];
	cin >> N >> M;
	REP(i, M){
		cin >> a[i] >> b[i];
		sec[i] = make_pair(b[i], a[i]);
	}
	sort(sec, sec+M);
	bool cut[100000] = {0};
	int MAX = -1, ans = 0;
	REP(i, M){
		if(sec[i].second > MAX){
			MAX = sec[i].first-1; ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var HA = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (H, A) = (HA[0], HA[1]);

        WriteLine((H - 1) / A + 1);

    }
}


Measured memory_bytes: 28272
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 13 21:11:51 2019

@author: Yamazaki Kenichi
"""

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

d = [0 for i in range(N)]

a = 0
b = 0
C = [0 for i in range(N)]
ans = 0

for i in range(N):
    if A[i] < B[i]:
        d[i] = 1
        a += A[i]
        b += B[i]
    else:
        C[i] += A[i]-B[i]

C.sort()
c =b-a 

if sum(C) < b-a:
    ans = -1
elif d.count(1) == 0:
    ans =0
else:
    ans = d.count(1)
    i=1
    while c>=0:
       c -= C[-i]
       ans+=1
       i +=1
    
print(ans)


Measured memory_bytes: 19188
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 = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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, k = LI()
A = [0] + LI()



for i in range(1, n + 1):
    A[i] = (A[i] + A[i - 1]) % k


for i in range(n + 1):
    A[i] = (A[i] - i) % k



ans = 0
D = defaultdict(int)
for j in range(n, -1, -1):
    ans += D[A[j]]
    D[A[j]] += 1
    if j + k - 1 < n + 1:
        D[A[j + k - 1]] -= 1


if k == 1:
    print(0)
else:
    print(ans)

Measured memory_bytes: 85952
import math


def prime_factorization(x):
    if x == 1:
        return {1: 1}

    notprime = {}
    pf = {}
    for y in range(2, math.ceil(math.sqrt(x)) + 1):
        if y not in notprime.keys():
            if x % y == 0:
                pf[y] = 0
                while x % y == 0:
                    x //= y
                    pf[y] += 1
            
            coef = 2
            while coef * y < x:
                notprime[coef * y] = True
                coef += 1
    if x > 1:
        pf[x] = 1    
    return pf


def submit():
    n = int(input())

    #　階乗の素因数分解を求める
    pf_all = {}
    for x in range(2, n + 1):
        pf = prime_factorization(x)
        for k, v in pf.items():
            if k not in pf_all.keys():
                pf_all[k] = v
            else:
                pf_all[k] += v

    pf_cand = [v for k, v in pf_all.items() if v > 1]
    pf_cand.sort()
    possible_divisors = [1, 3, 5, 15, 25, 75]
    
    def dfs(curr, rest, cnt):
        if curr > 75:
            return cnt
        if not rest:
            if curr == 75:
                return cnt + 1
            else:
                return cnt
        
        l = rest[-1]
        new_rest = rest[:-1]
        for p in possible_divisors:
            if p - 1 <= l:
                cnt = dfs(curr * p, new_rest, cnt)
            else:
                break
        return cnt
            
    print(dfs(1, pf_cand, 0))


if __name__ == "__main__":
    submit()


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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	int t; string s;
	cin >> t >> s;
	if(t < 3200) cout << "red\n";
	else cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
N = int(input())
A = list(map(int, input().split()))
ans = 0
s = 0
j = 0

for i in range(N):
    while j < N and not (s & A[j]):
        s ^= A[j]
        j += 1
    ans += j-i
    s ^= A[i]
print(ans)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  for (int i = 1; i <= n; i++) {
    int dx = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    int dt = t[i] - t[i - 1];
    if (!(dx <= dt && dx % 2 == dt % 2)) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  ll ans = 0;
  REP(i, N) ans += nextInt() - 1;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG 
 int main(){
     int n;
     cin>>n;
     vector<int> light(n);
     rep(i,n){
         cin>>light[i];
     }

     vector<int> a(n);
     int memory=1;

    rep(i,n){
        a[i]=light[memory-1];
        memory=a[i];
    }

    int count=0;
    rep(i,n){
        if(a[i]==2) {
            count+=i+1;
            break;
        }
        else continue;
    }
    if(count>0) cout<<count<<endl;
    else cout<<-1<<endl;
 }


Measured memory_bytes: 4032
import sys
readline = sys.stdin.buffer.readline
s = readline().rstrip().decode('utf-8')
n = len(s)
s_count = 0
ans = 0
i=0
while True:
    if i == n:
        break
    if s[i] == "T":
        if s_count > 0:
            s_count-=1
            ans+=2
    else:
        s_count+=1
    i+=1


print(n-ans)

Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = B;
    ans += min(A + B + 1, C);
    cout << ans << endl;
    return 0;
}


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

int main()
{
	string s;
	cin>>s;
	int sum=0,i;
	
	for(i=0;i<s.size();i++)
	{
		sum+=s[i]-'0';
	}
	
	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";
		
	return 0;
}

Measured memory_bytes: 3740
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <ctime>
#include <cstdlib>
using namespace std;
typedef long long ll;
int main(){
	int n,q;
	string s;
	cin>>n>>s>>q;
	while (q--) {
		int k;cin>>k;
		ll d=0,m=0,dm=0,dmc=0,i;
		for(i=0;i<k;i++){
			switch (s[i]) {
				case 'D':
					d++;
					break;
					
				case 'M':
					dm+=d;
					m++;
					break;
					
				case 'C':
					dmc+=dm;
			}
		}
		for(;i<n;i++){
			switch (s[i-k]) {
				case 'D':
					d--;
					dm-=m;
					break;
					
				case 'M':
					m--;
			}
			switch (s[i]) {
				case 'D':
					d++;
					break;
					
				case 'M':
					dm+=d;
					m++;
					break;
					
				case 'C':
					dmc+=dm;
			}
		}
		printf("%lld\n",dmc);
	}
}


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

using namespace std;

int main() {

	string s;
	cin >> s;

	if (s.size() == 1) {
			cout << 0 << endl;
			return 0;
	}

	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] != s[i + 1]) { break; }
		if (i == s.size() - 2) {
			cout << 0 << endl;
			return 0;
		}
	}

	string sorigin = s;
	string news;
	int counter;
	int countermin = 10000;
	for (int i = (char)'a'; i <= (char)'z'; i++) {
		s = sorigin;
		bool opflg = false;
		for (int j = 0; j < s.size() - 1; j++) {
			if (s[j] == i) {
				opflg = true;
				break;
			}
		}
		if (opflg) {
			counter = 0;
			while (1) {
				news = "";
				for (int j = 0; j < s.size() - 1; j++) {
					if (s[j] == i || s[j + 1] == i) {
						news.push_back((char)i);
					}
					else {
						news.push_back(s[j]);
					}

				}
				counter++;
				bool brkflg = true;
				for (int j = 0; j < news.size(); j++) {
					if (news[j] != i) {
						brkflg = false;
						break;
					}
				}
				if (brkflg) {
					countermin = min(countermin, counter);
					break;
				}
				s = news;
			}
		}
	}

	cout << countermin << endl;

	return 0;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int         long long
#define ll          long long
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),a.rend()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j,a,b) for(ll j=a;j<b;j++)
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())
#define IOS	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//CONSTANTS----------------------------------
#define PI 	    3.141592653589793238462643
const ll hell=1000000007;
const ll mod=1000000007;
//function-----------------------------------
ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}
ll LCM(ll a, ll b)
{
    return a*(b/GCD(a,b));
}
bool isPrime(ll n) {

    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll fact(ll n)
{
    ll f=1;
    for(ll i=2;i<=n;i++)
	f=f*i;
    return f;
}
ll power(ll a,ll b)
{
  if(b==0)return 1;
  if(b==1)return a;
  ll t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
//CODE------------------------------------------
ll solve()
{
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n>=k) cout<<x*k+(n-k)*y;
    else cout<<n*x;
    return 0;
}
//MAIN------------------------------------------
signed main(){
    IOS
    #ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#define llong long long
#define ldouble long double
#define uint unsigned int
#define ullong unsigned long long
#define udouble unsigned double
#define uldouble unsigned long double
#define modinc(x) {if(x>=P) x-=P;}
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define piiii pair<pair<int,int>,pair<int,int> >
#define pli pair<llong,int>
#define pll pair<llong,llong>
#define Memset(a,x) {memset(a,x,sizeof(a));}
using namespace std;

const int N = 1e5;
int fa[N+2];
int a[N+2];
int b[N+2];
int c[N+2];
int d[N+2];
vector<int> v;
int n,num;

int findfa(int u)
{
	int i = u;
	while(fa[u]!=u) u = fa[u];
	while(fa[i]!=u)
	{
		int j = fa[i]; fa[i] = u; i = j;
	} return u;
}

int getid(int x) {return lower_bound(v.begin(),v.end(),x)-v.begin()+1;}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {scanf("%d",&a[i]); a[0] ^= a[i];}
	for(int i=1; i<=n; i++) {scanf("%d",&b[i]); b[0] ^= b[i];}
	for(int i=0; i<=n; i++) c[i] = a[i],d[i] = b[i];
	sort(c,c+n+1); sort(d,d+n+1);
	for(int i=1; i<=n; i++) if(c[i]!=d[i]) {printf("-1"); return 0;}
	bool tmp = true; for(int i=1; i<=n; i++) if(a[i]!=b[i]) {tmp = false; break;}
	if(tmp) {printf("0"); return 0;}
	for(int i=1; i<=n; i++) fa[i] = i;
	v.push_back(a[0]); v.push_back(b[0]);
	int tot = 0;
	for(int i=1; i<=n; i++) {if(a[i]!=b[i]) v.push_back(a[i]),v.push_back(b[i]),tot++;}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=0; i<=n; i++) {a[i] = getid(a[i]); b[i] = getid(b[i]);}
	num = v.size();
	for(int i=0; i<=n; i++)
	{
		int p = findfa(a[i]),q = findfa(b[i]);
		if(p!=q) {fa[p] = q; num--;}
	} printf("%d\n",num+tot-1);
	return 0;
}

Measured memory_bytes: 3320
n, k = map(int, input().split())
d = list(map(int, input().split()))
all_num = [i for i in range(10)]
not_d = list(set(all_num) - set(d))
not_d_str = [str(i) for i in not_d]
#print(set(not_d_str))
ans = []
for i in range(n, 10 * n):
    if set(list(str(i))).issubset(set(not_d_str)):
        print(i)
        exit()
    #print("f", i)


Measured memory_bytes: 3064
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-10-28 21:57:27
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int N;
  cin >> N;
  cout << 111 * ((N - 1) / 111 + 1) << endl;
}

Measured memory_bytes: 256
program sequence_sum
  implicit none
  integer(8) :: n, num, k, tmp, a(0:100000) = 0
  integer :: x, m, b(0:100000) = 0, period, offset, rem, i
  read(*,*) n, x, m
  tmp = m
  if (n <= 2 * m) then
    num = x
    do k = 2, n
      x = mod(int(x, 8) * x, tmp)
      if (x == 0) exit
      num = num + x
    end do
    write(*,'(i0)') num
    stop
  end if
  a(1) = x
  b(x) = 1
  do i = 2, m + 1
    x = int(mod(int(x, 8) * x, tmp))
    a(i) = a(i - 1) + x
    if (b(x) > 0) then
      offset = b(x) - 1
      period = i - offset - 1
      exit
    end if
    b(x) = i
  end do
  num = (n - offset) / period
  rem = int(n - offset - num * period)
  write(*,'(i0)') (a(offset + period) - a(offset)) * num + a(offset + rem)
end program sequence_sum

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 # define ld long double
# define pb push_back

int main()
{
    ll n,W;cin>>n>>W;
    // weight npot more than W
    vector<ll> dp(W+1);//dp[i] means maximum  total value if items with total weight i
    for(ll i=0;i<n;i++){
        ll w,v;cin>>w>>v;
        for(ll i=W-w;i>=0;i--){
            dp[i+w]=max(dp[i+w],dp[i]+v);
        }
    }
    ll ans=0;
    for(ll i=0;i<=W;i++){
        ans=max(ans,dp[i]);
    }cout<<ans;
    return 0;
}


Measured memory_bytes: 4000
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    vl dv = divisor(n * 2);
    ll ans = INF_LL;
    for(ll x : dv) {
        ll y = n * 2 / x;
        pair<ll, ll> res = crt(vl({1, 0}), vl({x, y}));
        if(res.first != 0 || res.second != 0) {
            if(y == 1) {
                if(res.first == 0 && res.second == 1) {
                    res.first += 2;
                } else if(res.first <= 1) {
                    res.first += res.second;
                }
            } else if(res.first == 0) {
                res.first += res.second;
            }
            chmin(ans, res.first - 1);
        }
    }
    cout << ans << endl;
    // int n;
    // cin >> n;5
    // vector<pair<P, int>> a(n);
    // rep(i, n) {
    //     cin >> a[i].first.first >> a[i].first.second;
    //     a[i].second = i;
    // }
    // sort(all(a));
    // dsu uf(n);
    // rep(i, n - 1) {
    //     if(a[i].first.second < a[i + 1].first.second) {
    //         uf.merge(i, i + 1);
    //     }
    // }
    // sort(all(a), [](auto x, auto y) { return x.second < y.second; });
    // rep(i, n) { cout << uf.size(i) << endl; }
    return 0;
}


Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
    private static long count = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.valueOf(sc.next());

        getCount(x);

        System.out.println(String.valueOf(count));

    }

    public static void getCount(long x) {
        count = (x / 11) * 2;
        long diff = x % 11;

        if (diff <= 6 && diff > 0) {
            count++;
        } else if (diff > 6) {
            count = count + 2;
        } else if (diff == 0) {
            //何もしない
        }
    }
}

Measured memory_bytes: 9684
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(int, a, b);
	cout << ((a % 3)*(b % 3)*((a + b) % 3) ? "Impossible" : "Possible") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
void trozen()
{
  int maxc=0;
  int cnt=0;
  int n;
  cin>>n;
  rep(i,n)
  {
    int x,y;
    cin>>x>>y;
    if(x==y) cnt++;
    else
    {
      maxc=max(maxc,cnt);
      cnt=0;
    }
  }
  maxc=max(maxc,cnt);
  if(maxc>=3) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 3664
N = int(input())
S = []
m = ['M', 'A', 'R', 'C', 'H']
M, A, R, C, H = 0, 0, 0, 0, 0
ans = 0

if N <= 2:
    print(0)
else:
    for i in range(N):
        na = input()
        if na[0] in m:
            S.append(na)
    S =set(S)
    for i in S:
        fa = i[0]
        if fa == 'M':
            M += 1
        elif fa == 'A':
            A += 1
        elif fa == 'R':
            R += 1
        elif fa =='C':
            C += 1
        else:
            H += 1
    
    print(M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H)

Measured memory_bytes: 15904
n = int(input())
words = [input() for _ in range(n)]
prev = words[0]
memory = []
ans = 'Yes'
for i,w in enumerate(words):
  if i == 0:
    memory.append(w)
    continue
  if prev[-1] != w[0]:
    ans = 'No'
    break
  prev = w
  if w in memory:
    ans = 'No'
    break
  memory.append(w)
print(ans)
  


Measured memory_bytes: 3060
from math import ceil
from bisect import bisect_right
n, d, a = (int(x) for x in input().split())
xh = []
for _ in range(n):
    x, h = (int(x) for x in input().split())
    xh.append([x, h])
xh = sorted(xh, key=lambda x: x[0])
cnt = 0
dmg = [0] * (n + 1)
for i, (x, h) in enumerate(xh):
    dmg[i] += dmg[i - 1]
    h -= dmg[i]
    if h <= 0:
        continue
    num = ceil(h / a)
    dmg[i] += num * a
    idx = bisect_right(xh, [x + 2 * d, float('inf')])
    dmg[idx] -= num * a
    cnt += num
print(cnt)

Measured memory_bytes: 44172
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		for(int i=1;i<=n;i++){
			String s = sc.next();
			StringBuffer t = new StringBuffer();
			if(s.length()<=5 || s.length()%2==1){
				System.out.println("NA");
			}else if(s.substring(0,2).compareTo(">'")==0 && s.substring(s.length()-1,s.length()).compareTo("~")==0){
				for(int k=0;k<(s.length()-4)/2;k++) t.append("=");
				t.append("#");
				for(int k=0;k<(s.length()-4)/2;k++) t.append("=");
				if(s.substring(2,s.length()-1).compareTo(t.toString())==0) System.out.println("A");
				else System.out.println("NA");
			}else if(s.substring(0,2).compareTo(">^")==0 && s.substring(s.length()-2,s.length()).compareTo("~~")==0){
				for(int k=0;k<(s.length()-4)/2;k++) t.append("Q=");
				if(s.substring(2,s.length()-2).compareTo(t.toString())==0) System.out.println("B");
				else System.out.println("NA");
			}else{
				System.out.println("NA");
			}
		}
	}	
}

Measured memory_bytes: 26892
//状态:	UC
//题号:atcoder 084 c
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[100005];
int b[100005];
int c[100005];
int n;
void sor(){
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
}

void ini(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n;i++)scanf("%d",&b[i]);
	for(int i=0;i<n;i++)scanf("%d",&c[i]);
}

void sol(){
	long long ans=0;
	int i=0,j,k=0;
	for(j=0;j<n;j++){
		while(i<n&&a[i]<b[j])i++;
		while(k<n&&c[k]<=b[j])k++;
		ans+=(long long)(i)*(n-k);
		//cout<<ans<<endl;
	}
	printf("%lld\n",ans);
}

int main(){
	ini();
	sor();
	sol();
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,K;
    vector<int> A,F;
    int a;
    int Asum=0;
    cin >> N >> K;
    REP(i,N){
        cin >> a;
        A.push_back(a);
        Asum+=a;
    }
    REP(i,N){
        cin >> a;
        F.push_back(a);
    }
    sort(A.begin(),A.end());
    sort(F.begin(),F.end(),greater<>());
    
    int L=-1,R=INF,mid;
    while(abs(R-L)>1){
        mid=(L+R)/2;
        int num=0;
        REP(i,N){
            int calc=mid/F[i];
            calc=A[i]-calc;
            calc=max(0ll,calc);
            num+=calc;
        }
        if(num>K){
            L=mid;
        }else{
            R=mid;
        }
        //cout << L MM R MM mid MM num << endl;
    }
    cout << R << endl;
    
    return 0;
}



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

int main() {
    int s;
    cin >> s;
    vector<int> a;
    a.push_back(s);
    map<int, int> ma;
    for (int i = 1; i < 1000001; i++) {
        if (a[i - 1] % 2 == 0) {
            a.push_back(a[i - 1] / 2);
        } else {
            a.push_back(a[i - 1] * 3 + 1);
        }
        if (ma[a[i - 1]] != 0) {
            cout << i << endl;
            return 0;
        }
        ma[a[i - 1]]++;
    }
}

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

int main(void){
    int N;
    cin >> N;
    array<bool, 100> farray{false};
    int sum{0};
    for(int i{0}; i<N; ++i){
        int tmp;
        cin >> tmp;
        if(farray[tmp-1]==false){
            farray[tmp-1]=true;
            ++sum;
        }
    }
    cout << sum;
}


Measured memory_bytes: 256
import bisect

H, N = map(int, input().split())

AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append([A, B])

dp = [float('inf')]*(H+1)
dp[0] = 0
for h in range(1, H+1):
  for a, b in AB:
    if h - a <= 0:
      cost = b
    else:
      cost = dp[h-a] + b
    dp[h] = min(dp[h], cost)

print(dp[H])

Measured memory_bytes: 42204
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
l=[]
q=[]
for i in range(n):
    l.append(t-h[i]*0.006)
    q.append(abs(l[i]-a))

ans=0
b=10**20
for i in range(n):
    if q[i]<=b:
        b=q[i]
        ans=i+1

print(ans)




Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>

using namespace std;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)

int N, P[200001];
int ans;

void resolve()
{
    cin >> N;
    RPT1(i, N) cin >> P[i];

    int min_val = 200000;
    ans = 0;
    RPT1(i, N)
    {
        if (P[i] <= min_val) {
            ans++;
            min_val = P[i];
        }
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
   int N;
   cin >> N;
   vector<int> d(N);
 
   for(int i =0; i<N; i++){
       cin >> d[i];
   }
     sort(d.begin(),d.end());
    int count = 1;
    for(int i=1; i<N; i++){
       if(d[i] != d[i-1]){
           count+=1;
       }
   }
   cout << count << endl;
}


Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break

    sum = m + f
    if m == -1 or f == -1:
        print('F')
    elif sum >= 80:
        print('A')
    elif sum >=65:
        print('B')
    elif sum >= 50 or r >= 50:
        print('C')
    elif sum >= 30:
        print('D')
    else:
        print('F')



Measured memory_bytes: 5592
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    n, r = map(int,input().split())
    if 10 > n:
        print(r + (100 * (10 - n)))
    else:
        print(r)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  std::vector<int> a(5);
  for (int i = 0; i < 5; ++i)
    std::cin >> a.at(i);
  std::sort(a.begin(), a.end());

  int min = INT_MAX;
  do {
    int sum = 0;
    for (auto &v : a) {
      int mod = sum % 10;
      if (mod != 0)
        sum += 10 - mod;
      sum += v;
    }
    min = std::min(min, sum);
  } while (std::next_permutation(a.begin(), a.end()));

  std::cout << min << std::endl;
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

ll f(ll b,ll n){
    if(n < b)return n;
    else return f(b,n/b) + (n%b);
}
int main(){

    ll n,s;cin >> n >> s;
    if(s == n){
        cout <<s + 1 << endl;
        return 0;
    }
    ll maxb = 2;
    //2 <= b <= sqrt(n)
    for(ll b = 2;b*b <= n;b++){
        maxs(maxb,b);
        if(f(b,n) == s){
            cout << b << endl;
            return 0;
        }
        if(f(b+1,n) == s){
            cout << b+1 << endl;
            return 0;
        }
    }
    for(ll d = maxb;d >= 1;d--){
        if((n+d-s)%d == 0){
            ll b = (n+d-s)/d;
            if(b > (n/(d+1)) and b <= (n/d)){
                cout << b << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;

}

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

using namespace std;
using ll = long long;


int main() {
    string N; cin >> N;
    int len = N.length();
    int k[len];
    for (int i = 0; i < len; i++) {
        k[i] = N[i] - '0';
    }
    int d[len][2];
    d[0][0] = k[0];
    d[0][1] = 11 - k[0];

    for (int i = 1; i < len; i++) {
        d[i][0] = min(d[i-1][0] + k[i], d[i-1][1] + k[i]);
        d[i][1] = min(d[i-1][0] + 11 - k[i], d[i-1][1] + 9 - k[i]);
    }
    cout << min(d[len - 1][0], d[len - 1][1]) << endl;
    return 0;
}

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

const int N = 1e5+5;
char s[N];
int n;

int main() {	
	scanf("%s",s), n = strlen(s);
	if((~n^(s[0]==s[n-1]))&1) printf("Second\n");
	else printf("First\n");
}

Measured memory_bytes: 384
n, k = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7
l=0
r=n
for i in range(n+1):
  if i >= k-1:
    ans += (r - l + 1) % mod
    ans %= mod
  l += i + 1
  l %= mod
  r += n - i - 1
  r %= mod
print(ans)

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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

ll d[22][(1 << 21) + 1];
int a[22][22];
int n;
    
const ll K = 1e9 + 7;

ll calc(int i, int bit) {
	if (i == n + 1) {
		return 1;
	}
	if (d[i][bit] != -1) return d[i][bit];

	ll res = 0;

	FOR (j, 0, n - 1) {
		if ((((1 << j) & bit) == 0) && a[i][j + 1]) {
			res = (res + calc(i + 1, bit | (1 << j))) % K;
		}
	}

	//cout << i << " " << bit << " " << res << endl;

	return d[i][bit] = res;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    
    cin >> n;
    FOR (i, 1, n) {
    	FOR (j, 1, n) cin >> a[i][j];
    }

    FOR (i, 0, 21) {
    	FOR (j, 0, (1 << 21)) d[i][j] = -1;
    }

    cout << calc(1, 0) << endl;


    return 0;
}

Measured memory_bytes: 360832
#include <bits/stdc++.h>
using namespace std;
int H,W;
char a[1002][1002];
int dp[1002][1002];
const int MOD = 1e9+7;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>H>>W;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=W;i++){
        if(a[1][i]=='#'){
            break;
        }
        dp[1][i]=1;
    }

    for(int i=1;i<=H;i++){
        if(a[i][1]=='#'){
            break;
        }
        dp[i][1]=1;
    }
    for(int i=2;i<=H;i++){
        for(int j=2;j<=W;j++){
            if(a[i][j]=='#') continue;
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
        }
    }
    cout<<dp[H][W];
    return 0;
}


Measured memory_bytes: 5120
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

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

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const lint INF=1e18;
lint n,s;
lint dsum(lint a,lint b){
  if(a==0) return 0;
  return a%b+dsum(a/b,b);
}
int main(){
  cin>>n>>s;
  lint res=INF;
  for(lint b=2;b*b<=n;++b){
    if(dsum(n,b)==s){
      chmin(res,b);
    }
  }
  if(n==s) chmin(res,n+1);
  if(n-s>0){
    for(lint b=1;b*b<=n-s;++b) if((n-s)%b==0){
      {
        lint B=b+1;
        lint a=(n-s)/(B-1);
        if(a<B && a>=0 && (s-a)>=0 && (s-a)<B) chmin(res,(lint)B);
      }
      {
        lint B=(n-s)/b+1;
        lint a=(n-s)/(B-1);
        if(a<B && a>=0 && (s-a)>=0 && (s-a)<B) chmin(res,(lint)B);
      }
    }
  }
  if(res==INF) res=-1;
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 384