akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

int main() {
    while (1) {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0)
            break;

        rep(i, h) {
            rep(j, w) cout << "#";
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
<?php
fscanf(STDIN,"%d%d",$n,$m);
if($m==0){echo "0";exit;}
while($n--) {
  fscanf(STDIN,"%d%d%d",$x,$y,$z);
  $sum[0][] = $x + $y + $z;
  $sum[1][] =-$x + $y + $z;
  $sum[2][] = $x - $y + $z;
  $sum[3][] = $x + $y - $z;
}
$M = 0;
foreach($sum as $s) {
  sort($s);
  $M = max($M, abs(array_sum(array_slice($s, 0, $m))));
  $M = max($M, abs(array_sum(array_slice($s, -$m))));
}
printf("%d", $M);


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

using namespace std;

vector<int> h, st;
int k;

int dp(int c)
{
   if (st[c] != -1) return st[c];
   if (c == 1)
   {
      st[c] = abs(h[0] - h[1]);
      return st[c];
   }
   else if (c == 0)
   {
      st[c] = 0;
      return 0;
   }
   else
   {
      st[c] = numeric_limits<int>::max();
      for (int i = 1; i <= c and i <= k; i++)
      {
         st[c] = min(dp(c - i) + abs(h[c - i] - h[c]), st[c]);
      }
      return st[c];
   }
}

int main()
{
   int n;
   cin >> n; cin >> k;
   h = vector<int>(n);
   st = vector<int>(n, -1);
   for (int i = 0; i < n; i++)
   {
      cin >> h[i];
   }
   int res = dp(n - 1);
   cout << res;
   return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] v = new int[n];
    int[] c = new int[n];
    int ans = 0;

    for (int i = 0; i < n; i++) {
      v[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      c[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      if (v[i] > c[i]) {
        ans += v[i] - c[i];
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 35724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		int answer = 0;

		answer = (int)Math.pow(100, D) * (N + N / 100);

		System.out.println(answer);
	}
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int res = 0;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        if (tmp >= k) {
            ++res;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
H, W = gets.split.map(&:to_i)

G = []

H.times do
  a = Array.new(W)
  line = gets.chomp.bytes.push 35
  i, j = 0, 0
  while i <= W
    if line[i] == 35
      if j < i
        c = i - j
        k = j
        while k < i
          a[k] = c
          k += 1
        end
      end 
      i += 1
      j = i
    else
      i += 1
    end
  end
  G << a
end 
G << Array.new(W)

ans = 0
G.transpose.each do |ar|
  i, j = 0, 0
  local_max = 0
  while i <= H
    v = ar[i]
    if v.nil?
      if j < i
        local_max += (i - j)
        ans = local_max if ans < local_max
        local_max = 0
      end 
      i += 1
      j = i
    else
      local_max = v if local_max < v  
      i += 1
    end 
  end 
end
puts ans - 1


Measured memory_bytes: 81688
using System;

namespace DuplexPrinting
{
    class Program
    {
        static void Main(string[] args)
        {
            int inputNum = int.Parse(Console.ReadLine());
            int pageNum = inputNum / 2;
            int remainderNum = inputNum % 2;
            int resultNum = pageNum + remainderNum;
            Console.WriteLine(resultNum);


        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for( int i=0; i<N; i++ ){
			A[i] = sc.nextInt();
			B[i] = A[i];
		}
		Arrays.sort(B);
		for( int i=0; i<N; i++ ){
			if( A[i]==B[N-1] ){
				System.out.println(B[N-2]);
			}else{
				System.out.println(B[N-1]);
			}
		}
	}
}


Measured memory_bytes: 91044
N, M = map(int, input().split())
A = [-int(x) for x in input().split()]

import heapq
heapq.heapify(A)

for ticket_num in range(1,M+1):
    max_value = -1*heapq.heappop(A)
    heapq.heappush(A, -1*(max_value>>1))

print(-1*sum(A))

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

void solve(int n,int q){
    int a,b;
    vector<int> v(100,0);
    for(int i=0;i<n;i++){
        cin >> a;
        for(int j=0;j<a;j++){
            cin >> b;
            v[b-1]++;
        }
    }
    int ans=0;
    ans=*max_element(v.begin(),v.end());
    cout<<((ans>=q)?(max_element(v.begin(),v.end())-v.begin()+1):0)<<endl;
    
}

int main(void){
    int a,b;
    while(cin>>a>>b,a){
        solve(a,b);
    }
}

Measured memory_bytes: 3080
#include <iostream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if (n >= 2)
        ans += (n)*(n-1)/2;
    if (m >= 2)
        ans += (m)*(m-1)/2;

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long MOD = (long) (Math.pow(10, 9) + 7);
        String s = sc.next();
        System.out.println(s.charAt(0) + "" + (s.length() - 2) + "" + s.charAt(s.length() - 1));
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


Measured memory_bytes: 39204
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	int n;cin>>n;
	string s;cin>>s;
	int r=0;
	for(char c:s)if(c=='R')++r;
	int ans=r;
	for(int i=0;i<r;i++){
		if(s[i]=='R')--ans;
	}
	cout<<ans;
}
int main()
{	Fast;
	//int t;cin>>t;
	//while(t--)
	solve();
}

Measured memory_bytes: 3732
//    _____ _     _                _           _     _ _     _     
//    \_   \ |_  (_)___  __      _| |__   __ _| |_  (_) |_  (_)___ 
//     / /\/ __| | / __| \ \ /\ / / '_ \ / _` | __| | | __| | / __|
//  /\/ /_ | |_  | \__ \  \ V  V /| | | | (_| | |_  | | |_  | \__ \
//  \____/  \__| |_|___/   \_/\_/ |_| |_|\__,_|\__| |_|\__| |_|___/
//                                                                 
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=1e6+9;
int a,b,c;
vector<int>v;

int main(){
	cin>>a>>b>>c;
	v.pb(a);
	v.pb(b);
	v.pb(c);
	sort(all(v));
	if((v.back()!=v[0]&&v[0]==v[1])||(v.back()==v[1]&&v[1]!=v[0])) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
/* ABC105 - AtCoder Crackers
 * https://abc105.contest.Batcoder.jp/tasks/abc105_a
 */
#include <iostream>

int main(void) {

	int N, K;
	std::cin >> N >> K;

	int v = (N % K) == 0 ? 0: 1;

	std::cout << v << std::endl;

	return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n-1){
        if(a[i+1]<a[i]){
            ans += a[i] - a[i+1];
            a[i+1] = a[i]; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4776
q=[1.0]+[k=0]*n=gets.to_i
g=[]
$<.map{|s|a,b=s.split;(g[a.to_i-1]||=[])<<b.to_i-1}
g.map{|h|h.map{|t|q[t]+=q[k]/h.size};k+=1}
e=[a=0]*n
(s=m=0.0
g[k-=1].map{|t|s+=c=e[t];m=[m,c].max}
e[k]=1+s/z=g[k].size
z>1&&a=[a,q[k]*=(s-m)/~-z-s/z].min
)while k>0
p e[0]+a

Measured memory_bytes: 6268
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;	cin >> n >> k;
  vector<double> p(n);
  for(int i=0;i<n;i++){
    double per;	cin >> per;
    p.at(i)=(per+1)/2;
  }
  
  double sum=0;
  double ans=-1;
  queue<double>	que;
  for(double x:p){
    que.push(x);
    sum+=x;
    if(que.size()==k+1){
      sum-=que.front();
      que.pop();
    }
    ans=max(ans,sum);
  }
  printf("%.7f",ans);
}

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            if((a&1)==0 && (a%3!=0 && a%5 !=0)){
                System.out.println("DENIED");
                return;
            }
        }
        System.out.println("APPROVED");
    }
}


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

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

using namespace std;

const int INF=1<<29;

int solve(string a,string b,string c){
	auto build=[](string x,string y){
		int nx=x.length(),ny=y.length();
		vector<bool> flag(nx+1,true);
		rep(i,nx+1){
			rep(j,ny){
				if(i+j>=nx) break;
				if(x[i+j]!='?' && y[j]!='?' && x[i+j]!=y[j]){ flag[i]=false; break; }
			}
		}
		return flag;
	};

	int na=a.length(),nb=b.length(),nc=c.length();
	vector<bool> flag_ab=build(a,b);
	vector<bool> flag_ac=build(a,c);
	vector<bool> flag_bc=build(b,c);
	vector<bool> flag_cb=build(c,b);

	int res=INF;
	rep(i,na+1) if(flag_ab[i]) {
		rep(j,na+1) if(flag_ac[j]) {
			if(j<=i && i-j<=nc && flag_cb[i-j]) res=min(res,max({na,i+nb,j+nc}));
			if(j>=i){
				if((j-i<=nb && flag_bc[j-i]) || j-i>=nb) res=min(res,max({na,i+nb,j+nc}));
			}
		}
		for(int j=na;j<=i+nb;j++){
			if(flag_bc[j-i]) res=min(res,max(i+nb,j+nc));
		}
	}
	rep(i,na+1) if(flag_ac[i]) {
		rep(j,na+1) if(flag_ab[j]) {
			if(j<=i && i-j<=nb && flag_bc[i-j]) res=min(res,max({na,i+nc,j+nb}));
			if(j>=i){
				if((j-i<=nc && flag_cb[j-i]) || j-i>=nc) res=min(res,max({na,i+nc,j+nb}));
			}
		}
		for(int j=na;j<=i+nc;j++){
			if(flag_cb[j-i]) res=min(res,max(i+nc,j+nb));
		}
	}
	return res;
}

int main(){
	string a,b,c; cin>>a>>b>>c;
	cout<<min({solve(a,b,c),solve(b,c,a),solve(c,a,b)})<<'\n';
	return 0;
}


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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

ll bigmod(ll a, ll b, ll m)
{
    a %= m;
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = (res * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return res;
}

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

    int n;
    cin >> n;

    vector<int> v(n);
    unordered_map<int, int> cnt;

    for (int &x : v)
    {
        cin >> x;
        ++cnt[x];
    }

    // if odd leng: only one person has '0' as diff
    // And, all diffs should be divisible by 2, even or odd
    if (n & 1) // odd
    {
        if (cnt[0] != 1)
        {
            cout << 0;
            return 0;
        }
        cnt.erase(0);
    }

    for (auto x : cnt)
    {
        // cout << x.first << "->" << x.second << "\n";
        if (x.second & 1)
        {
            cout << 0;
            return 0;
        }
    }

    cout << bigmod(2, n / 2, 1e9 + 7);

    return 0;
}

Measured memory_bytes: 4108
S = list(input())

t = 0
max_t = 0

for i,s in enumerate(S):
    if s == 'R' and t == 0:
        t = 1
    elif s == 'R' and S[i-1] == 'R':
        t+=1
    else:
        t = 0
    max_t = max(max_t,t)
print(max_t)


Measured memory_bytes: 61632
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defun num-digits (num)
  (loop for digits from 1
        do (setf num (floor num 10))
        until (zerop num)
        finally (return digits)))

(defun decompose-to-digits (n)
  (loop with rem
        do (setf (values n rem) (floor n 10))
        collect rem
        until (zerop n)))

(defun valid753 (num)
  (let (flag3 flag5 flag7)
    (dolist (d (decompose-to-digits num))
      (cond ((= d 3) (setf flag3 t))
            ((= d 5) (setf flag5 t))
            ((= d 7) (setf flag7 t))))
    (and flag3 flag5 flag7)))

(defun %solve (cand base n)
  (if (zerop base)
      (if (and (<= cand n)
               (valid753 cand))
          1 0)
      (let ((next-base (floor base 10)))
        (+ (%solve (+ cand (* base 3)) next-base n)
           (%solve (+ cand (* base 5)) next-base n)
           (%solve (+ cand (* base 7)) next-base n)))))

(defun solve (n)
  (labels ((%solve (cand base n)
             (if (zerop base)
                 (if (and (<= cand n)
                          (valid753 cand))
                     1 0)
                 (let ((next-base (floor base 10)))
                   (+ (%solve (+ cand (* base 3)) next-base n)
                      (%solve (+ cand (* base 5)) next-base n)
                      (%solve (+ cand (* base 7)) next-base n))))))
    (loop for digit from 1 to (num-digits n)
          for base = 1 then (* base 10)
          sum (%solve 0 base n))))

(deftype uint nil `(integer 0 ,(expt 10 9)))
(defun main ()
  (let* ((n (read)))
    (println (solve n))))

#-swank(main)


Measured memory_bytes: 18272
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int N, M, A, B;
	scanf("%d %d %d %d", &N, &M, &A, &B);
	for(int i = 1; i <= N; i++) {
		for(int j = 1; j <= M; j++)
			if((i <= B && j <= A) || (i > B && j > A))
				putchar('1');
			else putchar('0');
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int SZ> struct Counter {
	int Count[SZ];
	set<int> Kinds;
	Counter() { rep(i, 0, SZ) Count[i] = 0; }

	void Increment(int i) {
		if (Count[i] == 0) Kinds.insert(i);
		Count[i]++;
	}

	void Decrement(int i) {
		Count[i]--;
		if (Count[i] == 0) Kinds.erase(i);
	}
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[101010];
int limit = 8;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) A[i]--;

	int originalN = N;

	vector<int> ans;
	set<int> unused;
	rep(i, 0, N) unused.insert(i);
	
	Counter<101010> counter;
	rep(i, 0, N) counter.Increment(A[i]);

	while (limit < N) {
		if (counter.Kinds.size() == 2) {
			auto ite = counter.Kinds.begin();

			int x = *ite; ite++;
			int y = *ite;

			if (counter.Count[x] == N - 1) {
				if (unused.count(x)) {
					ans.push_back(x);
					N--;
					unused.erase(x);
					counter.Decrement(A[x]);
					continue;
				}
			}

			if (counter.Count[y] == N - 1) {
				if (unused.count(y)) {
					ans.push_back(y);
					N--;
					unused.erase(y);
					counter.Decrement(A[y]);
					continue;
				}
			}
		}

		auto ite = unused.begin();

		if (0 < ans.size() and A[ans.back()] == *ite) ite++;
		ans.push_back(*ite);
		N--;
		counter.Decrement(A[*ite]);
		unused.erase(*ite);
	}

	vector<int> rest;
	rep(i, 0, N) {
		int x = *unused.begin();
		rest.push_back(x);
		unused.erase(x);
	}

	do {
		if (0 < ans.size() and A[ans.back()] == rest[0]) continue;
		bool ok = true;
		rep(i, 0, N - 1) if (A[rest[i]] == rest[i + 1]) ok = false;
		if (ok) {
			rep(i, 0, N) ans.push_back(rest[i]);
			break;
		}
	} while (next_permutation(all(rest)));

	if (ans.size() != originalN) {
		cout << -1 << endl;
		return;
	}

	rep(i, 0, originalN) {
		if(i) printf(" ");
		printf("%d", ans[i] + 1);
	}
	printf("\n");
}







Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
 
#define online_judge            freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio                    ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)               for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                      while
#define mp                      make_pair
#define le                      length()
#define endl                    "\n"
#define sf                        scanf    
 
const ll M=1e9+7; 
 
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
ll lcm(ll a,ll b)
{ return (a*b)/__gcd(a,b); }
 
 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;    
 
    x = x % p;
   
    if (x == 0) return 0;
 
    while (y > 0)  
    {  
       
        if (y & 1)  
            res = (res*x) % p;  
 
       
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<m);
}  

ll powmod(ll n)
{
    ll ret = 1;
    ll a = 2;
    while (n > 0) {
        if (n & 1) ret = ret * a % M;
        a = a * a % M;
        n >>= 1;
    }
    return ret;
}
 
ll modfact(ll n, ll p)
{
    if (n >= p)
        return 0;
 
    ll result = 1;
    for (int i = 1; i <= n; i++)
        result = (result * i) % p;
 
    return result;
}

long long binpower(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpower(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

///////////// TEMPLATE END /////////////////////////////////


	ll dp[2001];
void solve()
{
	ll n,m;
	cin>>n;
	m=3;
	for(ll i=3;i<=n;i++)
	{
		dp[i]=1;
	}
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	dp[3]=1;
	
	fr(i,n+1)
	{
		for(ll j=3;;j++)
		{
			if(i-j>=3)
			dp[i]=(dp[i]+dp[i-j])%M;
			
			else break;
		}
//		cout<<dp[i]<<endl;
	}
	cout<<dp[n];
	
}



int main()
{
//    fastio

//    int t;
//    cin>>t;
//    fr1(i,t)
    {
//        cout<<"Case #"<<i<<": ";
        solve();
    }
   
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int check(int a, int b) {
	if (min(a, b) == 0) {
		switch (max(a, b))
		{
		case 1:
			return 2;
		case 2:
			return 1;
		}
	}
	return 0;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string str;
	cin >> str;
	string rgb = "RGB";
	map<char, int> mp;
	for (int i = 0; i < 3; i++) {
		mp[rgb[i]] = i;
	}
	int cnt[4001][3] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			if (str[i] == rgb[j]) {
				cnt[i + 1][j] = cnt[i][j] + 1;
			}
			else {
				cnt[i + 1][j] = cnt[i][j];
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i + 1 < n; i++) {
		for (int j = i + 1; j + 1 <= n; j++) {
			if (str[i - 1] == str[j - 1]) continue;
			int checknum = check(mp[str[i - 1]], mp[str[j - 1]]);
			ans += cnt[n][checknum] - cnt[j][checknum];
			if (j + j - i <= n) {
				ans -= cnt[j + j - i][checknum] - cnt[j + j - i - 1][checknum];
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
ll W;
struct obj{
    ll w,v;
    obj(ll w, ll v):w(w),v(v){}
};
vector<obj> Objs;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        ll w,v; cin >> w >> v;
        Objs.emplace_back(w,v);
    }
    
}

void chmin(ll &a, ll b){if(a>b) a=b;};
#define V_MAX 1100
int solve(){

    // ll dp[110][V_MAX];
    // memset(dp,W+10,sizeof(dp));
    vector<map<ll,ll> > dp(N+1);
    dp[0][0] = 0;
    for (int i = 0; i < N; i++)
    {
        // for (int v = 0; v <= V_MAX; v++)
        for(auto u:dp[i])
        {
            if(u.second <= W){
                int v = u.first;
                if(dp[i+1][v]) chmin(dp[i+1][v], u.second);
                else dp[i+1][v] = u.second;
                if(dp[i+1][v+Objs[i].v]) chmin(dp[i+1][v+Objs[i].v], u.second+Objs[i].w);
                else dp[i+1][v+Objs[i].v] = u.second+Objs[i].w;
            }
        }
        dp[i].clear();
    }
    ll ans=0;
    for (auto u:dp[N])
    {
        if(u.second <= W) ans = max(ans, u.first);
    }
    cout << ans << endl;  
    return 0;        
}   

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


Measured memory_bytes: 6656
/*
 * drish1001
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>  
#include <iostream> 
using namespace __gnu_pbds; 
using namespace std;
#define     pb                 push_back
#define     mp                 make_pair
#define     ff                 first
#define     ss                 second
#define    MOD                1000000007
#define     pll                pair<ll,ll>
void        sorta(auto &v)     {sort(v.begin(),v.end());} 
void        sortd(auto &v)     {sort(v.begin(),v.end(), greater<>());} 
void        fast()            {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef        long long        ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> magic; 

//all variables and functions be1ow this ..


int main()
{
	string s, t;
	cin >> s >> t;
	ll n = s.size();
	ll m= t.size();
	ll ans=0;
	for(ll i=0;i<=n-m;i++)
	{
		ll cnt=0;
		string temp = s.substr(i, m);
		for(ll j=0;j<m;j++)
		{
			if(t[j]==temp[j])
				cnt++;
		}
		ans = max(ans,cnt);
	}
	cout << m-ans << endl;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define CVector CPoint
#define INF 0x3f3f3f3f
#define MAXN 1e5
const LL mod=1e9+7;
const double PI=acos(-1.0);
const double EPS=1e-10;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-')f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}

LL quickpowmod(LL x,LL y,LL mo){
    LL ret=1;
    while(y){
        if(y&1){
            ret=ret*x;
        }
        x=x*x;
        y>>=1;
    }
    return ret;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n,p;cin>>n>>p;
    int a=0,b=0,x;
    while(n--){
        cin>>x;
        if(x%2) a++;
        else b++;
    }
    LL ans=quickpowmod(2,b,1<<63);
    if(a!=0){
        ans*=quickpowmod(2,a-1,1<<63);
    }
    if(!a&&p) ans=0;
    cout<<ans<<endl;
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200005],have[1000005],used[1000005],mx=0,ans=0;
int main(){
   cin>>n;
   for(int i=1;i<=n;i++){
      cin>>a[i];
      have[a[i]]++;
      mx=max(mx,a[i]);
   }
   for(int i=1;i<=n;i++){
      if(have[a[i]]>=2){
         used[a[i]]=1;
         have[a[i]]--;
      }
      for(int j=a[i]*2;j<=mx;j+=a[i]) used[j]=1;
   }
   for(int i=1;i<=n;i++){
      if(!used[a[i]]) ans++;
   }
   cout<<ans;
   return 0;
}

Measured memory_bytes: 11980
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> A(N);
  vector<int64_t> B(M);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<M; i++){
    cin >> B[i];
  }
  
  vector<vector<int64_t>> dp(N+1,vector<int64_t>(M+1,1));
  int64_t MOD = 1e9+7;
  
  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      int64_t X = dp[i][j+1] + dp[i+1][j] - dp[i][j];
      if(X < 0){
        X += MOD;
      }
      if(A[i] == B[j]){
        dp[i+1][j+1] = X + dp[i][j];
      }
      else{
        dp[i+1][j+1] = X;
      }
      dp[i+1][j+1] %= MOD;
    }
  }
  /*for(int i=0; i<N+1; i++){
    for(int j=0; j<M+1; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  cout << dp[N][M] << endl;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e3 + 5;

int n,m,k,z;
string s[15];
int c[15];

bool f(int j){
	int id=0;
	for(int i=0;i<n;i++){
		c[id]+=s[i][j]=='1';
		if(c[id]>k) return true;
		if(z>>i & 1) id++;
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m>>k;
	for(int i=0;i<n;i++) cin>>s[i];
	int ans=0x3f3f3f3f;
	for(z=0;z<1<<n-1;z++){
		memset(c,0,sizeof(c));
		bool ok=false;
		int cnt=__builtin_popcount(z);
		for(int j=0;j<m;j++){
			if(f(j)){
				cnt++;
				memset(c,0,sizeof(c));
				ok=f(j);
			}
		}
		if(!ok) ans=min(ans,cnt);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <complex>
#include <cmath>
#include <iomanip>
using namespace std;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=1;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
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;
}




typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
xy_t projection(xy_t a, xy_t b) { return b*dot_product(a, b) / norm(b); }


// 3点から符号付き面積を求める
double signed_area(xy_t p1, xy_t p2, xy_t p3) {
	xy_t v1 = xy_t(p2.real() - p1.real(), p2.imag() - p1.imag());
	xy_t v2 = xy_t(p3.real() - p1.real(), p3.imag() - p1.imag());
	return (cross_product(v1, v2) / 2.0);
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	vector<xy_t> vs;

	int n; cin >> n;
	double x, y;
	while (n--) {
		cin >> x >> y;
		vs.pb(xy_t(x, y));
	}

	double ans = 0;
	REP(i, vs.size() - 1) {
		double s = signed_area(vs[0], vs[i], vs[i+1]);
		ans += s;
	}
	cout << fixed << setprecision(1) << ans << endl;


}




Measured memory_bytes: 3292
import java.util.Scanner;

public class Main{
    public static void main(String[] args) throws java.lang.Exception{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        
        System.out.println(d + " " + r + " " + String.format("%.8f", f));
    }
}


Measured memory_bytes: 26448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n,m;
  cin >> n >> m;
  ll a = min(n, m);
  ll b = max(n, m);
  if(a==1&&b==1){
    print(1);
  }
  else if(a==1){
    print(a*b-2);
  }
  else{
    print((n - 2) * (m - 2));
  }
}

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

signed main(){
  int A,C;
  cin>>A;
  string B;
  cin>>B;
  C=(B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
  int ans=A*C/100;
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int isPal(string s)
{
    string temp="";
    for(int i=s.length()-1;i>=0;i--)
    {
        temp+=s[i];
    }
    if(temp==s)
    {
        return 1;
    }
    return 0;
}
int main()
{
    string s;
    cin>>s;
    if(s.length()%2==0)
    {
        cout<<"No";
    }
    else
    {
        string a="",b="";
        for(int i=0;i<s.length()/2;i++)
        {
            a+=s[i];
        }
        for(int i=s.length()/2+1;i<s.length();i++)
        {
            b+=s[i];
        }
        if(isPal(s) && isPal(a) && isPal(b))
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    string s;
    cin>>s;
    int l=0;
    int c=0;
    int r=s.size()-1;
    while(l<r){
        dprint(l,r);
        if(s[l]==s[r]){
            ++l;
            --r;
            continue;
        }
        if(s[l]=='x'){
            ++c;
            ++l;
            continue;
        }
        if(s[r]=='x'){
            ++c;
            --r;
            continue;
        }
        c=-1;
        break;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 512
S = input()
ans = 0
for i in range(len(S)):
    cnt = 0
    while(i+cnt < len(S) and (S[i+cnt] == 'A' or S[i+cnt] == 'C' or S[i+cnt] == 'T' or S[i+cnt] == 'G')):
        cnt+=1
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        string[] line = Console.ReadLine().Split(' ');
        int x = int.Parse(line[0]);
        int y = int.Parse(line[1]);

        Console.WriteLine(x + y / 2);
        Console.ReadLine();
    }
}

Measured memory_bytes: 11092
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int X;
    cin >> X;
    if(X>2000){
        cout << 1 << el;return;
    }
    vec<bool> memo(X+107, false);
    memo[0] = true;
    REP(i, X-100+1){
        if(!memo[i]){
            continue;
        }
        memo[i+100]
        = memo[i+101]
        = memo[i+102]
        = memo[i+103]
        = memo[i+104]
        = memo[i+105]
        = true;
    }
    cout << (memo[X]?1:0) << el;
}



Measured memory_bytes: 256
a,b,k = map(int,input().split())
lst = []
end = min(a,b) #実際の終わり

for i in range(1,end+1):
    ra = a % i
    rb = b % i
    if ra == 0 and rb == 0:
        lst.append(i)

ans = lst[-1*k]
print(ans)

Measured memory_bytes: 61804
a = input()

for i in range(2**3):
    total = int(a[0])
    ans = a[0]
    for j in range(3):
        if i & (1<<j):
            total += int(a[j+1])
            ans += '+' + a[j+1]
        else:
            total -= int(a[j+1])
            ans += '-' + a[j+1]
    if total == 7:
        print(ans+'=7')
        exit(0)

Measured memory_bytes: 3060
N = int(input())
H = list(map(int,input().split()))
flg = True
H[0]-=1
for i in range(1,N):
    if H[i] >= H[i-1]+1:
        H[i] -= 1
    elif H[i] >= H[i-1]:
        continue
    else:
        print("No")
        flg = False
        break
if flg == True:
    print("Yes")


Measured memory_bytes: 63856
import java.util.*;
class Main{
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
   long n = sc.nextLong();
   long t = n%10;
   if(t==3)
     System.out.println("bon");
   else if(t==0 || t==1|| t==6||t==8)
     System.out.println("pon");
   else
     System.out.println("hon");
   
 }
}

Measured memory_bytes: 35756
// 課題6_2 AtCoder Beginner Contest 069 B - i18n
// nk777
 
#include<stdio.h>
// 文字列操作に関するヘッダファイル
#include<string.h>
#define MAX 101

int main(void){
    // 英単語の長さlength
    int length;
    // 英単語を格納する文字列word[]
    char word[MAX];
    
    // word[]を受け取る
    scanf("%s", word); 

    // 文字列の長さを読み込む
    length = strlen(word);

    // 1文字目、真ん中の文字数(最初と最後を引く)、最後の文字
    printf("%c%d%c\n", word[0], length - 2, word[length-1]);

    return 0;
}

Measured memory_bytes: 128
def floor_sum(n, m, a, b)
  res = 0
  if a >= m
    res += (n - 1) * n * (a / m) / 2
    a %= m
  end
  if b >= m
    res += n * (b / m)
    b %= m
  end

  y_max = (a * n + b) / m
  x_max = y_max * m - b
  if y_max == 0
    return res
  else
    res += (n - (x_max + a - 1) / a) * y_max
    res += floor_sum(y_max, a, m, - x_max % a)
    return res
  end
end

t = $stdin.readline.to_i
t.times do
  n, m, a, b = $stdin.readline.chomp.split.map(&:to_i)
  puts floor_sum(n, m, a, b)
end

Measured memory_bytes: 14388
import math

a, b, c, d = map(int, input().split())

def f(n, c, d):
    sum = n
    sum -= n // c
    sum -= n // d
    lcm = c * d // math.gcd(c, d)
    sum += n // lcm
    return sum

ans = f(b, c, d) - f(a-1, c, d)
print(ans)


Measured memory_bytes: 61816
# coding: utf-8
import sys
from math import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

K = ir()
answer = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            answer += gcd(i, gcd(j, k))

print(answer)


Measured memory_bytes: 67660
/*
Author: CNYALI_LK
LANG: C++
PROG: Cf2017C_D.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
char s[202000];
int a[202000],f[202000],smn[70000000];
void js(int x){
	int s=a[x];
	f[x]=smn[s]+1;
	for(int i=0;i<26;++i)chkmin(f[x],smn[s^(1<<i)]+1);
	chkmin(smn[s],f[x]);
}
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int n;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1,t=1<<26;i<t;++i)smn[i]=0x3f3f3f3f;
	
	for(int i=1;i<=n;++i){
		a[i]=a[i-1]^(1<<(s[i]-'a'));
		js(i);
	}
	printf("%d\n",f[n]);	
	return 0;
}



Measured memory_bytes: 267264
import scala.io.StdIn
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val l = List[Int](StdIn.readInt, StdIn.readInt, StdIn.readInt, StdIn.readInt, StdIn.readInt)

    val waits = l.map(i => if (i / 10 * 10 == i) 0 else i / 10 * 10 + 10 - i)

    println(l.sum + waits.sum - waits.max)

  }
}

Measured memory_bytes: 25532
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int64 S;
  cin >> S;
  int64 X1, Y1, X2, Y2;
  // X1 * Y2 - X2 * Y1 == S
  X1 = 1e9;
  Y2 = (S + X1 - 1) / X1;
  X2 = 1;
  Y1 = X1 * Y2 - S;
  cout << 0 << " " << 0 << " " << X1 << " " << Y1 << " " << X2 << " "
       << Y2 << endl;
  return 0;
}


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

using namespace std;
int h,w;

int main()
{
    int i,j;

    cin>>h>>w;
    string s[h];
    int dp[h][w];

    for(i=0;i<h;i++)
    {
        cin>>s[i];
    }
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(s[i][j] == '.')
            {
                if(i > 0 && j > 0)
                {
                    dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
                }
                else if(i > 0)
                {
                    dp[i][j] = dp[i-1][j]%mod;
                }
                else if(j > 0)
                    dp[i][j] = dp[i][j-1]%mod;
            }
        }
    }
    cout<<dp[h-1][w-1];
    return 0;
}


Measured memory_bytes: 5248
//ABC150B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string s;
	int n;
	cin >> n >> s;
	int count = 0;
	for(int i=0;i<n-2;i++){
		if(s.substr(i,3) == "ABC"){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 764
def check(baggage, k, p)
  while(1)
    index = 0
    k.times do
      tmp = 0
      while tmp + baggage[index] <= p
        tmp += baggage[index]
        index += 1
        return index if index == baggage.size
      end
    end
    return index
  end
end

baggage = []
n, k = gets.chomp.split(' ').map(&:to_i)
n.times do
  baggage.push(gets.to_i)
end
left = 0
right = 100000 * 100000
while (right - left) > 1
  mid = (left + right) / 2
  v = check(baggage, k, mid)
  if v >= n
    right = mid
  else
    left = mid
  end
end
puts right

Measured memory_bytes: 9748
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a , b ;
    cin >> a >> b ;
    int c[4] ;
    int now = a ;
    int count = 0 ;
    int kai =  b - a + 1 ;
    for(int i = 0 ; i < kai ; i++ ){
         c[0] = now % 10 ;
         now = now / 10 ;
         c[1] = now % 10 ;
         now = now / 100 ;
         c[2] = now % 10 ;
         now = now / 10 ;
         c[3] = now % 10 ;
         
         
         if(c[0] == c[3]&&c[1]==c[2]){
             count++ ;
         }

         a = a + 1 ;
         now = a ;
         //cout << now << endl;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
def solve(n, d, x, y):
    return len(list(filter(lambda p: (p[0]**2 + p[1]**2) <= d**2, zip(x, y))))

n, d = map(int, input().split())
x = [0]*n
y = [0]*n
for i in range(n):
    x[i], y[i] = map(int, input().split())
print(solve(n, d, x, y))

Measured memory_bytes: 35900