akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a%2 == 1 && b%2 == 1){
    cout << "Odd" << endl;
  }else{
    cout << "Even" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from math import inf

n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[0]*n
cost[-2]=abs(h[-1]-h[-2])
for i in range(n-3,-1,-1):
  mini=inf
  for j in range(1,k+1):
    
    if i+j<n:
      #print(i,i+j,abs(h[i]-h[i+j])+cost[i+j])
      mini=min(abs(h[i]-h[i+j])+cost[i+j],mini)
  cost[i]=mini
print(cost[0])

Measured memory_bytes: 84748
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>
#include <cctype>
#include <sstream>
#include <numeric>

typedef long long lint;

using namespace std;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);++i)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define PI 3.141592653589793
#define acout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define sum(a) accumulate(all(a),0)

lint* arr1(lint x) {
	lint *array = new lint[x];
	rep(i, x)array[i] = 0;
	return array;
}
lint** arr2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {
	while (1) {
		int n=0;
		double sum=0,ave=0,A=0;
		cin >> n;
		if (n == 0)break;
		vector<lint> a,b;
		a.resize(n);
		b.resize(n);
		rep(i, n)cin >> a[i];
		rep(i, n)b[i] = a[i] * a[i];
		ave = 1.*sum(a)/n;
		A = sqrt(1.*sum(b)/n-ave*ave);
		acout << A<<"\n";
	}
}


Measured memory_bytes: 3252
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int):
    if X >= 30:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n)cin>>a[i];
  sort(rall(a));
  ll ans=a[0];
  ll i=1;
  ll cu=1;
  while(cu<n-1){
    cu++;
    ans+=a[i];
    if(cu%2==1) i++;
  }
  COUT(ans);
}

Measured memory_bytes: 4836
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
4 2
5 2
2 1
8 3

