akhauriyash/Code-Regression huggingface dataset:
N = int(input())
XY = [list(map(int, input().split(" "))) for _ in range(N)]

d = {(-1, -1): 0}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = XY[i]
        x2, y2 = XY[j]
        x3, y3 = x2-x1, y2-y1
        if x3 < 0 or (x3 == 0 and y3 < 0):
            x3, y3 = -1*x3, -1*y3
        pos = (x3, y3)
        if pos not in d:
            d[pos] = 0
        d[pos] += 1

# print(d.values(), d, max(d.values()))
print(N - max(d.values())//2)

Measured memory_bytes: 3188
N = int(input())
S = [input() for i in range(N)]

ans = 0
A = B = BA = 0
for s in S:
    for i in range(len(s) - 1):
        if s[i] + s[i + 1] == 'AB':
            ans += 1

    if s[-1] == 'A' and s[0] == 'B':
        BA += 1
    elif s[-1] == 'A':
        A += 1
    elif s[0] == 'B':
        B += 1


if (A > 0) & (B > 0) & (BA > 0):
    ans += BA + 1
    A, B = A - 1, B - 1
    ans += min(A, B)

elif (A > 0) & (B > 0):
    ans += min(A, B)

elif A > 0:
    ans += BA

elif B > 0:
    ans += BA

elif BA > 0:
    ans += (BA - 1)

print(ans)

Measured memory_bytes: 46424
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	int size = str.size();
	string strA,strB;
	for(int i=(size)/2 -1;i>0;--i){
		strA = str.substr(0,i);
		strB = str.substr(i,i);
		if( strA == strB ){
			cout << i*2 << endl;
			return;
		}
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

int med(const std::vector<int>& xs) {
    int n = xs.size();
    if (n % 2 == 0) {
        return xs[n / 2 - 1] + xs[n / 2];
    } else {
        return xs[n / 2];
    }
}

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> ls(n), rs(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> ls[i] >> rs[i];
    }

    std::sort(ls.begin(), ls.end());
    std::sort(rs.begin(), rs.end());

    std::cout << med(rs) - med(ls) + 1 << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 4760
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<int> a(n), b(n);
	rep(i,n){
		cin >> a[i] >> b[i];
	}
	sort(all(a));
	sort(all(b));

	int cnt = 0;
	int p = n - 1;
	while(h > 0){
		if(n >= 0 and b[p] > a.back()){
			cnt++;
			h -= b[p];
			p--;
		}else{
			cnt += h / a.back();
			if(h % a.back() != 0) cnt++;
			break;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    cum = 0
    d = {}
    d[0] = 1
    ans = 0
    
    for num in a:
        cum += num
        cum %= M
        if cum not in d:
            d[cum] = 1
        else:
            ans += d[cum]
            d[cum] += 1
        
    print(ans)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 56816
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vll vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//以上テンプレ

int main(){
    string X;
    cin>>X;
    stack<char> ans;
    ll a=X.size();
    rep(i,a){
        if(X.at(i)=='S'){
            ans.push('S');
        }else if(X.at(i)=='T'&&ans.empty()){
            ans.push('T');
        }else if(X.at(i)=='T'&&ans.top()=='S'){
            ans.pop();
        }else{
            ans.push('T');
        }
    }
    cout<<ans.size()<<endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a>b){
    swap(a,b);
  }
  if (a>c){
    swap(a,c);
  }
  if (b>c){
    swap(b,c);
  }
  cout << a << ' ' << b << ' ' << c <<endl;
    
  
  
}


Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>
#include <array>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cassert>

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;


int main()
{
	int N;
	cin >> N;
	int W[100];
	int abstotal = 0;
	int S1 = 0;
	int S2 = 0;
	int difference = 10000;
	int newDiff = 0;
	
	for (int i = 0; i < N; i++)
	{
		cin >> W[i];
		abstotal += W[i];
	}

	for (int i = 0; i < N; i++)
	{
		S1 += W[i];
		S2 = abstotal - S1;
		newDiff = abs(S1 - S2);
		if (newDiff < difference)
		{
			difference = newDiff;
		}
		else
		{
			cout << difference;
			break;
		}
	}

	system("pause");
	
	return 0;
}



Measured memory_bytes: 504
import java.util.*;

class Main {
	public static void main(String...args) {
		Scanner scan = new Scanner(System.in);
		int count = 0;
		int[] arryS;
		int[] arryT;
		int sSize;
		int tSize;
		int sentinel;

		sSize = scan.nextInt();
		arryS = new int[sSize];
		for(int s = 0; s < sSize; s++){
			arryS[s] = scan.nextInt();
		}

		tSize = scan.nextInt();
		arryT = new int[tSize];
		for(int t = 0; t < tSize; t++){
			arryT[t] = scan.nextInt();
		}

		for(int i = 0; i < tSize; i++){
			for(int n = 0; n <sSize; n++){
			    if(arryT[i] == arryS[n]){
			        count++;
			        break;
			    }
			}
		}
		System.out.println(count);
	}
}



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

int main() {
  int n;
  cin >> n;
  int* S = new int[n];
  for (int i = 0; i < n; i++)
    cin >> S[i];

  int q;
  cin >> q;
  int* T = new int[q];
  for (int i = 0; i < q; i++)
    cin >> T[i];

  int c = 0;
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (S[j] == T[i]) {
        c++;
        break;
      }
    }
  }
  cout << c << endl;

  delete[] S;
  delete[] T;

  return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<cmath>
int main(){
	int w, a, b, d;
  	std::cin >> w >> a >> b;
 	if(abs(a - b) > w)
      d = abs(a - b) - w;
  	else
      d = 0;
  	std::cout << d;
  	std::cout << std::endl;
  	return 0;
}


Measured memory_bytes: 256
def 解():
    iN = int(input())
    d={}
    for a in [int(_) for _ in input().split()]:
        if a in d:
            d[a] += 1
        else:
            d[a] = 1
    iMax = 0
    for a in d.keys():
        iMax = max(iMax,d.get(a,0) + d.get(a+1,0) + d.get(a-1,0))
    print(iMax)
解()


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	long long int i,j,k,l,m,n,t,temp,cnt=1;
	cin>>n>>k;
	long double a[n];
	for(i=0;i<n;i++)
	{
		cin>>t;
		a[i]=((double)t+(double)1)/(double)2;
	}
	long double sum=0,maxx=-1;
	for(i=0;i<k;i++)
	{
		sum=sum+a[i];
	}
	maxx=max(maxx,sum);
	j=0;
	for(i=k;i<n;i++)
	{
		sum=sum+a[i]-a[j];
		j++;
		maxx=max(sum,maxx);
	}
	cout<<fixed<<setprecision(15)<<maxx;
}

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


int main() {
    int n;
    cin>>n;
    int d[n];
    rep(i,n) cin>>d[i];

    int ans = 0;
    rep(i,n)rep(j,i) ans += d[i]*d[j];

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
L=list(map(int,input().split()))
if L.count(0)!=0:
  print(0)
else:
  L_1=sorted(L)
  x=1
  for i in range(n):
    x*=L_1[i]
    if x>10**18:
      x=-1
      break
  print(x)

Measured memory_bytes: 89384
S = input()
S = list(map(int, S))

t = 1
r = 0
d = [0] * 2019
d[0] += 1
for n in reversed(S):
    r = (r + n * t) % 2019
    t = t * 10 % 2019
    d[r] += 1

ans = 0
for m in d:
    ans += m * (m-1) // 2

print(ans)


Measured memory_bytes: 75736
import java.util.*;
public class Main {
	//定義関数から参照できる変数定義はこの辺
	static int N;
	static int [] Ary;
	static int ans=0;
	
	//分けて宣言する場合
	//int [] var;
	//var = new int [num];
	
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		Ary = new int[N+1];
		for(int i=1;i<=N;i++){
			Ary[i] = sc.nextInt();
		}

		Arrays.sort(Ary);
		
		if (Ary[N/2]<Ary[N/2+1]) {
			ans=Ary[N/2+1]-Ary[N/2];
		}
		else{
			ans=0;
		}
		System.out.println(ans);
		//System.out.print(ans);
    }
    //関数定義
	//public static int funk(long X,long A) {
    //    return ;    
    //}
}


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

long long gcd(int x, int y, int z) {
  long long a = min(min(x, y), z);
  long long b = 1;
  for(int i = 1; i <=a; i++) {
    if(x%i == 0 && y%i == 0 && z%i == 0) b = i;
  }
  return b;
}
  
int main() {
  
  int K;
  cin >> K;
  vector<int> X(K*K*K);
  
  int ans = 0;
  
  for(int i = 1; i <= K; i++) {
    for(int j = 1; j <= K; j++) {
      for(int l = 1; l <= K; l++) {
        ans += gcd(i, j, l);      
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 34308
#include <iostream>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
typedef long long ll;


const int mod=1000000007;

ll perm(ll num){
    ll n=1;
    for(ll i=num;i>0;--i){
        n=i*n%mod;
    }
    return n;
}

int main(){
    
    ll N,M;
    cin>>N>>M;
    
    ll ans=0;
    
    if(abs(N-M)==1){
        ans=perm(N)*perm(M)%mod;
    }else if(N==M){
        ans=perm(N)*perm(N)*2%mod;
    }
   
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 3636
import sys


def solv(i):
    r = 0.0
    j = 0
    for k in seq(i):
        j += 1
        if 10 < j:
            break
        else:
            r += k
    return r


def seq(init):
    s = []
    s.append(init)
    yield(init)
    while True:
        x = s[-1] * 2.0
        s.append(x)
        yield x
        y = s[-1] / 3.0
        s.append(y)
        yield y


for line in sys.stdin:
    i = float(line)
    print solv(i)

Measured memory_bytes: 4260
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N;
  cin >> N;
  
  ll chk = 0;
  ll count = 0;
  while(N>chk){
    count++;
    chk+=pow(26,count);
  }
  
  char ans[1000];
  ll tmp=N;
  
  rep(i,count){
    if(tmp%26!=0){
      ans[i] = tmp%26 + 'a' - 1;
      tmp = tmp/26;
    }else{
      ans[i] = 'z';
      tmp = (tmp-26)/26;
    }
  }
  
  rep(i,count){
	cout << ans[count-1-i];
  }
  
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe") << endl;
    
    return 0;
}


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

int main() {
  int a, b, num=0;
  cin >> a >> b;
  for (int i=a; i<=b; i++) {
    if (i%10 == i/10000)
      if ((i/10)%10 == (i/1000)%10)
      	num++;
  }
  cout << num << endl;
}


Measured memory_bytes: 256
def read_input():
    k, s = map(int, input().split())

    return k, s


def check_z(z, k):
    if z <= k:
        return z
    else:
        return -1


def check_yz(y, k):
    count = 0
    tempy = min(y, k)
    while tempy >= 0:
        if check_z(y - tempy, k) != -1:
            count += 1
        tempy -= 1
    return count

def check_xyz(x, k):
    count = 0
    tempx = min(x, k)
    while tempx >= 0:
        yc = check_yz(x - tempx, k)
        if yc != -1:
            count += yc
        tempx -= 1
    return count



def submit():
    k, s = read_input()

    print(check_xyz(s, k))

if __name__ == '__main__':
    submit()


Measured memory_bytes: 40560
#include<iostream>
using namespace std;
main()
{
   int A,B,y,z;
   cin>>A>>B;
   if(A>B)
   {
       if(B*2<A)
       {
           y=B*2;
       z=A-y;
       cout<<z<<endl;
       }
       else
        cout<<"0"<<endl;
   }
   else
    cout<<"0"<<endl;
}


Measured memory_bytes: 3592
import collections

N = int(input())
A = list(map(int,input().split()))
A = sorted(A)[::-1]

s = collections.Counter(A)
res = 1
count = 0

for i in sorted(list(set(A)))[::-1]:
    if 4 <= s[i] and count != 1:
        res *= i
        res *= i
        count += 2
    elif 2 <= s[i]:
        res *= i 
        count += 1

    if count == 2:
        break

if count == 2:
    print(res)
else:
    print(0)
    



Measured memory_bytes: 21796
using System;
using System.Linq;

public class HelloWorld
{        
    static public void Main ()
    {
        var AB = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        
        var A = AB[0];
        var B = AB[1];
        
        long x = CumXor(A-1);
        var y = CumXor(B);
           
        
        Console.WriteLine(x^y);
    }
    
    static long CumXor(long num){
        if(num < 0){
            return 0;
        }
        long res = num;
        if(num%2 == 0){
            long tmp = ((num)/2)%2 == 0 ? 0:1;
            res ^= tmp;
        }else{
            long tmp = ((num+1)/2)%2 == 0 ? 0:1;
            res = tmp;
        }
        return res;
    }
        
    
}


Measured memory_bytes: 13396
#include <cstdio>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll n,k;
ll f[2002][2002],s[2005],ans;
int main()
{
	scanf("%lld%lld",&n,&k);
	f[0][n+1]=1;	
	for(int i=1;i<=k;i++)
		for(int j=n+1;j;j--)
			s[j]=(s[j+1]+f[i-1][j])%mod,f[i][j]=(j<=n-i+1)?s[j]:0;
	ans=(f[k][1]-f[k-1][1]+mod)%mod;
	for(int i=1;i<n-k;i++)ans=(ans+ans)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31488
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

K = I()
n = len(LS2())
mod = 10**9+7

# 完成図は、
# (S[0]以外からなる文字列)S[0](S[1]以外からなる文字列)S[1]…(S[n-1]以外からなる文字列)S[n-1](任意の文字列)
# この表記は一意
# 形式的冪級数で考えると,
# 求めたいものは (1-25x)^(-n)*(1-26x)^(-1) の x^K の係数であり、
# これは、(i+n-1)_C_(n-1)*25^i*26^(K-i) を i=0,…,K にわたって足し合わせたものである

C = [1]
for i in range(1,K+1):
    C.append((C[-1]*(i+n-1)*pow(i,mod-2,mod)) % mod)
# C[i] = (i+n-1)_C_(n-1)

ans = 0
for i in range(K+1):
    ans += C[i]*pow(25,i,mod)*pow(26,K-i,mod)
    ans %= mod

print(ans)

Measured memory_bytes: 196396
import math
kaibun = input()
count = 0
lenstr = len(kaibun)

if lenstr%2 ==0:
  left = kaibun[:int(lenstr/2)]
  right = kaibun[int(lenstr/2):]
else:
  left = kaibun[:math.floor(lenstr/2)]
  right = kaibun[math.floor(lenstr/2):]

for i in range(len(left)):
  back = -1 * i -1
  if left[i] != right[back]:
    count+=1
print(count)


Measured memory_bytes: 3060
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,a,b) for (int i = a; i < (b); i++)
#define sz(t) int(t.size())
#define INF 1000000000
using namespace std;
typedef long long ll;


vector<tuple<int, int, int> > edges;
int d[2505];

vector<int> adj1[2505];
vector<int> adj2[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool valids[2505];

void dfs(int v, bool *arr, vector<int> *adj) {
    if (arr[v])
        return;
    arr[v] = true;
    for (auto u : adj[v]) {
        dfs(u, arr, adj);
    }
}

int main(void) {
    int n, m, p;
    cin >> n >> m >> p;
    REP(i, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        c -= p;
        edges.push_back(make_tuple(a, b, -c));
        adj1[a].push_back(b);
        adj2[b].push_back(a);
    }

    dfs(0, reachableFrom1, adj1);
    dfs(n - 1, reachableToN, adj2);

    REP(i, 0, n) valids[i] = reachableFrom1[i] & reachableToN[i];
    REP(i, 0, n) d[i] = INF;

    // REP(i, 0, n) cout << valids[i] << endl;

    bool updated = true;
    int nstep = 0;
    d[0] = 0;
    while (updated) {
        updated = false;
        for (auto e : edges) {
            int a, b, c;
            tie(a, b, c) = e;
            if (!valids[a] || !valids[b])
                continue;
            int newD = d[a] + c;
            if (newD < d[b]) {
                updated = true;
                d[b] = newD;
            }
        }

        nstep += 1;
        if (nstep >= n && updated) {
            cout << -1 << endl;
            return 0;
        }
    }

    int ans = -(d[n - 1]);
    ans = max(ans, 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main(){
  int k;
  int a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return(0);
    }
  }
  cout<<"NG"<<endl;
  return(0);
}

Measured memory_bytes: 3592
# include<iostream>
using namespace std;
int main(void)
{
    char a[4][4];
    int i, j;
    for(i = 0; i < 3; ++i)
        {
           cin >> a[i][0]>> a[i][1]>> a[i][2];
        }
    cout << a[0][0]<<a[1][1] << a[2][2] << endl;

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())
lcm = (c*d)//gcd(c, d)
ac = (a-1)//c
bc = b//c
ad = (a-1)//d
bd = b//d
acd = (a-1)//lcm
bcd = b//lcm
abc = bc-ac
abd = bd-ad
abcd = bcd-acd
print((b-a+1)-abc-abd+abcd)

Measured memory_bytes: 65260
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    
    return 0;
}

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

def f(b, c, th):
    '''
    >>> from math import pi
    >>> f(3, 4, pi / 2)
    5.0
    '''
    from math import cos
    return pow(b ** 2 + c ** 2 - 2 * b * c * cos(th), 0.5)


def solve(A: int, B: int, H: int, M: int):
    from math import pi
    m = M / 60
    h = (60 * H + M) / (12 * 60)
    return f(A, B, abs(h - m) * 2 * pi)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    print(solve(A, B, H, M))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    test()
    main()


Measured memory_bytes: 17940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

// INT VS LL

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    ll n = x / d;
    if (x >= 0){
	    if (k <= n){
	    	ll ans = x - k * d;
	    	cout << ans << '\n';
	    }
	    else{
	    	k -= n;
	    	ll ans = x - (n * d);
	    	cout << (k % 2 == 0 ? ans : abs(ans - d)) << '\n';
	    }
	}
	else{
		n *= -1LL;
		if (k <= n){
	    	ll ans = abs(x + k * d);
	    	cout << ans << '\n';
	    }
	    else{
	    	k -= n;
	    	ll ans = x + (n * d);
	    	cout << (k % 2 == 0 ? abs(ans) : abs(ans + d)) << '\n';
	    }
	}
    // if x 
    return 0;
}

Measured memory_bytes: 3640
n,m = list(map(int,input().split()))
ans = ''
l = ['a']*n
for i in range(m):
    s,c = list(map(int,input().split()))
    if l[s-1] != 'a' and l[s-1] != str(c):
        ans = str(-1)
    else:
        l[s-1] = str(c)
if n != 1 and l[0] == str(0):
    ans = str(-1)
if n != 1 and l[0] == 'a':
    l[0] = str(1)
if n == 1 and l[0] == 'a':
    l[0] = '0'
if n >=2:
    if l[1] == 'a':
        l[1] = str(0)
if n >=3:
    if l[2] == 'a':
        l[2] = str(0)
if ans != '-1':
    ans = ''
    for j in range(n):
        ans += l[j]
       
print(int(ans))

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

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)
#define FOREACH(i,x) for (__typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

char out[1000][1000];
string color = "RYGB";

int main() {
  // ios_base::sync_with_stdio(0);

  int H, W, D;
  scanf("%d%d%d", &H, &W, &D);
  int D2 = 1;
  while (D % (D2<<1) == 0) D2 <<= 1;
  D2 = max(1, D2/2);

  if (D&1) REP(i,H)REP(j,W) out[i][j] = color[(i^j)&1];
  else REP(i,H)REP(j,W) {
    int bit1 = ((i-j + 1000*D)/(D))&1;
    int bit2 = ((i+j)/(D))&1;
    out[i][j] = color[(bit2<<1) + bit1];
  }
  // REP(i,H)REP(j,W) {
    // int bit1 = (i^j^(i/D2)^(j/D2))&1;
    // int bit2 = ((i/D2)^(j/D2))&1;
  // }
  REP(i,H) printf("%s\n", out[i]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

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

    string s;
    int i=0, h[26]={0}, flag = 1;
    cin >> s;
    while(s[i]) {
        if(s[i]>=97&&s[i]<=122) h[s[i]-97]++;
        i++;
    }
    for(i=0;i<26;i++) {
        if(h[i]&1) {
            flag = 0;
            break;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
    cout << "\n";
    return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())


m = []

m = [2,3]
for i in range(2,87):
  m.append(m[i-2]+m[i-1])


def lucasnumber(n):
  if n == 0:
    return 2
  if n == 1:
    return 1
  if n == 2:
    return 3
  if n == 3:
    return 4
  return int(2*m[n-4]+m[n-3])

print(lucasnumber(n))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;
typedef pair <int, pii> piii;

vector <int> from[100010];
vector <piii> query;
int ans[100010];
int max_d[100010];

void print(int x, int d, int c){
//	cout << x << " " << d << " " << c << endl;
	if (max_d[x] >= d) return ;
	max_d[x] = d;
	if (ans[x] == 0) ans[x] = c;
	for (int i = 0; i < from[x].size(); i++){
		int v = from[x][i];
		print(v, d - 1, c);
	}
}

int main(){
	int n, m, q;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++){
		int u, v;
		scanf("%d%d", &u, &v);
		from[u].push_back(v);
		from[v].push_back(u);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		int v, d, c;
		scanf("%d%d%d", &v, &d, &c);
		query.push_back(mp(v, mp(d, c)));
	}
	reverse(query.begin(), query.end());
	memset(max_d, -1, sizeof(max_d));
	for (int i = 0; i < q; i++){
		piii t = query[i];
		print(t.fi, t.se.fi, t.se.se);
	}
	for (int i = 1; i <= n; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 8816
# O(N)
import collections
H, W, N = map(int, input().split())
table = collections.defaultdict(int) # (left, top) of 3x3 block => black count
for i in range(N):
    a, b = map(int, input().split())
    for yy in range(3):
        for xx in range(3):
            y = a - 1 - yy
            x = b - 1 - xx
            if 0 <= y and y + 2 < H and 0 <= x and x + 2 < W:
                table[(y, x)] += 1
counts = [0] * 10
for v in table.values():
    counts[v] += 1
counts[0] = (H - 2) * (W - 2) - sum(counts)
for c in counts:
    print(c)


Measured memory_bytes: 166860
n=int(input())
m=a=r=c=h=0
for i in range(n):
    s=input()
    if s[0]=='M':
        m+=1
    elif s[0]=='A':
        a+=1
    elif s[0]=='R':
        r+=1
    elif s[0]=='C':
        c+=1
    elif s[0]=='H':
        h+=1
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)

Measured memory_bytes: 3064
#include<iostream>

int main() {
	int a, b;
	std::cin >> a >> b;

	bool tab[100][100]{ };// Is a cell(h,w) white ?

	auto p = [&]() {
		for (const auto&e : tab) {

			for (const auto&ee : e)
				std::cout << (ee ? '.' : '#');// cond ? white:black

			std::cout << "\n";
		}
	};
//	p();

	for (auto&e : tab)
		for (auto&ee : e)
			ee = true;

	for (int hi{}; hi < 50; ++hi) {
		for (auto&e : tab[hi])
			e = !e;
	}

//	p();

	--a;
	--b;
	for (int wi{}; wi < 100; wi += 2) {

		for (int hi{}; hi < 49; hi += 2) {
			if (a == 0)
				break;

			auto & here = tab[hi][wi];
			here = !here;
			--a;
		}

		for (int hi{ 51 }; hi<100; hi += 2) {
			if (b == 0)
				break;

			auto& here = tab[hi][wi];
			here = !here;
			--b;
		}
	}

	std::cout << 100 << " " << 100 << "\n";
	p();
	/*for (auto&e : tab) {
		
		for (auto&ee : e)
			std::cout << (ee ? '.' : '#');
		
		std::cout << "\n";
	}*/
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		for(; scanner.hasNext(); )
		{
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if(a < b)
			{
				int buf = a;
				a = b;
				b = buf;
			}
			
			System.out.println(getGCD(a, b)+" "+getLCM(a, b));
		}
	}
	
	private static int getGCD(int a, int b)
	{
		for(;;)
		{
			if(a > b)
			{
				a = a % b;
				if(a == 0)
					return b;
			}
			else
			{
				b = b % a;
				if(b == 0) 
					return a;
			}
		}
	}
	
	private static int getLCM(int a, int b)
	{
		for(int n=b; ; n+=b)
		{
			if(n%a==0 && n%b==0)
			{
				return n;
			}
		}
	}
}

Measured memory_bytes: 26136
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll mn = min({a, b, c, d, e});
    cout << (n + mn - 1) / mn + 4;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"strconv"
	"time"
)

const (
	limitSecs = 2.0
)

// D
var (
	D         int
	c         [26]int
	s         [][26]int
	startTime time.Time
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func calcScore(t []int) int {
	var last [26]int
	score := 0
	S := 0
	for i := 0; i < 26; i++ {
		last[i] = -1
	}
	for d := 0; d < len(t); d++ {
		S += s[d][t[d]]
		last[t[d]] = d
		for i := 0; i < 26; i++ {
			S -= c[i] * (d - last[i])
		}
		score += max(1000000+S, 0)
	}
	return score
}

func solution3() []int {
	var t []int
	for d := 0; d < D; d++ {
		score := -1
		best := -1
		t = append(t, 0)
		for i := 0; i < 26; i++ {
			t[len(t)-1] = i
			newScore := calcScore(t)
			if newScore > score {
				best = i
				score = newScore
			}
		}
		t[len(t)-1] = best
	}
	return t
}

func optimize1(t []int) []int {
	rand.Seed(time.Now().UnixNano())
	score := calcScore(t)
	for time.Now().Sub(startTime).Seconds()+0.015 < limitSecs {
		d := rand.Intn(D)
		q := rand.Intn(26)
		old := t[d]
		t[d] = q
		newScore := calcScore(t)
		if newScore < score {
			t[d] = old
		} else {
			score = newScore
		}
	}
	return t
}

func main() {
	defer flush()

	startTime = time.Now()

	D = readInt()
	for i := 0; i < 26; i++ {
		c[i] = readInt()
	}
	s = make([][26]int, D)
	for i := 0; i < D; i++ {
		for j := 0; j < 26; j++ {
			s[i][j] = readInt()
		}
	}

	t := solution3()
	t = optimize1(t)
	for d := 0; d < D; d++ {
		println(t[d] + 1)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 2196
#include<stdio.h>

int cnt=0;

void insertionSort(int A[],int n, int g);
void shellsort(int A[],int n);
int main(void){

  int n,i;
  scanf("%d",&n);
  int a[n];

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

  shellsort(a,n);

  return 0;
}

void insertionSort(int A[],int n, int g){
  int i,v,j;

  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellsort(int A[],int n){
  int G[10000],m,i;
  cnt=0;

  G[0]=0;
  for(i=1;i<n+1;i++){
    G[i]=G[i-1]*4+1;
    if(G[i]>=n/4){
      m=i;
      break;
    }
  }
  printf("%d\n",m);


  for(i=0;i<m;i++){
    if(i==0){
      printf("%d",G[m-i]);
    }
    else{
      printf(" %d",G[m-i]);
    }
    insertionSort(A,n,G[m-i]);
  }
  printf("\n");
  printf("%d\n",cnt);

  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }
}



Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
    int n;
    cin >> n;
    int x;
    P mx = P(-1e9, 0);
    P mn = P(1e9, 0);
    cout << 2 * n - 1 << endl;
    rep(i, n)
    {
        cin >> x;
        mx = max(mx, P(x, i + 1));
        mn = min(mn, P(x, i + 1));
    }
    if (mx.first + mn.first >= 0)
    {
        for (int i = 1; i <= n; i++)
        {
            cout << mx.second << ' ' << i << endl;
        }
        for (int i = 2; i <= n; i++)
        {
            cout << i - 1 << ' ' << i << endl;
        }
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            cout << mn.second << ' ' << i << endl;
        }
        for (int i = n; i > 1; i--)
        {
            cout << i << ' ' << i - 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B >> C;
  if(A==B&&A!=C||A==C&&A!=B||B==C&&A!=B)Out("Yes");
  else Out("No");
}



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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


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

    int H, W;
    cin >> H >> W;

    VVI field(H, VI(W, 0));
    FOR(i, 0, H) {
        string s;
        cin >> s;
        FOR(j, 0, W) {
            field[i][j] = s[j] - '0';
        }
    }

    VVI dp(H, VI(W, INT_MAX));
    dp[0][0] = field[0][0];

    FOR(i, 0, H) {
        FOR(j, 0, W) {
            if (i + 1 < H) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + field[i + 1][j]);
            }
            if (j + 1 < W) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + field[i][j + 1]);
            }
        }
    }

    print(dp[H - 1][W - 1]);

    return 0;
}


Measured memory_bytes: 3248
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int main()
{
	int n;
	scanf("%d", &n);
	int x[101], mi = 100000000;
	for(int i = 0; i < n; scanf("%d", &x[i++]));
	sort(x, x + n);
	for(int i = x[0]; i <= x[n - 1]; ++i)
	{
		int total = 0;
		for(int j = 0; j < n; ++j)
		{
			total += (x[j] - i) * (x[j] - i);
		}
		mi = min(mi, total);
	}
	printf("%d\n", mi);
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if(A<=8 && B<=8) System.out.println("Yay!");
		else System.out.println(":(");

	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {
	
int n,q , i ,j,c=0;

	scanf("%d",&n);
	
int s[n];

for ( i=0; i < n; i++){
scanf("%d",&s[i]);

}
	scanf("%d",&q);
	
int t[q];

for ( i=0; i < q; i++){
scanf("%d",&t[i]);

}

for ( i=0; i < q; i++){
for ( j=0; j < n; j++){
  if ( s[j] == t[i]){c++;break;}

}
}
printf("%d\n",c);	
	
	return 0;
}



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

int main() {
    int x, y, tmp;

    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        if (x > y) {
            tmp = x;
            x = y;
            y = tmp;
        }
        cout << x << " " << y << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll n;
  string s,t;
  t="YAKI";
  cin >> s;
  n=s.length();
  if(n<4){
    printf("No");
    return 0;
  }
  rep(i,4){
    if(s[i]!=t[i]){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
}

Measured memory_bytes: 256
// ITP1_6_D:   Matrix Vector Multiplication
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101], c[101];
	int i, j;
	int n, m;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (j = 0; j < m; j++) scanf("%d", &b[j]);

	for (i = 0; i < n; i++) {
		c[i] = 0;
		for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
	}

	for (i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <cfloat>
using namespace std;
int main (){
 int a,c;
 char b;
cin >> a >> b >> c;
if(b=='+'){
cout << a + c;
}else{
    cout << a - c;
}
}

Measured memory_bytes: 256
S = input()

counter = []
cnt_dict = {'R':0, 'L':0}
for i in range(len(S)):
    l = S[i]
    if l == 'R':
        if cnt_dict['L'] == 0:
            cnt_dict[l] += 1
        else :
            counter.append(cnt_dict)
            cnt_dict = {'R':0, 'L':0}
            cnt_dict[l] += 1
    else :
        cnt_dict[l] += 1
counter.append(cnt_dict)
        
output = []
for c in counter:
    block_R = [0 for _ in range(c['R'])]
    block_L = [0 for _ in range(c['L'])]
    q, r = divmod((c['R'] + c['L']), 2)
    if r == 0:
        block_R[-1] = q
        block_L[0] = q
    else :
        if c['R'] % 2 == 0:
            block_R[-1] = q
            block_L[0] = q + r
        else :
            block_R[-1] = q + r
            block_L[0] = q
    
    
    output += block_R
    output += block_L
    
print(' '.join(map(str,output)))
    

Measured memory_bytes: 29204
#include<bits/stdc++.h>
#define lli unsigned long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;


void solve(){
    lli n,h,mx=0,ans=1000000000000; cin>>h>>n;
    vector<lli> a(n), b(n);
    NA(i,0,n) cin>>a[i]>>b[i], mx = max(mx, a[i]);
    vector<lli> dp(h+10000, 1000000000000);
    NA(i,1,h+mx+1){
        NA(j,0,n){
            if(i>a[j]) dp[i] = min(dp[i], dp[i-a[j]]+b[j]);
            else dp[i] = min(dp[i], b[j]);
        }
        if(i>=h && i<=h+mx) ans = min(ans, dp[i]);
    }
    cout<<ans;
    return;
}

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


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

using namespace std;

#define ll long long

int main() {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n - 1);
	map<int,int> m;
	for(int i = 0; i < n - 1; ++i) {
		cin >> a[i];
		m[a[i]]++;
	}
	
	for(int i = 1; i <= n; ++i) {
		cout << m[i] << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 13556
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(S: str):
    print(S[:len(S)-8])
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var dic = new Dictionary<string, int>();

            long result = 0;
            for (int i = 0; i < N; i++)
            {
                var s = Console.ReadLine();

                var array = s.ToCharArray();
                Array.Sort(array);
                s = new string(array);

                if (dic.ContainsKey(s))
                {
                    dic[s]++;
                }
                else
                {
                    dic[s] = 0;
                }

                result += dic[s];
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 29144
#include<stdio.h>
#include<stdlib.h>
typedef struct{
    int tID;
    int time;
    int count;
    int c[10];
    int p[10];
    int penalty;
}Data;
Data icpc[50];
int T,P,R;
int comp(const void *a,const void *b){
    Data c = *(Data *)a;
    Data d = *(Data *)b;
    if(c.count>d.count) return -1;
    else if(c.count<d.count) return 1;
    else{
        if(c.penalty<d.penalty) return -1;
        else if(c.penalty>d.penalty) return 1;
        else{
            if(c.tID<d.tID) return -1;
            else return 1;
        }
    }
    return 0;
}
void init(){
    for(int i=0;i<50;i++){
        icpc[i].tID=i;
        icpc[i].time=0;
        icpc[i].count=0;
        for(int j=0;j<10;j++)
            icpc[i].c[j]=0,icpc[i].p[j]=0;
        icpc[i].penalty=0;
    }
}
int main(void){
    while(1){
        scanf("%d%d%d",&T,&P,&R);
        if(T+P+R==0) break;
        init();
        for(int i=0;i<R;i++){
            int tid,pid,time;
            char mes[10];
            scanf("%d%d%d%s",&tid,&pid,&time,mes);
            if(icpc[tid-1].c[pid-1]) continue;
            //printf("%c\n",mes[0]);
            if(mes[0]=='W'){
                icpc[tid-1].p[pid-1]++;
            }else{
                icpc[tid-1].count++;
                icpc[tid-1].c[pid-1]=1;
                icpc[tid-1].penalty+=icpc[tid-1].p[pid-1]*1200+time;
            }
        }
        qsort(icpc,T,sizeof(Data),comp);
        for(int i=0;i<T;i++){
            printf("%d %d %d\n"
                   ,icpc[i].tID+1,icpc[i].count,icpc[i].penalty);
        }
    }
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, i, j, k, m, INF = 1000000, x;
	vector<int> vv = { INF, 2, 5, 5, 4, 5, 6, 3, 7, 6 }, v;
	vector<string> vs = { "", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
	string ss;

	cin >> n >> m;
	v.assign(10, INF);
	while (m--) {
		cin >> x;
		v[x] = vv[x];
	}

	vector<string> dp(n + 1);
	dp[0] = "";
	for (i = 1; i <= n; i++) {
		dp[i] = "";
		for (j = 1; j <= 9; j++) {
			if ((v[j] != INF) && (i - v[j] >= 0) && ((i == v[j]) || (dp[i - v[j]] != ""))) {
				x = dp[i - v[j]].length() + 1;
				if (x > dp[i].length()) dp[i] = dp[i - v[j]] + vs[j]; 
				else if (x == dp[i].length()) {
					ss = dp[i - v[j]] + vs[j];;
					dp[i] = max(dp[i], ss);
				}
			}
		}
	}

	cout << dp[n] << "\n";

	return 0;
}

Measured memory_bytes: 39936
<?php

list($x, $n) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$p_array     = array_map('intval',explode(" ",trim(fgets(STDIN))));

if ( $n == 0 ) {
    echo($x)."\n";
    exit;
}

//初期化
$abs_array     = [];

//絶対値配列の作成
for ( $i=0; $i<$n; $i++ ) {
    array_push($abs_array,abs($x-$p_array[$i]));
}


//最小の絶対値の探索と当該値の取得
$min_value = (min($abs_array));
$min_index = array_search($min_value,$abs_array);

$answer;
//当該値に最も近い値の取得

$i=$p_array[$min_index];
$d=$p_array[$min_index];

while( true ) {

    if ( !in_array($d,$p_array) ) {
        $answer = $d;
        echo($answer)."\n";
        break;
    }
    if ( !in_array($i,$p_array) ) {
        $answer = $i;
        echo($answer)."\n";
        break;
    }
    if ( in_array($d,$p_array) && in_array($i,$p_array) ) {
        $d--;
        $i++;
        continue;
    }

}

?>

Measured memory_bytes: 16052
from math import gcd

k = int(input())

res = 0
mul = (0, 1, 3, 6)
for a in range(1, k+1):
    for b in range(a, k+1):
        for c in range(b, k+1):
            res += gcd(gcd(a, b), c) * mul[len({a, b, c})]

print(res)


Measured memory_bytes: 9080