akhauriyash/Code-Regression huggingface dataset:
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
void solve()
{
	ll i,ans=0,n,k;
	cin>>n>>k;
	vll a(n);
	rep(i,n)
		cin>>a[i];
	sort(all(a));
	reverse(all(a));
	if(k>=n)
	{
		cout<<0;
		return;
	}
	for(i=k;i<n;i++)
		ans+=a[i];
	cout<<ans;
}
int main()
{
	fast();
	ll t;
	t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long int 
#define f(i,n) for(int i=0;i<(n);i++)
#define rep(i,a,n) for(int i=(a);i<=(n);i++)
#define vi vector<int>
#define pi pair<int,int>
#define pb push_back
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define inf LONG_MAX
#define ninf LONG_MIN
const int mod = 1e9+7;

int32_t main() {
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  
  int n;
  cin>>n;
  int m=n%10;
  if(m==2 or m==4 or m==5 or m==7 or  m==9)
    cout<<"hon";
  else if(m==0 || m==1 || m==6 || m==8)
    cout<<"pon";
  else cout<<"bon";
  cout<<"\n";
  
  
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

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

    int n = s.size();

    rep(i, n) {
        if(i % 2 == 0) {
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        } else if (i % 2 != 0) {
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

vector<ll> factors(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i ++) if(n % i == 0) ret.push_back(i), ret.push_back(n/i);
    Sort(ret);
    Unique(ret);
    return ret;
}

int main(void){
    Cin(ll, n);
    auto f = factors(n);
    
    ll ans = 0;
    for(auto &d : f) if(d < n/d-1) ans += n/d-1;
    Cout(ans);
}


Measured memory_bytes: 384
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod=10**9+7

def coutwo(n):
    count=0
    flag=True
    while flag==True:
        if n%2==0:
            count+=1
            n=n//2
        else:
            flag=False
    return count
#print(coutwo(4))
n=I()
lis=LI()
ans=0
for i in range(n):
    ans+=coutwo(lis[i])
print(ans)

Measured memory_bytes: 4448
x,y = map(int, input().split())
if x % 3 == 0 or y % 3 == 0:
  print(0)
else:
    a = [(x // 3) * y, (x - x // 3) * (y // 2), (x - x // 3) * (y - y // 2)]
    b = [(x // 3 + 1) * y, (x - x // 3 - 1) * (y // 2), (x - x // 3 - 1) * (y - y // 2)]
    c = [(y // 3) * x, (y - y // 3) * x // 2, (y - y // 3) * (x - x // 2)]
    d = [(y // 3 + 1) * x, (y - y // 3 - 1) * (x // 2), (y - y // 3 - 1) * (x - x // 2)]
    ans = min(max(a)-min(a),max(b)-min(b),max(c)-min(c),max(d)-min(d),x,y)
    print(ans)

Measured memory_bytes: 3064
# N, K = gets.chomp.split.map(&:to_i)
N = gets.chomp.to_i
Graph = {}
(N-1).times do 
  u, v, w = gets.chomp.split.map(&:to_i)
  u -= 1
  v -= 1
  Graph[u] ||= []
  Graph[u] << [v, w]
  Graph[v] ||= []
  Graph[v] << [u, w]
end

dist = Array.new(N, -1)  # distance of each node
dist[0] = 0
q = [0]
while (q.size() > 0)
  from = q.shift
  Graph[from].each do |(to, w)|
    if (dist[to] >= 0)  # Alreday visited
      next
    end
    dist[to] = dist[from] + w
    q << to
  end
end

dist.each do |d|
  if (d % 2 == 0)
    p 0
  else
    p 1
  end
end

Measured memory_bytes: 51708
n,k=map(int,input().split())

#k以下のn個の数字

ans=[0]*(k+1)
p=10**9+7
result=0
for i in range(k):
    num=k-i

    ans[num]=pow(k//num,n,p)
    j=2
    while num*j<=k:
        ans[num]-=ans[num*j]
        j+=1
    result+=((ans[num]*num)%p)    
    #print(num,ans)
print(result%p)

Measured memory_bytes: 68604
S = input()
d = {'N': 0, 'S': 0, 'W': 0, 'E': 0}
for s in S:
    d[s] = 1

ans = "Yes"
if (d['N'] ^ d['S']) or (d['W'] ^ d['E']):
    ans = "No"

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

#define NUM 3

int main(void){
	int num;
	int hours, minutes, seconds;
	int i;
	
	scanf("%d", &num);
	
	hours = num / 3600;
	num %= 3600;
	minutes = num / 60;
	num %= 60;
	seconds = num;
	
	printf("%d:%d:%d\n", hours, minutes, seconds);
	
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){

    int h, n;
    int i, a, x;

    x = 0;
    scanf("%d",&h);
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d",&a);
        x += a;
    }

    if(x < h) printf("No");
    else printf("Yes");


    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using ll = long long;
using namespace std;

int N;
vector<int> a;

int main() {
    cin >> N;
    a = vector<int>(N);
    int mx = 0;
    int mn = 0;
    cin >> a[0];
    for (int i = 1; i < N; i++) {
        cin >> a[i];
        if (a[mx] < a[i]) {
            mx = i;
        }
        if (a[mn] > a[i]) {
            mn = i;
        }
    }
    int m = 0;
    vector<pair<int, int>> p;
    if (abs(a[mx]) > abs(a[mn])) {
        for (int i = 0; i < N; i++) {
            a[i] += a[mx];
            m++;
            p.push_back(make_pair(mx + 1, i + 1));
        }
    }
    else {
        for (int i = 0; i < N; i++) {
            a[i] += a[mn];
            m++;
            p.push_back(make_pair(mn + 1, i + 1));
        }
    }
    if (a[0] > 0) {
        for (int i = 0; i < N - 1; i++) {
            a[i + 1] += a[i];
            m++;
            p.push_back(make_pair(i + 1, i + 2));
        }
    }
    else if (a[0] < 0) {
        for (int i = N - 2; i >= 0; i--) {
            a[i] += a[i + 1];
            m++;
            p.push_back(make_pair(i + 2, i + 1));
        }
    }
    cout << m << endl;
    for (auto e : p) {
        cout << e.first << " " << e.second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def main():
  H, W, D = map(int, input().split())
  num = [[] for _  in range(H*W)]
  for i in range(H):
    temp = list(map(int, input().split()))
    for j in range(len(temp)):
      num[temp[j]-1] = [i, j]
  #num = np.array(num)
  num_sum = [0]*(H*W)
  for i in range(D, H*W):
    num_sum[i] = num_sum[i-D] + (abs(num[i][0]-num[i-D][0])+ abs(num[i][1]-num[i-D][1]))
  Q = int(input())
  ans = []
  for i in range(Q):
    L, R = map(int, input().split())
    ans.append(num_sum[R-1]-num_sum[L-1])
  print(*ans, sep='\n')
if __name__ == "__main__":
  main()

Measured memory_bytes: 22864
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

char arr[100 +10];
void solve() {

    int n;
    SI(n);
    scanf("%s", arr);

    if(n % 2 != 0) {
        puts("No");
        return;
    }

    REP(i, n/2) {

        if (arr[i] != arr[i+n/2]) {
            puts("No");
            return;
        }

    }
    puts("Yes");

}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;

int main(){
    long H, W;
    cin >> H >> W;
    long ans = LONG_MAX;
    
    if(H % 3 == 0 || W % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    
    long S_max, S_min;
    
    // Hで分割
    S_max = (H / 3 + 1) * W;
    S_min = (H / 3) * W;
    ans = min(ans, S_max - S_min);
    
    // Wで分割
    S_max = H * (W / 3 + 1);
    S_min = H * (W / 3);
    ans = min(ans, S_max - S_min);
    
    // それ以外
    long S1, S2, S3;
    
    for(long i = 1; i < H; i++){
        S1 = i * W;
        
        if(W % 2 == 0){
            S2 = S3 = (H - i) * (W / 2); 
        }
        else{
            S2 = (H - i) * (W / 2);
            S3 = (H - i) * (W / 2 + 1);
        }
        
        S_max = max({S1, S2, S3});
        S_min = min({S1, S2, S3});
        
        ans = min(ans, S_max - S_min);
    }
    
    for(long i = 1; i < W; i++){
        S1 = H * i;
        
        if(H % 2 == 0){
            S2 = S3 = (H / 2) * (W - i);
        }
        else{
            S2 = (H / 2) * (W - i);
            S3 = (H / 2 + 1) * (W - i);
        }
        
        S_max = max({S1, S2, S3});
        S_min = min({S1, S2, S3});
        
        ans = min(ans, S_max - S_min);
    }
    
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>

int main(void) {
	double a, b, C;
	double PI = acos(-1);//PI=3.141593...
	double crad,S,L,h;

	scanf("%lf %lf %lf", &a, &b, &C);

	crad = C*PI / 180;

	S = a*b*sin(crad)/2;
	L = a + b + sqrt(a*a + b*b - 2 * a*b*cos(crad));
	h = (2 * S) / a;

	printf("%f\n%f\n%f\n", S, L, h);

	return 0;
}


Measured memory_bytes: 2904
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
A = []
for _ in range(N):
  A.append(reads())

necc = [[True] * N for _ in range(N)]

def fail():
  print(-1); exit()

for i, j, k in combinations(range(N), 3):
  if A[i][j] + A[j][k] < A[i][k] or A[i][j] + A[i][k] < A[j][k] or A[i][k] + A[j][k] < A[i][j]:
    fail()
  if A[i][j] + A[j][k] == A[i][k]:
    necc[i][k] = False
  if A[i][j] + A[i][k] == A[j][k]:
    necc[j][k] = False
  if A[i][k] + A[j][k] == A[i][j]:
    necc[i][j] = False

ans = sum(A[i][j] for i, j in combinations(range(N), 2) if necc[i][j])
print(ans)

Measured memory_bytes: 46684
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int answer=0;
	if(n%2==0)
		answer=a[n/2]-a[n/2-1];
	cout<<answer;
	return 0;
}


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int a, b; cin >> a >> b;
	int ans = a * b - a - b + 1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	int k;
	vector<int> vec(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> vec.at(i);
	}
	for (int i = 0; i < N; ++i)
	{
		if(vec.at(i)%2==0){
			if(vec.at(i)%6==0||vec.at(i)%10==0){
				k=k;
			}
          else{
            k=k+1;
            
		}
	}
    }
	if(k!=0){
		cout << "DENIED" << endl;
	}
	else{
		cout << "APPROVED" << endl;
	}

}

Measured memory_bytes: 256
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
count = 0

for i in range(N):
  for j in range(i + 1, N):
    dist = 0
    for k in range(D):
      dist += (X[i][k] - X[j][k]) ** 2
    
    dist = math.sqrt(dist)
    
    if dist.is_integer():
      count += 1
print(count)

Measured memory_bytes: 3064
n, k = map(int, input().split())
mod = 10**9 + 7

ans = 0
for i in range(n - k + 2):
    start = ((k+i) * ((k+i) - 1)) // 2
    stop = (2 * n - (k+i) + 1) * (k+i) // 2
    ans += stop - start + 1
    ans %= mod
print(ans)

Measured memory_bytes: 9200
N, K = map(int, input().split())
S = list(input())

for i in range(N):
    if i == K-1:
        if S[i] == "A":
            print("a", end="")
        elif S[i] == "B":
            print("b", end="")
        else:
            print("c", end="")
    else:
        print(S[i], end="")

print("")


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

int main() {
    int A, B, C, D, L, R;
    cin >> A >> B >> C >> D;
    L = A + B;
    R = C + D;
    if (L < R) {
        cout << "Right" << endl;
    } else if (L == R) {
        cout << "Balanced" << endl;
    } else {
        cout << "Left" << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
nums = list(map(int, input().split()))
allSum = sum(nums)
partSum = 0
ans = allSum
for i in range(n-1):
    partSum = partSum + nums[i]
    x = allSum - partSum
    y = partSum
    z = abs(x - y)
    if z < ans:
        ans = z
print(ans)

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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n,-1);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    c[0] = a[0];
    c[n-1] = b[n-1];
    if(a[n-1] != b[0]){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]){
            if(c[i]!=-1 && c[i]!=a[i]){
                cout << 0 << endl;
                return 0;
            }else c[i] = a[i];
        }else if(c[i]!=-1 && c[i] >a[i]){
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i=n-2;i>=0;i--){
        if(b[i]>b[i+1]){
            if(c[i]!=-1 && b[i]!=c[i]){
                cout << 0 << endl;
                return 0;
            }else c[i] = b[i];
        }else if(c[i]!=-1 && c[i]>b[i]){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for(int i=0;i<n;i++){
        if(c[i]==-1){
            ans *= min(a[i],b[i]);
            ans %= mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll cnt;
ll a[4005][3];
int main(){
	int n;
	string s;
	cin>>n;//字符的个数 
	cin>>s;//s是字符串 
	
	for(int i=0;i<n;i++)
		//a[i][0]从第i个数到结尾总共有多少个R G B（包含第i个数） 
		for(int j=i; j<n;j++)
		{
			if(s[j]=='R') a[i][0]++; //'R'
			else if(s[j]=='G') a[i][1]++;//'G'
			else if(s[j]=='B') a[i][2]++;	//'B'
		}
	
	int i,j,k;
	for(i=0;i<n-2;i++)
	{
		for(j=i+1;j<n-1;j++)
		{//k从j+1 
			if(s[j]!=s[i]){
				//判断剩下的应该是什么颜色 
				char re;//第三种颜色字符 
				if(s[i]!='R' && s[j]!='R') re='R';
				else if(s[i]!='G' && s[j]!='G') re='G';	
				else if(s[i]!='B' && s[j]!='B') re='B';
				//如果第三种颜色是R则加上从j+1到结尾总共还有多少个R 
				if(re=='R') cnt+=a[j+1][0];
				else if(re=='G') cnt+=a[j+1][1];
				else if(re=='B') cnt+=a[j+1][2];
				//如果j+(j-i)的位置恰好是第三种颜色则数值减去1 
				if(2*j-i<n && s[2*j-i]==re) cnt--;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include<iostream>
using namespace std;
int main(){
  int five=0;
  int seven=0;
  for(int i=0;i<3;i++){
    int a;
    cin>>a;
    if(a==5){
      five++;
    }else if(a==7){
      seven++;
    }
  }
  
  if(five==2&&seven==1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int yakusu[100];
  for(int i=0; i<100; i++){
    yakusu[i] = 0;
  }
  int count=0;
  for(int i=1; i<=100; i++){
    if(a%i == 0){
      if(b%i==0){
        yakusu[count] = i;
        count++;
      }
    }
  }
  sort(yakusu, yakusu+100);
  reverse(yakusu, yakusu+100);
  cout << yakusu[k-1] <<endl;
  return 0;
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int n;
string s;

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

    int ans = 1;
    for (int i = 1; i < n; i++)
    {
        if (s[i - 1] != s[i])
        {
            ans++;
        }
    }

    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;

  vector<int64_t> L(N + 1);
  L.at(0) = 2;
  L.at(1) = 1;

  for (int i = 2; i < N + 1; i++) {
    L.at(i) = L.at(i-1) + L.at(i-2);
  }

  cout << L.at(N) << endl;
}


Measured memory_bytes: 256
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main{
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;

		sc = new Scanner(in);

		int N = sc.nextInt();
		long[] a = new long[N];
		long sunuke = 0;
		long arai = 0;

		for(int i = 0; i < N; i++){
			a[i] = sc.nextLong();
			if(i >= 1){
				arai += a[i];
			}else{
				sunuke += a[i];
			}
		}

		long min = Math.abs(sunuke-arai);
		for(int i = 1; i < N-1; i++){
			sunuke += a[i];
			arai -= a[i];

			if(min > Math.abs(sunuke-arai)){
				min = Math.abs(sunuke-arai);
			}
		}
		System.out.println(min);
	}
}

/*
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class AtCoderBeginner078 {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		InputStream in = new FileInputStream("src/input.txt");
		//InputStream in = System.in;

		sc = new Scanner(in);

		int N = sc.nextInt();
		//long[] a = new long[N];
		Deque<Long> deque = new ArrayDeque<Long>();
		long sunuke = 0;
		long arai = 0;

		for(int i = 0; i < N; i++){
			deque.add(sc.nextLong());
		}

		sunuke = deque.pollFirst();
		arai = deque.pollLast();

		long min = sunuke-arai;
		while(!deque.isEmpty()){
			System.out.println(min + deque.toString());
			if(Math.abs(min + deque.getFirst())  > Math.abs(min - deque.getLast())){
				min -= deque.pollLast();
			}else{
				min += deque.pollFirst();
			}
		}
		//min = Math.abs(sunuke-arai);
		System.out.println(Math.abs(min));
	}
}
*/

Measured memory_bytes: 79268
mod = 10 ** 9 + 7

n, a, b = map(int,input().split())

def combmod(n,k,mod):
    a = 1
    b = 1
    for i in range(k):
        a = a * (n-i) % mod
        b = b * (i+1) % mod
    return a * pow(b, mod-2, mod) % mod

nca = combmod(n, a, mod) #comb(n, a, mod)#factorial(n) // factorial(a) // factorial(n-a)
ncb = combmod(n, b, mod) #comb(n, b, mod)#factorial(n) // factorial(b) // factorial(n-b)

ans = pow(2, n, mod)

ans -= 1 + nca + ncb
ans %= mod
print(ans)


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

int main()
{
    ll x;
    cin >> x;
    if (x >= 2000) {
        cout << 1 << endl;
        return 0;
    }
    int z = x / 100;
    if (x > 105 * z) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}



Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

L = [] 
if N % 2 == 0:
    for i in range(1,N//2+1):
        L.append(2 * i)
    L = sorted(L, reverse=True)
    for i in range(1,N//2+1):
        L.append(2 * i - 1)
else:
    for i in range(1,(N + 1)// 2 + 1):
        L.append(2 * i - 1)
    L = sorted(L, reverse=True)
    for i in range(1,(N + 1)// 2):
        L.append(2 * i)
        
ans = ''
for i,j in enumerate(L):
    ans  += str(A[j-1]) + ' '
print(ans)

Measured memory_bytes: 26020
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

int main(){
  ll n, k; cin >> n >> k;
  ll pattern = k;
  rep(i, 1, n){
    pattern *= k-1;
  }
  cout << pattern << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int N,M;
int a[100],b[100];
int mouitta[20];
int kosuu=0;


int dfs(int x,int* po){
    int kati=0;
    for(int i=0;i<N;i++){if(po[i]==0)kati=1;}
    if(kati==0){kosuu++;}
    else{
    int anal[N];
    for(int i=0;i<N;i++)anal[i]=po[i];
    for(int i=0;i<M;i++){
        if(a[i]==x+1&&anal[b[i]-1]==0){
            anal[b[i]-1]=1;
            dfs(b[i]-1,anal);
            anal[b[i]-1]=0;
        }
        if(b[i]==x+1&&anal[a[i]-1]==0){
            anal[a[i]-1]=1;
            dfs(a[i]-1,anal);
            anal[a[i]-1]=0;
        }
    }
    }
}


int main(void){
    scanf("%d %d",&N,&M);
    for(int i=0;i<M;i++)scanf("%d %d",&a[i],&b[i]);
    for(int i=0;i<N;i++)mouitta[i]=0;
    mouitta[0]=1;
    dfs(0,mouitta);
    printf("%d",kosuu);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define puu pair<ULL, ULL>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 2e3 + 5;
const int MOD = 1e9 + 7;
int s[N], t[N], n, m;
LL dp[N][N], S[N][N];
int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d", &s[i]);
    for (int i = 1; i <= m; ++i) scanf("%d", &t[i]);
    S[0][0] = 1;
    for (int i = 1; i <= max(n, m); ++i) S[0][i] = S[i][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if(s[i] == t[j]) {
                dp[i][j] = S[i-1][j-1];
            }
        }
        for (int j = 1; j <= m; ++j) {
            S[i][j] = (S[i-1][j]+S[i][j-1]-S[i-1][j-1]+dp[i][j])%MOD;
        }
    }
    printf("%lld\n", (S[n][m]+MOD)%MOD);
    return 0;
}



Measured memory_bytes: 62848
n = int(input())
xy = [list(map(int,input().split()))for _ in range(n)]

iti = -float("inf")
ni = -float("inf")
san = -float("inf")
yon = -float("inf")
for x,y in xy:
    iti = max(iti,x+y)
    ni = max(ni,x-y)
    san = max(san,-x+y)
    yon = max(yon,-x-y)

print(max(iti+yon,ni+san))

Measured memory_bytes: 45412
import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int m=sc.nextInt();
        int[]x=new int[m],y=new int[m];
        for(int i=0;i<m;++i){
            x[i]=sc.nextInt();
            y[i]=sc.nextInt();
        }
        int[]e=new int[1<<m];
        for(int i=0;i<1<<m;++i){
            if(Integer.bitCount(i)<4)continue;
            int max=0;
            for(int j=0;j<m;++j){
                if((i&1<<j)==0)continue;
                for(int k=0;k<m;++k){
                    if(j==k||(i&1<<k)==0)continue;
                    Map<Integer,Integer>hm=new HashMap<Integer,Integer>();
                    for(int l=0;l<m;++l){
                        if((i&1<<l)==0)continue;
                        int cl=x[l]*(y[k]-y[j])-y[l]*(x[k]-x[j]);
                        hm.put(cl,hm.getOrDefault(cl,0)+1);
                    }
                    int c=0;
                    for(Integer el:hm.values()){
                        if(el>=3)System.err.println("err hm="+hm);
                        if(el>=2)
                            c++;
                    }
                    max=Math.max(max,c);
                }
            }
            e[i]=max*(max-1)/2;
        }
        //System.err.println(Arrays.toString(e));
        int[]dp=new int[1<<m];
        for(int i=1;i<1<<m;++i){
            int b=i;
            int max=e[i];
            while(b>0){
                max=Math.max(max,dp[b]+e[b^i]);
                b=(b-1)&i;
            }
            dp[i]=max;
        }
        out.println(dp[(1<<m)-1]);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 681936
// In the Name of Allah
// Ya Ali

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define F first
#define S second
#define all( x ) x.begin() , x.end()
#define pb push_back
#define mp make_pair

const int maxn = 3010 ;
const int mod = 998244353 ;
const int INF = 1e9 + 10;

int n , dp[ maxn ][ maxn ] , k , a[ maxn ] ;

signed main()
{
 ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

 cin >> n >> k ;

 for(int i = 1 ; i <= n ; i ++)
   cin >> a[ i ] ;

 dp[ 0 ][ 0 ] = 1 ;

 for(int i = 1 ; i <= n ; i ++){
   for(int j = 0 ; j <= k ; j ++){
     dp[ i ][ j ] = (2*dp[ i-1 ][ j ])%mod ;
     if( a[ i ] <= j )dp[ i ][ j ] = (dp[ i ][ j ] + dp[ i-1 ][ j-a[ i ] ]%mod )%mod ;
   }
 }

 cout << dp[ n ][ k ]%mod ;

    return 0;
}


Measured memory_bytes: 74224
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())
    a.sort()
    a = tuple(a)
    TorF = [0] * (a[-1] + 1)
    for ae in a:
        TorF[ae] = 1
    for i1 in range(n - 1):
        a1 = a[i1]
        if TorF[a1]:
            m = a[-1] // a1 + 1
            for i2 in range(2, m):
                TorF[a1 * i2] = 0
        if a[i1 + 1] == a[i1]:
            TorF[a[i1]] = 0
    r = sum(TorF)
    print(r)

if __name__ == '__main__':
    main()

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

int main() {
    int64_t N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());

    double ans = v.at(0);
    for (int i = 1; i < N; i++) {
        ans = (ans + v.at(i)) / 2;
    }
    cout << fixed << setprecision(8);
    cout << ans << endl;
}

Measured memory_bytes: 3776
///
// File:  dpl_1_b.cpp
// Author: ymiyamoto
//
// Created on Wed Nov  1 23:21:00 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  int32_t N, W;
  cin >> N >> W;

  vector<pair<int32_t, int32_t>> items(N + 1);
  for (int32_t i = 1; i <= N; i++) {
    cin >> items[i].first;
    cin >> items[i].second;
  }

  vector<vector<uint32_t>> dp(N + 1, vector<uint32_t>(W + 1, 0));
  for (int32_t i = 1; i <= N; i++) {
    int32_t v = items[i].first;
    int32_t w = items[i].second;
    for (int32_t j = 0; j <= W; j++) {
      if (j - w >= 0) {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v);
      } else {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }

  cout << dp[N][W] << endl;

  return 0;
}

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a==c){
        cout<<no<<endl;
        return 0;
    }
    if(a==b) cout<<yes<<endl;
    else if(a==c) cout<<yes<<endl;
    else if(c==b) cout<<yes<<endl;
    else cout<<no<<endl;
  
}


Measured memory_bytes: 3604
/*
 
dunjen_master
 
*/
 

#include<bits/stdc++.h>

 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;

typedef long long int ll;

ll mul(ll a,ll b){

    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}




int main(){
 
    
      string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
 
    cout<<"No"<<endl;
    
 
    
    
 
    
}

    

    
 
    



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

int main() {
  int a, b;
  cin >> a >> b;
  if(a % 3 != 0 && b % 3 != 0 && (a + b) % 3 != 0)
    cout << "Impossible" << endl;
  else
    cout << "Possible" << endl;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
s = [input() for _ in range(H)]

import sys
for j in range(1,H-1):
    for i in range(1,W-1):
        if s[j][i] =='#':
            if s[j][i-1] == '#':
                pass
            elif s[j-1][i] == '#':
                pass
            elif s[j][i+1] == '#':
                pass
            elif s[j+1][i] == '#':
                pass
            else:
                print('No')
                sys.exit()
print('Yes')


Measured memory_bytes: 9116
#include<bits/stdc++.h>
#include<iostream>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BP(n) __builtin_popcount(n)
#define bs(v,x) binary_search(all(v),x)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(j,n) for (j=i+1;j<n;j++)
#define Unique(v) vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define mod 1000000007
#define PI acos(-1.0)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
/*void input(vector<int>& v,int n){ int i,io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<int> v) { int i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<char,int>  frequency(string v){ int i; map<char,int> m; rep (i,v.length()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
bool binary_pred(int a,int b){ return a==b; }*/
int main() {
	fastio;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	if (n>=30)
		cout<<"Yes"<<endl;
	else 
		cout<<"No"<<endl;
}



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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;

  if (S == U)
    A--;
  else
    B--;

  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

namespace {
using namespace std;
using ll = long long;
using ull = unsigned long long;
}

int X, Y, Z, K;
vector<ll> A, B, C;

void input() {
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    for (auto& a : A) cin >> a;
    B.resize(Y);
    for (auto& b : B) cin >> b;
    C.resize(Z);
    for (auto& c : C) cin >> c;
}

bool cut_search(ll p, vector<ll>* sums = nullptr) {
    int cnt = 0;
    for (auto a : A) {
        for (auto b : B) {
            for (auto c : C) {
                ll sum = a+b+c;
                if (sum < p)
                    break;
                cnt++;
                if (sums)
                    sums->push_back(sum);
                if (cnt >= K)
                    return true;
            }
        }
    }
    return cnt >= K;
}

void solve() {
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    ll l = 0, r = A[0]+B[0]+C[0];
    ll p = 0;
    while (l <= r) {
        ll c = (l+r)/2;
        if (cut_search(c)) {
            p = c;
            l = c + 1;
        } else {
            r = c - 1;
        }
    }
    vector<ll> sums;
    cut_search(p+1, &sums);
    sort(sums.rbegin(), sums.rend());
    for (auto sum : sums)
        cout << sum << endl;
    for (int i = sums.size(); i < K; i++)
        cout << p << endl;
}

int main() {
    input();
    solve();
    
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep0(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
#define N 200000005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
using namespace std;
int n,x[105],ans=N,cnt; 
int main() {
	cin>>n;
	rep1(i,1,n) cin>>x[i];
	sort(x+1,x+n+1);
	rep1(i,x[1],x[n]) {
		cnt=0;
		rep1(j,1,n) cnt+=(x[j]-i)*(x[j]-i);
		ans=min(ans,cnt);
	}
	cout<<ans; 
	re 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;

string s;
long long int k;

int main(){
        cin >> s;
        scanf("%lld",&k);

        for(long long int i=0;i<s.size() ; i++){
                if(k==0) break;
                if(('z'- s[i]+1)%26 <= k){
                        k = k - ('z'-s[i]+1)%26;
                        s[i]='a';
                }
        }

        if(k>0){
                if(s[s.size()-1]+k%('z'-'a'+1) > 'z'){
                        s[s.size()-1]=s[s.size()-1] + k%('z'-'a'+1)-'z'+'a'-1;
                }else {
                s[s.size()-1]=(s[s.size()-1]+k%('z'-'a'+1));
                }
        }

        cout << s << endl;

        return 0;
}

Measured memory_bytes: 512
from heapq import heappush, heappop
n, k =map(int, input().split())

#重み付きのヒープに入れる
L =[]
for i in range(n):
    t, d = map(int, input().split())
    heappush(L, (-d, t)) #降順にしたいけど,heapqが昇順固定なので、-にする

LL=[]
sum = 0
s = set()
for i in range(k):
    d, t = heappop(L)
    if t in s:
        heappush(LL, (-d, t)) #重複したものは交換対象としておく
    s.add(t)
    sum+=-d

ans = len(s)**2+sum

while L and LL:
    d, t = heappop(L)
    if t not in s:
        s.add(t)
        dd, _ = heappop(LL)
        sum = sum -dd +(-d)
        ans = max(ans, len(s)**2+sum)
print(ans)


Measured memory_bytes: 19232
N = int(input())
A = [int(i) for i in input().split()]
max_i = A.index(max(A))
min_i = A.index(min(A))
abs_max_i = max(max_i,min_i,key = lambda x:abs(A[x]))
print(2*N-2)
for i in range(N):
    [print("{} {}".format(abs_max_i+1, i+1)) if i != abs_max_i else None]
if A[abs_max_i] > 0:
    for i in range(N-1):
        print("{} {}".format(i+1, i+2))
else:
    for i in range(N-1,0,-1):
        print("{} {}".format(i+1, i))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

    int max = -1;
    int masu[2][n];
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> masu[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        int ans = 0;
        int idx;
        idx = i;
        for (int j = 0; j <= i; j++)
        {
            ans += masu[0][j];
        }
        for (int j = i; j < n; j++)
        {
            ans += masu[1][j];
        }
        if (max < ans)
        {
            // cout << "max=" << max << ",idx=" << idx << endl;
            max = ans;
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

b = [0]  # 黒の累積和
w = [0]  # 白の累積和

count_b = 0
count_w = 0
for i in range(n):
    if s[i] == "#":
        # 黒なら
        count_b += 1
    else:
        # 白なら
        count_w += 1
    b.append(count_b)
    w.append(count_w)

ans = n
for i in range(n+1):
    ans = min(ans, b[i]+w[-1]-w[i])
print(ans)


Measured memory_bytes: 12772
#include <stdio.h>

int main(int argc,char* argv[]){
  int n,i;
  long long int fact = 1;
  
  scanf("%d",&n);

  for(i = 1; i < (n+1); ++i){
    fact*=i;
  }

  printf("%lld\n",fact);
  
  return 0;
  
}

Measured memory_bytes: 0
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val ans = when(N % 10) {
      2, 4, 5, 7, 9 -> "hon"
      0, 1, 6, 8 -> "pon"
      else -> "bon"
    }
    out.println(ans)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


Measured memory_bytes: 34724
//
// Created by dina on 05/07/20.
//

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n; cin >> n;
    int ac_count = 0, tle_count = 0, wa_count = 0, re_count = 0;
    while(n--){
        string str; cin >> str;
        if(str == "AC") ac_count++;
        else if(str == "WA") wa_count++;
        else if(str == "TLE") tle_count++;
        else re_count++;
    }
    cout << "AC x " << ac_count << "\n";
    cout << "WA x " << wa_count << "\n";
    cout << "TLE x " << tle_count << "\n";
    cout << "RE x " << re_count << "\n";
    return 0;
}


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

using namespace std;

const int INF = 88888888;
const int N = 2502;

typedef vector<vector<int> > vvi;
typedef vector<int> vi;

#define all(x) (x).begin(), (x).end()

long long ans = 0;

int main()
{
    string s;
    cin >> s;
    long long cnt0 = 0, cnt1 = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '1') cnt1++;
        else cnt0++;
    }
    for (int j = 1; j <= cnt1; j++)
    {
        ans += (j + 1) / 2;
    }
    string s2 = "";
    for (int i = 0; i < s.size(); )
    {
        int j = i;
        while (j < s.size() && s[j] == s[i])
        {
            j++;
        }
        int cnt = j - i;
        if (s[i] == '0')
        {
            for (int j = 0; j < cnt; j++) s2 += "0";
        }
        else
        {
            for (int j = 0; j < cnt % 2; j++) s2 += "1";
            ans += 1ll * cnt0 * (cnt / 2);
        }
        i = j;
    }
    int z = 0, d = 0;
    for (int i = 0; i < s2.size(); i++)
    {
        if (s2[i] == '1')
        {
            if (d % 2 == 0) ans += (z / 2) + (cnt0 - z);
            else ans += ((z + 1) / 2) + cnt0 - z;
            d ^= 1;
        }
        else
        {
            z++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3920
import java.util.Scanner;

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

Measured memory_bytes: 17156