output:
13
"""

import sys
from collections import namedtuple


def solve():
    for i, item in enumerate(item_list, 1):
        for cp in range(1, real_cp + 1):
            if item.w <= cp:
                values[i][cp] = max(values[i - 1][cp], values[i - 1][cp - item.w] + item.v)
            else:
                values[i][cp] = values[i - 1][cp]
    return values[-1][-1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_items, real_cp = map(int, _input[0].split())
    items = map(lambda x: x.split(), _input[1:])

    Item = namedtuple('Item', 'v w')
    item_list = (Item(v=int(v), w=int(w)) for v, w in items)

    values = [[0] * (real_cp + 1) for _ in range(c_items + 1)]
    ans = solve()
    print(ans)

Measured memory_bytes: 27908
#include  <stdio.h>
int main(void) {

int a;
char b;
int c;
int d;

while (1) {d=0;
 scanf ("%d %c %d",&a,&b,&c);
 if (b=='+'){
    d=a+c;
    printf ("%d\n",d);
 }
 if (b=='-'){
    d=a-c;
    printf ("%d\n",d);
    }
 if (b=='*'){
    d=a*c;
    printf ("%d\n",d);
 }
 if (b=='/'){
    d=a/c;
    printf ("%d\n",d);
 }
 if (b=='?') break ;              }

 return 0;

}

Measured memory_bytes: 600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MAX 200010

typedef long int li;
li n;
li k;
li orbit[MAX]={};
li accum[MAX]={};
li len_orbit=0;
li term=0;
li* map[MAX];
li deg[MAX]={};
li a[MAX];


li next_orbit(li i);
li search(li t,li i);
li last_orbit(li t);

int main(){
  scanf("%d%ld",&n,&k);
  li i;
  for(i=1;i<=n;i++) map[i]=NULL;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    deg[a[i]]++;
    map[a[i]]=realloc(map[a[i]],sizeof(li)*deg[a[i]]);
    map[a[i]][deg[a[i]]-1]=i;
  }



  orbit[0]=0;len_orbit=1;
  i=0;
  do{
    if(df)printf("i:%d\n",i);
    i=next_orbit(i);
  }while(i!=0);
  
  if(df){
    printf("len:%d\n",len_orbit);
    for(i=0;i<len_orbit;i++){
      printf(" %d",orbit[i]);
    }
    printf("\n");
  }
  k%=term;
  if(k==0)return 0;
  i=last_orbit(k);
  if(df)printf("last:%d\n",i);
  while(i<n){
    li j=search(a[i],i);
    if(j==deg[a[i]]-1){
      printf("%d ", a[i]);
      i++;
    }else{
      i=map[a[i]][j+1]+1;
    }
  }

  return 0;
}

li next_orbit(li i){
  li j=search(a[i],i);
  if(df)printf("j:%d->",j,deg[a[i]]);
  if(j==deg[a[i]]-1){
    term++;
    j=0;
  }else j++;
  if(df)printf("j:%d,",j);
  i=map[a[i]][j]+1;
  if(i==n){term++; i=0;}
  if(df)printf("i:%d\n",i);
  accum[len_orbit]=term+1;
  orbit[len_orbit++]=i;
  return i;
}

li search(li t,li i){
  li a=0,b=deg[t]-1;
  if(map[t][b]==i)return b;
  while(b-a>0){
    li c=(a+b)/2;
    if(map[t][c]==i)return c;
    if(map[t][c]<i) a=c;
    else b=c;
  }
  return a;
}


li last_orbit(li t){
  li a=0,b=len_orbit-1;
  while(b-a>1){
    li c=(a+b)/2;
    if(accum[c]<= t)a=c;
    else b=c;
  }
  return orbit[a];
}



/// confirm df==0 ///


Measured memory_bytes: 15488
#include <iostream>

using namespace std;

string str[100] = { "KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR",
"AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA",
"AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABARA" }, s;//表和输入的字符串

int main()
{
    ios::sync_with_stdio(false);//加速
    cin >> s;//输入s
    for (int i = 0; i < 16; i++)//一共十六种可能，分别存在str[0]~str[15]中
        if (s == str[i])//如果匹配上了
            return cout << "YES\n", 0;//输出能并直接return 0
    cout << "NO\n";//如果没输出YES就是不匹配，输出NO
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N = in();
  int K = in();
  out(N%K != 0);
}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

template<class T> ostream& operator<<(ostream& os, const V<T> &v) {
    cout << "[";
    for (auto p: v) cout << p << ", ";
    cout << "]";
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    int n; ll x;
    cin >> n >> x;
    V<ll> a(n);
    ll sm = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sm += a[i];
    }
    if (x == sm) {
        cout << n << endl;
        return 0;
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    for (int i = 0; i < n-1; i++) {
        if (x >= a[i]) {
            x -= a[i];
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  char A[10],B[10],C[10];
  scanf("%s%s",A,B);
  int a,b=0;
  scanf("%d %d",&a,&b);
  scanf("%s",C);
  int i,v,u=0;
  for(i=0;i<10;i++)
  {
    if(C[i]=='\0')
    {
      break;
    }
    else if(C[i]!='\0'&&A[i]!='\0'&&C[i]!=A[i])
    {
      v++;
    }
    else if(C[i]!='\0'&&B[i]!='\0'&&C[i]!=B[i])
    {
      u++;
    }
  }
  if(v==0)
  {
    printf("%d %d",a-1,b);
  }
  else if(u==0)
  {
    printf("%d %d",a,b-1);
  }
  return 0;
}
  
  

Measured memory_bytes: 128
from sys import stderr
from functools import reduce
from operator import add
from bisect import insort
from fractions import gcd
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes" if n else "No")
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n, x = f()
X = sorted(f())
insort(X,x)
dist = [X[i+1]-X[i] for i in range(n)]
print(reduce(gcd, dist))

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

#define ff              first
#define ss              second
#define endl 			"\n"
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerbefone(x)    __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define Pi 				acos(-1.0)
#define precise(x,y)    fixed<<setprecision(y)<<x
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FIO;
	int tt = 1;
	// cin >> tt;
	while (tt--)
	{
		int n;
		cin >> n;
		vector<int> v(n + 1);
		int ans[n + 1];
		for (int i = 1; i <= n; i++)
		{
			cin >> v[i];
		}
		ans[1] = 0;
		ans[2] = abs(v[1] - v[2]);
		for (int i = 3; i <= n; i++)
		{
			ans[i] = min(abs(v[i] - v[i - 1]) + ans[i - 1], abs(v[i] - v[i - 2]) + ans[i - 2]);
		}
		cout << ans[n] << endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    n = n % 10;
    string ans;
    if (n == 0 || n == 1 || n == 6 || n == 8) {
        ans = "pon";
    } else if (n == 3) {
        ans = "bon";
    } else {
        ans = "hon";
    }
    cout << ans << "\n";
}


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

int x, y;

int main()
{
    scanf("%d %d", &x, &y);
    int dif = abs(abs(x) - abs(y));
    if (x + dif == y) printf("%d\n", dif);
    else if (-x + dif == y) printf("%d\n", dif + 1);
    else if (-(x + dif) == y) printf("%d\n", dif + 1);
    else if (-(-x + dif) == y) printf("%d\n", dif + 2);
    return 0;
}


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

using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    while (t--) {
        int n, d;
        scanf("%d%d", &n, &d);
        if (n&1) printf("%d\n", (n-1)*127+d);
        else printf("%d\n", (n-1)*127+(d^127));
    }
}


Measured memory_bytes: 256
import java.util.*;
	import java.lang.Math;
    public class Main
	{
		
		public static void main(String args[])
		{
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();
			int k = scan.nextInt();
			int m = 100*(10-n);
			if(n<10)
				System.out.println(k+m);
			else
				System.out.println(k);
			
		}
    }

Measured memory_bytes: 21716
class dsu:
    def __init__(self, N):
        self.root = [-1 for _ in range(N)]
        self.size = [1 for _ in range(N)]

    def merge(self, x, y):
        x = self.leader(x)
        y = self.leader(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.root[x] = y
            self.size[y] += self.size[x]
        else:
            self.root[y] = x
            self.size[x] += self.size[y]
    
    def leader(self, x):
        while self.root[x] >= 0:
            x = self.root[x]
        return x

    def same(self, x, y):
        return self.leader(x) == self.leader(y)

N, Q = [int(_) for _ in input().split()]
uf = dsu(N)

for i in range(Q):
    t, u, v = [int(_) for _ in input().split()]
    if t == 0:
        uf.merge(u, v)
    else:
        if uf.same(u, v):
            print(1)
        else:
            print(0)


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

int main() {
	//入力
	string k;
	cin >> k;

	//処理
	int ans = 0;
	if (k.at(0) == '1') ans++;
	if (k.at(1) == '1') ans++;
	if (k.at(2) == '1') ans++;

	cout << ans << endl;
}

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

int main (int argc, char * argv[])
{
    int n;
    char s1[100];
    char s2[100];
    int a=0,b=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %s",s1,s2);
        if(strcmp(s1,s2)==0){
            a+=1;
            b+=1;
        }else if(strcmp(s1,s2)>0){
            a+=3;
        }else if(strcmp(s1,s2)<0){
            b+=3;
        }
    }
    printf("%d %d\n",a,b);
    return 0;
}



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

  if(n<2){
    std::cout << "1" << '\n';
    return 0;
  }

  int temp=2;
  while (temp*2<=n ) {
    temp*=2;
  }
  std::cout << temp << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    int numS = stoi(s);
    int save = numS;
    int a = 0;
    REP(i, s.size() + 1){
        a += numS % 10;
        numS /= 10;
    }
    if(save % a == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>

using namespace std;

typedef complex<double> point;
double cross(point a,point b){
    return imag(conj(a)*b);
}
double dot(point a,point b){
    return real(conj(a)*b);
}
int ccw(point a,point b,point c){
    b -= a; c-= a;
    if(cross(b,c) > 0) return 1;
    if(cross(b,c) < 0) return -1;
    if(dot(b,c) < 0) return 2;
    if(norm(b) < norm(c) ) return -2;
    return 0;
}

int main(){
    while(cin){
        vector<point> P;
        for(int i=0;i<3;i++){
            double y,x;
            if(not (cin >> x >> y)){
                goto end;
            }
            P.push_back(point(x,y));
        }
        point inner;
        cin >> inner.real() >> inner.imag();
        if((ccw(P[0],P[1],inner) == 1 and
            ccw(P[1],P[2],inner) == 1 and
            ccw(P[2],P[0],inner) == 1) or 
           (ccw(P[0],P[1],inner) == -1 and
            ccw(P[1],P[2],inner) == -1 and
            ccw(P[2],P[0],inner) == -1)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
end:;
    return 0;
}

Measured memory_bytes: 1236
list = []
for i in range(4):
    list.append(int(input()))


a = 0
b = 0
c = 0
res = 0
for a in range(list[0]+1):
    for b in range(list[1]+1):
        for c in range(list[2]+1):
            total = 500*a + 100*b + 50*c
            if total == list[3]:
                res += 1
print(int(res))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(){
	int N;cin>>N;
  	int dp[101000];
  	for(int i=0;i<101000;i++){
    	dp[i]=N;
    }
  
 	dp[0]=0;
  	for(int i=1;i<=N;i++){
    //1
    	dp[i]=min(dp[i],dp[i-1]+1);
    //6
      	for(int pow6=6;pow6<=i;pow6*=6){
        	dp[i]=min(dp[i],dp[i-pow6]+1);
        }
    //9
      	for(int pow9=9;pow9<=i;pow9*=9){
        	dp[i]=min(dp[i],dp[i-pow9]+1);
        }
    }
  
  	cout<<dp[N]<<endl;

}

Measured memory_bytes: 640
import math

N = int(input())

P = list(map(int,input().split()))
Q = list(map(int,input().split()))

def check(A):
    L = [j+1 for j in range(N)]
    ans = 0
    for i in range(N):
        a = L.index(A[i])
        ans += a*math.factorial(N-1-i)
        L.pop(a)
    return ans
p = check(P)
q = check(Q)
print(abs(p-q))

Measured memory_bytes: 3064
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int main(){
    string s;
    int k;
    int n;
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] - 'A' + 'a';
    cout << s << endl;
}

Measured memory_bytes: 256
use std::io::*;
fn main() {
    let mut n = String::new();    
    stdin().read_line(&mut n).unwrap();
    let n: i32 = n.trim().split_whitespace().collect::<Vec<&str>>()[0].parse().unwrap();

    let mut v = String::new();
    stdin().read_line(&mut v).unwrap();
    let v = v.trim().split_whitespace().collect::<Vec<&str>>();

    let mut vv: Vec<i32> = Vec::new();
    for i in v {
        vv.push(i.parse::<i32>().unwrap());
    }

    let mut c = String::new();
    stdin().read_line(&mut c).unwrap();
    let  c = c.trim().split_whitespace().collect::<Vec<&str>>();

    let mut cv: Vec<i32> = Vec::new();
    for i in c {
        cv.push(i.parse::<i32>().unwrap());
    }


    let mut ans = 0;
    for i in 0..n {
       if vv[i as usize] > cv[i as usize] {
            ans += vv[i as usize] - cv[i as usize];
       }
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352
S = input()
if S == "SUN":
    print(7)
if S == "MON":
    print(6)
if S == "TUE":
    print(5)
if S == "WED":
    print(4)
if S == "THU":
    print(3)
if S == "FRI":
    print(2)
if S == "SAT":
    print(1)


Measured memory_bytes: 3060
#include<iostream>
#include<array>

using namespace std;

int main(){
    int n, t, tmp, ans = 1;
    array<int, 1001> so;

    cin >> n;
    so.fill(0);

    for(int i = 2; i <= n; i++){
        tmp = i;
        t = 2;
        while(tmp != 1){
            if(tmp % t == 0){
                so[t]++;
                tmp /= t;
            }else{
                t++;
            }
        }
    }

    for(int i = 2; i <= n; i++){
        if(so[i] != 0){
            t = ans;
            if(ans >= 1000000007 / (so[i] + 1) ){
               for(int k = 0; k < so[i]; k++){
                    ans += t;
                    if(ans >= 1000000007) ans -= 1000000007;
                }
            }else{
                ans *= so[i] + 1;
            }
        }
    }

    cout << ans << endl;
}

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

function main()
	n = parseInt(readline())
	m = n
	k = 0
	for i in 1:9
		k += m%10
		m = div(m, 10)
	end
	if n%k == 0
		print("Yes")
	else
		print("No")
	end
end

main()

Measured memory_bytes: 107200
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  for(int x=0;x<W+2;x++){
  cout<<"#";
  }
  cout<<endl;
  string P;
  for(int p=0;p<H;p++){
    cin>>P;
    cout<<"#"<<P<<"#"<<endl;
  }
  for(int x=0;x<W+2;x++){
  cout<<"#";
  }
  cout<<endl;
}
    

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int& x : arr) cin >> x;

	for(int i = 0; i < n; i++) {
		for(int j = i; j < n; j++) {
			swap(arr[i], arr[j]);
			if(is_sorted(arr.begin(), arr.end())) {
				cout << "YES\n";
				return 0;
			}
			swap(arr[i], arr[j]);
		}
	}
	cout << "NO\n";
}


Measured memory_bytes: 256
while 1:
    n=int(input())
    if n==0:break
    a = []
    for i in range(n):
        a+=[list(map(int, input().split()))]
        a[i]+=[sum(a[i])]
        for j in range(n):print('%5d'%a[i][j],end='')
        print('%5d'%a[i][n])
    a=list(zip(*a[::-1]))
    for i in range(n):print('%5d'%sum(a[i]),end='')
    print('%5d'%sum(a[n]))

Measured memory_bytes: 7620
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let ls = take 2 $ unfoldr f $ sortBy (flip compare) (0 : as)
    print $ if length ls == 2 then product ls else 0
    where
        f []    = Nothing
        f [_]   = Nothing
        f [_,_] = Nothing
        f (x:y:xs)
            | x == y    = Just (x, xs)
            | otherwise = f (y : xs)


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

#define sz(x) ((int)x.size())

using namespace std;











int main() {
	string s;
	int ans;
	cin >> s;
	ans = sz(s);
	for (int i = 0; i < sz(s) - 1; i++)
		if (s[i] != s[i + 1])
			ans = min(ans, max(i + 1, sz(s) - i - 1));
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int i,j;
    string s,t,x,s2;
    cin >> s >> t;
    s2 = s;
    int a,b;
    
    a = s.length();
    
    for (i=1;i<=a;i++){
        for (j=0;j<a;j++){
            if (j+i> a-1){
                s2[(j+i)-(a)]=s[j];
            }
            else
            s2[j+i]=s[j];
        }
        if (s2 == t){
            cout << "Yes";
            return 0;
        }
        
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int n,m;
  while(cin >> n >> m,n){
    vi sumh(n+1,0),sumw(m+1,0);
    FOR(i,1,n+1){
      int tmp;
      cin >> tmp;
      sumh[i] = sumh[i-1] + tmp;
    }
    FOR(i,1,m+1){
      int tmp;
      cin >> tmp;
      sumw[i] = sumw[i-1] + tmp;
    }
    vi kh,kw;
    for(int i = n;i > 0;i--){
      REP(j,i) kh.pb(sumh[i]-sumh[j]);
    }
    for(int i = m;i > 0;i--){
      REP(j,i) kw.pb(sumw[i]-sumw[j]);
    }
    sort(ALL(kh));
    sort(ALL(kw));
    int ans = 0;
    REP(i,(int)kh.size()){
      auto itr = equal_range(ALL(kw),kh[i]);
      ans += distance(itr.first,itr.second);
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 19724
s = int(input())
num = 10**9+7
n_list = [-1] * (s + 1)

def count_num(rest):
    result = 0
    if n_list[rest] != -1:
        result += n_list[rest]
    else:
        if rest < 3:
            pass
        elif rest < 5:
            result += 1
        else:
            result += 1
            for i in range(rest-2):
                result += count_num(i) % num
        result %= num
        n_list[rest] = result
    return result

print(count_num(s))



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vecs(F);
	fx(H) {
		vecps(F);
	}
	int ans = 0;
	fx(1<<H) {
		vecs(S);
		int v = x;
		int i = 0;
		while (v>0) {
			if ((v&1)==1) {
				pb(S, F[i]);
			}
			i++;
			v >>= 1;
		}
		fy(1<<W) {
			vec(C);
			int z = y;
			int j = 0;
			int sum = 0;
			while (z>0) {
				if ((z&1)==1) {
					fw(S.size()) {
						sum += S[w][j] == '#' ? 1 : 0;
					}
				}
				j++;
				z >>= 1;
			}
			if (sum==K) {
				ans++;
			}
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 3536
n = list(input())
if n[0] == "1":
  ans = "9"
else:
  ans = "1"
if n[1] == "1":
  ans = ans + "9"
else:
  ans = ans + "1"
if n[2] == "1":
  ans = ans + "9"
else:
  ans = ans + "1"
  
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>
using namespace std;
#define rep(i,n) for (int i=0 ; i<(n);i++)
#define INF 1e9+7
int main() {
	string a;
	cin >> a;
	if (a[0] == 'a' || a[0] == 'i' || a[0] == 'u' || a[0] == 'e' || a[0] == 'o')
		cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

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

int main(){
	int N;
	cin >> N;
	ll A[N];
	rep(i,N) cin >> A[i];

	int ans = 0;
	bool con = true;
	while (con) {
		rep(i,N) {
			if (A[i]%2 == 0) A[i] /= 2;
			else {
				con = false;
				break;
			}
		}
		ans += 1;
	}	
	ans -= 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
import numpy as np
 
n, m = map(int, input().split())
 
cards = list(map(int, input().split()))
cards = np.array(cards, np.int64)
cards.sort()

bc = [list(map(int, input().split())) for _ in range(m)]
bc = np.array(bc, np.int64)

B = bc[:,0]
C = bc[:,1]
 
#並び替えた配列のidxをnparrayで取得
idx = C.argsort()
B = B[idx][::-1]
C = C[idx][::-1]
 
p = 0
for b,c in zip(B,C):
    cards[p:p+b] = np.maximum(cards[p:p+b], c)
    p += b

print(sum(cards))

Measured memory_bytes: 38648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
  int n;
  cin >> n;
  vector<int> array(n);
  vector<int> odd_a(1e5+1, 0), even_a(1e5+1, 0);
  REP(i, n){
    cin >> array[i];
    if(i % 2 == 0){
      odd_a[array[i]]++;
    } else {
      even_a[array[i]]++;
    }
  }
  int max_odd, max_even, max_odd1, max_even1;
  int odd_count = 0;
  int even_count = 0;
  int odd_count1 = 0;
  int even_count1 = 0;
  int ans = 0;
  REP(i, 1e5+1) {
    if(odd_count < odd_a[i]){
      odd_count = odd_a[i];
      max_odd = i;
    }
  }
  REP(i, 1e5+1) {
    if(even_count < even_a[i]){
      even_count = even_a[i];
      max_even = i;
    }
  }
  if (even_count > odd_count){
    if (max_odd == max_even) {
      odd_count = 0;
      REP(i,1e5+1) {
        if (i != max_even && odd_count < odd_a[i]){
          odd_count = odd_a[i];
          max_odd = i;
        }
      }
      ans = n - even_count - odd_count;
    }else {
      ans = n - even_count - odd_count;
    }
  }else if (even_count < odd_count) {
    if (max_odd == max_even) {
      even_count = 0;
      REP(i,1e5+1) {
        if (i != max_odd && even_count < even_a[i]){
          even_count = even_a[i];
          max_even = i;
        }
      }
      ans = n - even_count - odd_count;
    }else {
      ans = n - even_count - odd_count;
    }
  } else {
    if (max_odd == max_even) {
      even_count1 = 0;
      REP(i,1e5+1) {
        if (i != max_odd && even_count1 < even_a[i]){
          even_count1 = even_a[i];
          max_even1 = i;
        }
      }
      odd_count1 = 0;
      REP(i,1e5+1) {
        if (i != max_even && odd_count1 < odd_a[i]){
          odd_count1 = odd_a[i];
          max_odd1 = i;
        }
      }
      ans = min(n - even_count - odd_count1, n - even_count1 - odd_count);
    } else {
      ans = n - even_count - odd_count;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)

Measured memory_bytes: 89220
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

if 1 in A:
    if N%2==0:
        print("1"*(N//2))
    else:
        if 7 in A:
            print("7"+"1"*(N//2-1))
        elif 5 in A:
            print("5"+"1"*(N//2-2))
        elif 3 in A:
            print("3"+"1"*(N//2-2))
        elif 2 in A:
            print("2"+"1"*(N//2-2))
        else:
            print("8"+"1"*(N//2-3))
else:
    B=[[] for i in range(0,10)]
    for i in range(0,M):
        if 2 in A:
            B[5].append(2)
        if 3 in A:
            B[5].append(3)
        if 4 in A:
            B[4].append(4)
        if 5 in A:
            B[5].append(5)
        if 6 in A:
            B[6].append(6)
        if 7 in A:
            B[3].append(7)
        if 8 in A:
            B[7].append(8)
        if 9 in A:
            B[6].append(9)


    dp=['n' for i in range(0,max(10,N+1))]
    for i in range(0,min(N+1,10)):
        if i==2:
            if 2 in A:
                dp[5]='2'
        if i==3:
            if 3 in A:
                dp[5]='3'
        if i==4:
            if 4 in A:
                dp[4]='4'
        if i==5:
            if 5 in A:
                dp[5]='5'
        if i==6:
            if 6 in A:
                dp[6]='6'
        if i==7:
            if 7 in A:
                dp[3]='7'
        if i==8:
            if 8 in A:
                dp[7]='8'
        if i==9:
            if 9 in A:
                dp[6]='9'

    if N>=6:
        a='0'
        b='0'
        c='0'
        if B[3]!=[]:
            b='77'
        if dp[6]=='n':
            a=int(a)
            b=int(b)
            c=int(c)
            x=max(a,b,c)
            if x!=0:
                dp[6]=str(x)
        else:
            a=int(a)
            b=int(b)
            c=int(c)
            d=int(dp[6])
            dp[6]=str(max(a,b,c,d))

    if N>=7:
        a='0'
        b='0'
        c='0'
        d='0'
        if B[3]!=[] and dp[4]!='n':
            b='7'+dp[4]
        if B[4]!=[] and dp[3]!='n':
            c='47'
        if dp[7]=='n':
            a=int(a)
            b=int(b)
            c=int(c)
            d=int(d)
            x=max(a,b,c,d)
            if x!=0:
                dp[7]=str(x)
        else:
            a=int(a)
            b=int(b)
            c=int(c)
            d=int(d)
            e=int(dp[7])
            dp[7]=str(max(e,a,b,c,d))

    for i in range(8,N+1):
        a='0'
        b='0'
        c='0'
        d='0'
        e='0'
        f='0'
        if B[3] and dp[i-3]!='n':
            b='7'+dp[i-3]
        if B[4] and dp[i-4]!='n':
            c='4'+dp[i-4]
        if B[5] and dp[i-5]!='n':
            d=str(max(B[5]))+dp[i-5]
        if B[6] and dp[i-6]!='n':
            e=str(max(B[6]))+dp[i-6]
        if B[7] and dp[i-7]!='n':
            f='8'+dp[i-7]
        a=int(a)
        b=int(b)
        c=int(c)
        d=int(d)
        e=int(e)
        f=int(f)
        x=max(a,b,c,d,e,f)
        if x==0:
            dp[i]='n'
        else:
            dp[i]=str(x)
    print(int(dp[N]))


Measured memory_bytes: 20048
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.14159265358979;

ll fac[MAX], finv[MAX], inv[MAX];
ll POW[MAX];

ll extgcd(ll a, ll b, ll& x, ll& y){
    ll d=a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }
    else{
        x=1;y=0;
    }
    return d;
}

void POWinit(){
    POW[0]=0;
    POW[1]=1;
    for(ll i=2;i<MAX;i++){
        POW[i]=POW[i-1]*i;
        POW[i]%=MOD;
    }
}


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

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod_inverse(ll a,ll mod){
    ll x,y;
    extgcd(a,mod,x,y);
    return (mod+x%mod)%mod;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,ans[1010]={};
    cin>>n>>k;
    COMinit();
    POWinit();
    if(n<k){
        cout<<0<<endl;
        return 0;
    }
    ans[1]=1;
    rep2(i,2,k+1){
        ans[i]=1;
        rep(j,n){
            ans[i]*=i;
            ans[i]%=MOD;
        }
        rep2(j,1,i){
            ans[i]-=COM(i,j)*ans[j]%MOD;
            ans[i]%=MOD;
            if(ans[i]<0) ans[i]+=MOD;
        }
    }
    // cout<<ans[k]<<endl;
    cout<<ans[k] * mod_inverse(POW[k],MOD) %MOD<<endl;
    return 0;
}


Measured memory_bytes: 19148
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);
    auto p = readln.split.to!(int[]).map!(i => i - 1).array;
    auto q = readln.split.to!(int[]).map!(i => i - 1).array;

    int a, b;
    int i;

    auto pm = iota(n).array;

    do {
        if (p == pm) a = i;
        if (q == pm) b = i;
        i++;
    } while (nextPermutation(pm));

    auto ans = abs(a - b);
    writeln(ans);
}














void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
def main():
    """
    1<=|s|<=5,000
    1<=K<=5
    """
    s = input()
    K = int(input())

    part(s, K)


def f(s, K):
    """
    K=1, sorted(s)[0]
    K=2, s[min_idx:min_idx+2]
        aabbaac

        min:a, next: aa
        aab<aac
    1-5文字: すべて異なる文字列なら1文字でよい

    minから5種類存在するなら不要
        K個以上存在する
    a: min
    aaaaa: 5th(aa,aaa,aaaaがあれば)

    abced: 完了
    babcd: 途中にaがあるから未完
     abcde: 完了,ただしaaaaaとかあったらNG
    """
    pass


def part(s, K):
    #s = "abcde" * 1000
    n = len(s)
    ss = set()
    for i in range(n):
        # 最初なぜかn文字まで繰り返していたが、辞書順を考えれば不要
        for j in range(i, i+K):
            subs = s[i:j+1]
            # print(subs, i, j, sep="\t")
            ss.add(subs)

    ans = sorted(ss)[K-1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4464
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

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

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


class ECountMedian {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);

        int64_t n;cin >> n;
        vector<pair<int64_t ,int64_t >> range(n);
        rep(i,n)cin >> range[i].first >> range[i].second;

        if(n % 2 == 0){
            vector<int64_t> a(n),b(n);
            rep(i,n)a[i] = range[i].first,b[i] = range[i].second;
            sort(a.begin(),a.end());
            sort(b.begin(),b.end());

            int64_t x0 = 2 * a[(n-1)/2],x1 = 2 * a[n/2];
            int64_t y0 = 2 * b[(n-1)/2],y1 = 2 * b[n/2];

            cout << max((int64_t)0,-((abs(x0 + x1)/2) - (abs(y0 + y1)/2)) + 1) << '\n';
        }else{
            vector<int64_t> a(n),b(n);
            rep(i,n)a[i] = range[i].first,b[i] = range[i].second;
            sort(a.begin(),a.end());
            sort(b.begin(),b.end());

            cout << max((int64_t)0,1 + b[n/2] - a[n/2])  << '\n';

        }

	}
	void main2(istream& cin,ostream& cout){

	}
};


int main() {
	ECountMedian solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9516
import sys
fin = sys.stdin.readline


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    gcd_ = gcd(a, b)
    return gcd_ * (a // gcd_) * (b // gcd_)


N = int(fin())
T_list = [int(fin()) for _ in range(N)]

if N == 1:
    print(T_list[0])
else:
    common_lcm = lcm(T_list[0], T_list[1])
    for T in T_list[1:]:
        common_lcm = lcm(common_lcm, T)
    print(common_lcm)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int digit(int num){
	int cnt=0;
	while(num>0){
		num/=10;
		cnt++;
	}
	return cnt;
}

int main(){
	int A[210],B[210];
	int N;
	for(int i=1;i<=200;i++){
		cin>>A[i]>>B[i];
		if(cin.eof()){
			N=i-1;
			break;
		}
	}
	for(int i=1;i<=N;i++){
		cout<<digit(A[i]+B[i])<<endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int h,w; cin>>h>>w;
  vector<string> a(h);
  rep(i,h) cin>>a[i];

  set<int> t;
  set<int> y;

  rep(i,h){
    bool c=1;
    // cout<<"i "<<i<<endl;
    rep(j,w){
      if(a[i][j]=='#')
      c=0;
    }
    if(c){
      // cout<<"i ireru "<<i<<endl;
      y.insert(i);
    }
  }
  rep(i,w){
    bool c=1;
    rep(j,h){
      if(a[j][i]=='#')
      c=0;
    }
    if(c)
    t.insert(i);
  }

  rep(i,h){
    if(y.count(i))
    continue;
    rep(j,w){
      if(t.count(j))
      continue;
      cout<<a[i][j];
    }
    cout<<endl;
    // cout<<"aa"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int i, ans = 0;
	char S[5];

	scanf("%s", &S);

	for (i = 0; i < 4; i++) {
		if (S[i] == '+')
			ans = ans + 1;
		else if (S[i] == '-')
			ans = ans - 1;
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

int mod=1e9+7;
int dp[120][100100];

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for (int ko=0;ko<=k;ko++){
            if(ko==0){
                dp[i][0]=1;
            }else if (ko<=v[i-1]){
                dp[i][ko]=(dp[i][ko-1]+dp[i-1][ko])%mod;
            }else{
                dp[i][ko]=((dp[i][ko-1]+dp[i-1][ko])%mod-dp[i-1][ko-1-v[i-1]]+mod)%mod;
            }
            
        }
    }
    
    
    cout<<dp[n][k];
    
   return 0;
   rep(i,n+1) {
        rep(j,k+1) {
            cout<<dp[i][j]<<',';
        }cout<<endl;
    }
}


Measured memory_bytes: 40832
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long n = sc.nextLong();
		long k = sc.nextLong();
		
		// 計算
		long result = 0;
		for(long b = 1; b <= n; b++){
		    long p = n/b;
		    long r = n%b;
		    result += max(b-k, 0)*p + max(r-k+1, 0);
			if(k == 0) result--;
		}
		
		// 出力
		System.out.println(result);
	}
}




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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

int main()
{
    int N, K; cin >> N >> K;
    vector<int> P(N); cin >> P;

    sort(P.begin(), P.end());
    int ans = 0;
    rep(i, K) {
        ans += P[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<map>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

int a;

int main()
{
	a=read();
	if(a%10==2||a%10==4||a%10==5||a%10==7||a%10==9)
		printf("hon\n");
	else if(a%10==0||a%10==1||a%10==6||a%10==8)
		printf("pon\n");
	else
		printf("bon\n");
	return 0;
} 


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    string s[n];
    int t[n];
    // std::vector<int> v;
    rep(i, n) {
        cin >> s[i] >> t[i];
        // v.push_back(t[i]);
    }
    string x;
    cin >> x;

    int num;
    rep(i, n) {
        if ( s[i] == x ) {
            num = i;
            break;
        }
    }

    ll ans = 0;
    for (int i = num+1; i < n; ++i) {
        ans += t[i];
    }
    cout << ans << endl;
    // cout << accumulate(v.at[num+1], v.end()) << endl;
    return 0;
}


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

using Int = int;
using namespace std;


struct digit{
	static Int x[10][10];
	Int val;
	digit(Int val) : val(val) {}
	digit operator*(const digit &a){
		return digit(x[val][a.val]);
	}
	operator int(){
		return val;
	}
} zero(0);

#define REP(i, n) for(digit i(0); i.val < (n); ++i.val)

Int digit::x[10][10];

Int out[10][10][10][10];

int main(){
	for(Int i = 0; i < 10; ++i) for(Int j = 0; j < 10; ++j) cin >> digit::x[i][j];

	// REP(i, 10) REP(j, 10) cout << i*j;
	
	Int count = 0;

	REP(a, 10) REP(b, 10) REP(c, 10) REP(d, 10){
		digit e = zero * a * b * c * d;
		REP(i, 10) if(a != i && zero * i * b * c * d * e == 0) goto DAME;
		REP(i, 10) if(b != i && zero * a * i * c * d * e == 0) goto DAME;
		REP(i, 10) if(c != i && zero * a * b * i * d * e == 0) goto DAME;
		REP(i, 10) if(d != i && zero * a * b * c * i * e == 0) goto DAME;
		REP(i, 10) if(e != i && zero * a * b * c * d * i == 0) goto DAME;
		if(a != b && zero * b * a * c * d * e == 0) goto DAME;
		if(b != c && zero * a * c * b * d * e == 0) goto DAME;
		if(c != d && zero * a * b * d * c * e == 0) goto DAME;
		if(d != e && zero * a * b * c * e * d == 0) goto DAME;
		goto YOSHI;
DAME:
		++count;
YOSHI:;
	}
	cout << count << endl;

}



Measured memory_bytes: 3100
# https://atcoder.jp/contests/abc044/tasks/abc044_a
n = int(input())
k = int(input())
x = int(input())
y = int(input())

amount = 0
if n < k:
    amount = n * x
else:
    amount = (k * x) + ((n - k) * y)

print(amount)


Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int main (){
  int n;
  cin >>n;
  int F[50];
  F[0] = F[1] = 1;
  for ( int i = 2; i <= n; i++) F[i] = F[i - 1] + F[i - 2];

  cout << F[n] << endl;

  return 0;

}

Measured memory_bytes: 1164
#include<stdio.h>

int main(void)
{
	int a, b, c;
	int i = 0;
	int divisors = 0;

	scanf("%d %d %d", &a, &b, &c);
	for (i = a; i <= b; i++)
	{
		if (c % i == 0)divisors++;
	}
	printf("%d\n", divisors);
	return 0;
}



Measured memory_bytes: 2140