akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
/*
	expression : ( 1 <= x <= 3) is evaluated follow the steps below.
    0. (x is Integer, and value is 2.)
	1. (1 <= x) <= 3
	2. (true ) <= 3
	3. (1) <= 3 // In C++, true : Boolean is considered 1 : Integer
	4. true
	
	if you want to say  "x is greater than 2, and less than 3",
	you should write this::
	( 2 <= x && x <= 3)
	
	2.In this problem, beause test case is so weak, but
	Generally, when you compare double type integer, 
	you should use eps which means very small value.
	e.g 
	double a = 1.0;
	double eps = 0.000000000000001
	print (a == 1.0) <--- false
	print (abs(a - 1.0)  > eps)  <---- true;
	
*/
int main(){
    double x,y;
    int Aleft=0,Bleft=0,Cleft=0,Dleft=0;
    int Aright=0,Bright=0,Cright=0,Dright=0;
    
    while(cin >> x >> y){
    	
    if(x>=1.1){Aleft++;}
    else if(0.6<=x && x<1.1){Bleft++;}
    else if(0.2<=x && x<0.6){Cleft++;}
    else{	Dleft++; }
    
    if(y>=1.1){Aright++;}
    else if(0.6<=y && y<1.1){Bright++;}
    else if(0.2<=y && y<0.6){Cright++;}
    else{Dright++;}
    }

    cout << Aleft << " " << Aright << endl;
    cout << Bleft << " " << Bright << endl;
    cout << Cleft << " " << Cright << endl;
    cout << Dleft << " " << Dright << endl;

    return 0;
}


Measured memory_bytes: 3164
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>

int main() {
  int w, h, x, y;
  scanf("%d %d %d %d", &w, &h, &x, &y);
  printf("%.6f", (double)w*h/2);
  if (w % 2 == 0 && x == w/2 && h % 2 == 0 && y == h/2) {
    printf(" %d\n", 1);
  } else {
    printf(" 0\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long N = scan.nextLong();
        long K = scan.nextLong();

        long ans = 0;

        if(K < N) {
            ans = Math.min(Math.abs(K*(N/K) - N), Math.abs(K*(N/K+1) - N));
            os.println(ans);
        } else if (N < K) {
            ans = Math.min(N, Math.abs(K-N));
            os.println(ans);
        } else if(N == K) {
            os.println(0);
        }


    }
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int res;
  for (int a=0; a<=A; a++) {
    for (int b=0; b<=B; b++) {
      for (int c=0; c<=C; c++) {
        int total = 500*a + 100*b + 50*c;
        if(total == X) ++res;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1)res.emplace_back(n,1);
    return res;
}
int main(){
    ll N;
    string S;
    cin >> S;
    N = S.size();
    vector<ll> memo(N+1),ten(N+1);
    ten[0] = 1;
    rep(i,N){
        ten[i+1] = (ten[i]*10) % 2019;
    }
    rep(i,N){
        memo[i+1] = (memo[i] + ten[i]*(S[N-1-i] - '0'))%2019;
    }
    /*
    rep(i,N){
        T[i+1] = (T[i] + memo[i])%2019;
    }*/
    /*
    rep(i,N){
        cout << memo[i+1] << " ";
    }*/
    /*
    cout << endl;
    */
    map<ll,ll> mp;
    rep(i,N){
        mp[memo[i+1]]++;
    }
    ll cnt = 0;
    for(auto& e:mp){
        cnt += (e.second)*(e.second-1)/2;
    }
    cnt += mp[0];
    cout << cnt <<endl;
}

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

count = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            p1 = s.find(str(i))
            if p1 != -1:
                p2 = s.find(str(j), p1+1)
                if p2 != -1:
                    p3 = s.find(str(k), p2+1)
                    if p3 != -1:
                        count += 1

print(count)


Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 1e5;
typedef long long LL;
using namespace std;
LL n , a , b;
int main()
{
	while(~scanf("%lld%lld%lld" , &n , &a , &b)){
		LL ans = (n - 2) * b - (n - 2) * a;
		printf("%lld\n" , max(0LL , ans + 1));
	}
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    long long n,ans = 0;
    scanf("%lld",&n);

    if(n < 2 || n % 2 == 1)
    {
        printf("0");
    }
    else
    {
        n /= 2;
        long long num = 5;
        while (num <= n)
        {
            ans += n / num;
            num *= 5;
        }
        printf("%lld",ans);
    }
}

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

using namespace std;

#define all(v) v.begin(), v.end()
#define F first
#define S second
#define FOR(i, n) for(int i = 0; i < (int) n; i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

struct FT{
	int n;
	vi v;
	FT(int n){
		this->n = n;
		v.assign(n+1, 0);
	}
	int operator[](int i){
		int ans = 0;
		for(; i>0; i-=(i&(-i))) ans+=v[i];
		return ans; 
	}
	void add(int i, int x){
		for(; i <= n; i+=(i&(-i))) v[i]+=x;
	}
};

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

	int n; cin >> n;
	FT f(n);
	int ans = 0;
	FOR(i, n){
		int x; cin >> x;
		if(f[x] == 0)
			ans++;
		f.add(x, 1);
	} 

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1024
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (mat (make-array (list n n) :element-type 'uint32))
         (res (make-array (list n n) :element-type 'uint32)))
    (dotimes (i n)
      (dotimes (j n)
        (setf (aref res i j) (setf (aref mat i j) (read-fixnum)))))
    (dotimes (k n)
      (dotimes (i n)
        (dotimes (j n)
          (unless (or (= i k) (= j k))
            (let ((new-dist (+ (aref mat i k) (aref mat k j))))
              (when (> (aref mat i j) new-dist)
                (println -1)
                (return-from main))
              (when (= (aref mat i j) new-dist)
                (setf (aref res i j) 0)))))))
    (println (floor (reduce #'+ (array-storage-vector res)) 2))))

#-swank(main)


Measured memory_bytes: 17376
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt() - 1;
        String s = scanner.next();
        int c1 = 0, c2 = 0;

        for (int i = n; i >= 0; i--) {
            if (s.charAt(i)== ')') {
                c1++;
            } else {
                c1 = Math.max(0, c1 - 1);
            }
            if (s.charAt(n - i) == '(') {
                c2++;
            } else {
                c2 = Math.max(0, c2 - 1);
            }
        }
        for (int i = 0; i < c1; i++)
            System.out.print('(');
        System.out.print(s);
        for (int i = 0; i < c2; i++)
            System.out.print(')');
        System.out.println();
    }
}

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

long long int M = 998244353;
const int N = 2e+5 + 5;
long long int power(long long int x, long long int n)
{
    if (n == 0)
        return (long long)1;
    else if (n % 2 == 0) //n is even
        return power((x * x) % M, n / 2);
    else //n is odd
        return (x * power((x * x) % M, (n - 1) / 2)) % M;
}
long long int cans(long long int p, long long int q)
{
    return ((p * power(q, M - 2)) % M + M) % M;
}

long long int fact[N], facti[N];

int main()
{
    fact[0] = facti[0] = 1;
    for (long long int i = 1; i < N; i++)
    {
        fact[i] = (fact[i - 1] * i) % M;
        facti[i] = cans(1, fact[i]);
    }
    long long int n, m, k;
    cin >> n >> m >> k;
    long long int ans = 0;
    for (long long int i = 0; i <= k; i++)
    {
        long long int tans = power(m - 1, n - 1 - i);
        tans = (tans * fact[n - 1]) % M;
        tans = (tans * facti[n - 1 - i]) % M;
        tans = (tans * facti[i]) % M;
        ans = (ans + tans) % M;
    }
    ans = (ans * m) % M;
    cout<<ans;
}

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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	int n, k; cin >> n >> k;
	vector < int > v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	vector < int > DP(n);
	DP[0] = 0; 

	for (int i = 1; i < n; ++i) {
		int mn = INT_MAX;

		for (int j = 1; j <= k && i - j >= 0; ++j) {
			mn = min(mn, DP[i - j] + abs(v[i - j] - v[i]));
		}
		DP[i] = mn;
	}

	cout << DP[n - 1];
	return 0;
}

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

using namespace std;

int main(void){
 long long n;
 vector<int> alpha;
 cin >> n;
 n--;
 do{
  alpha.push_back(n%26) ;
   }while(n /= 26,n--);
   
  reverse(alpha.begin(),alpha.end());
  
  for(vector<int>::size_type i = 0;i < alpha.size(); i++){
   //int a = alpha[i];
   char a = 'a' + alpha[i] ; 
   cout << a ; 
  }
  
  return 0;
  
}

Measured memory_bytes: 3624
n = int(input())
arr = list(reversed(list(map(int,input().split()))))
brr = list(reversed(list(map(int,input().split()))))
brr.append(0)
cur=0
ans=0
for i in range(n+1):
    ans+=min(arr[i],cur)
    a=max(0,arr[i]-cur)
    ans+=min(a,brr[i])
    cur=max(brr[i]-a,0)
print(ans)

Measured memory_bytes: 18624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		long[] x = sc.nextLongArray(n);
		
		long res = 0;
		
		for(int i = 1; i < n; i++) {
			long distance = x[i]-x[i-1];
			
			res+=Math.min(distance*a, b);
		}
		
		out.println(res);
	}

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

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 34900
import math

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**6
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

X, Y = [int(i) for i in input().split()]

if (2*Y - X) % 3 != 0:
    print(0)
elif (2*X - Y) % 3 != 0:
    print(0)
else:
    x = (2*X - Y) // 3
    y = (2*Y - X) // 3
    print(cmb(x+y, x , mod))


Measured memory_bytes: 121968
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;

vector<int> g[100111],id[100111],v,cyc;
int n,a[100111],fa[100111],dep[100111];
bool use[100111];

void dfs(int x,int f=0,int fid=0)
{
	fa[x]=f;
	use[x]=1;v.pb(x);
	for(int i=0;i<(int)g[x].size();i++)
		if(!use[g[x][i]])
		{
			dep[g[x][i]]=dep[x]+1;
			dfs(g[x][i],x,id[x][i]);
		}
		else if(id[x][i]!=fid&&dep[g[x][i]]<=dep[x])
		{
			int cur=x;
			while(cur!=g[x][i])
			{
				cyc.pb(cur);
				cur=fa[cur];
			}
			cyc.pb(cur);
			if(a[f]==x)reverse(cyc.begin(),cyc.end());
		}
}
bool in[100111];
int sz[100111],cur;
bool dfs2(int x,int f=0)
{
	cur++;
	int ch=0;
	for(int i=0;i<(int)g[x].size();i++)
		if(!in[g[x][i]]&&g[x][i]!=f)
		{
			ch++;
			if(!dfs2(g[x][i],x))return false;
		}
	if(ch>1)return false;
	return true;
}
int calc()
{
	for(int i=0;i<(int)cyc.size();i++)in[cyc[i]]=1;
	for(int i=0;i<(int)cyc.size();i++)
	{
		cur=-1;
		if(!dfs2(cyc[i]))return 0;
		sz[i]=cur;
	}
	int last=0;for(int i=0;i<(int)cyc.size();i++)if(sz[i])last=i;
	int ret=1;
	for(int i=0;i<(int)cyc.size();i++)
	{
		if(sz[i]==0)continue;
		int len=i-last;if(len<=0)len+=(int)cyc.size();
		if(len<sz[i])return 0;
		else if(len>sz[i])ret=(ret+ret)%mod;
		last=i;
	}
	return ret;
}

int frq[100111],ans,dp[100111];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)
	{
		get1(a[i]);
		g[i].pb(a[i]);id[i].pb(i);
		if(a[i]!=i)
		{
			g[a[i]].pb(i);
			id[a[i]].pb(i);
		}
	}
	ans=1;
	for(int i=1;i<=n;i++)
	{
		if(use[i])continue;
		v.clear();cyc.clear();
		dfs(i);
		if((int)v.size()==(int)cyc.size())
			frq[(int)v.size()]++;
		else ans=1ll*ans*calc()%mod;
	}
	for(int i=1;i<=n;i++)
	{
		dp[0]=1;
		for(int j=1;j<=frq[i];j++)
		{
			dp[j]=dp[j-1];
			if(i>1&&i%2)dp[j]=(dp[j]+dp[j-1])%mod;
			if(j>1)dp[j]=(dp[j]+1ll*dp[j-2]*(j-1)%mod*i)%mod;
		}
		ans=1ll*ans*dp[frq[i]]%mod;
	}
	printendl(ans);
	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

bool G[15][15];

ll bitcount(ll x){
  if(x==0) return 0;
  return bitcount(x>>1)+(x&1);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  string s; cin>>s;
  ll ans=0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        vll a={i,j,k,-1};
        ll now=0;
        rep(ki,n){
          if(s[ki]-'0'==a[now]){
            now++;
          }
        }
        if(now>2) ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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


double N,K;
int main(){
    int a;
    double r;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>a;
    }
    r=(N-1)/(K-1);
    int amari=((int)N-1)%((int)K-1);
    if(amari==0)cout<<int(r)<<endl;
    else cout<<int(r)+1<<endl;
}

Measured memory_bytes: 384
miti = [[] for _ in range(5)]

for i in range(3):
    a, b = map(int, input().split())
    miti[a].append(b)
    miti[b].append(a)

cnt_list = []

for m in miti:
    cnt_list.append(len(m))
cnt_list.sort()
if cnt_list == [0, 1, 1, 2, 2]:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 8996
S = input()
if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
elif S == 'SAT':
  print(1)
else:
  pass

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
	ll N, A, B; cin >> N >> A >> B;
	ll x = N / (A+B);
	ll y = N % (A+B);
	ll ans = x * A;
	ans += (y < A) ? y : A;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
//最小公約数
int gcd(int a, int b) {
 return b != 0 ? gcd(b, a % b) : a;
}
void solve() {
	int N, X; cin >> N >> X;
	vector<int> x(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
		x[i] = abs(X - x[i]);
	}
	int ans = x[0];
	for (int i = 1; i < x.size(); ++i) {
		ans = gcd(ans, x[i]);
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3724
A, B, C = map(int, input().split())
K = int(input())
count = 0

while A >= B:
    B = B*2
    count = count + 1
    
for i in range(K - count):
    C = C * 2

if C > B:
    print("Yes")
else:
    print("No")
    
    
    
    

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

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

int main() {
  long long int n,m;
  string s,t;
  cin>>n>>m>>s>>t;
  long long int g=gcd(n,m);
  long long int l=n*m/gcd(n,m);
  
  for(int i=0;i<g ; i++){
    if(s[i*l/m]!=t[i*l/n]){
      cout<<-1;
      return 0;
    }
  }
  
  cout<<l;
 
  
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int,input().split()))
ans = 1
p = [0,0,0]  
mod = 10**9+7
for i in range(n):
    q = 0
    for j in range(3):
        if p[j] == a[i]:
            q +=1
    for k in range(3):
        if p[k] == a[i]:
            p[k] += 1
            break
    ans = ans*q%mod
print(ans%mod)

Measured memory_bytes: 53148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_ABC088_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[3];
            int[] b = new int[3];

            string[] line0 = Console.ReadLine().Split(' ');
            string[] line1 = Console.ReadLine().Split(' ');
            string[] line2 = Console.ReadLine().Split(' ');

            int[,] matrix = new int[3, 3];

            matrix[0, 0] = int.Parse(line0[0]);
            matrix[0, 1] = int.Parse(line0[1]);
            matrix[0, 2] = int.Parse(line0[2]);
            matrix[1, 0] = int.Parse(line1[0]);
            matrix[1, 1] = int.Parse(line1[1]);
            matrix[1, 2] = int.Parse(line1[2]);
            matrix[2, 0] = int.Parse(line2[0]);
            matrix[2, 1] = int.Parse(line2[1]);
            matrix[2, 2] = int.Parse(line2[2]);

            a[0] = 0;
            b[0] = matrix[0, 0];
            b[1] = matrix[0, 1];
            b[2] = matrix[0, 2];

            a[1] = matrix[1, 0] - b[0];
            a[2] = matrix[2, 0] - b[0];

            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    if (a[i] + b[j] != matrix[i, j])
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0;i < n;i++){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end(),greater<int>());
    int sum = 0;
    for (int i = 0;i < k;i++){
        sum += l.at(i);
    }

    cout << sum << endl;
}

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

total = 0

for night in range(1,n+1):
    if night <= k:
        total += x
    else:
        total += y

print(total)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	int color = 0, max = 0;
	vector<int> arr(8, 0);

	cin >> n;
	for(int i = 0; i < n; i++) {
		int num;
		cin >> num;

		num /= 400;
		if(num < 8) {
			arr[num] = 1;
		} else {
			max++;
		}
	}
	for(int i = 0; i < 8; i++) color += arr[i];
	if(color == 0) {
		cout << "1 " << max << endl;
	} else {
		cout << color << " " << color + max << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 20005;

int n,ans,tot;
int S[MAXN];

vector<int> cnt[2][3];

int main()
{
	cin >> n;
	if (n == 3)
	{
		puts("2 5 63");
		return 0;
	}
	for (int i = 4;i <= 30000;i++)
		if (i % 2 == 0 || i % 3 == 0)
			cnt[i % 2][i % 3].push_back(i);
	ans = 15000;
	while (ans > n && cnt[0][1].size() >= 3)
	{
		cnt[0][1].pop_back();
		cnt[0][1].pop_back();
		cnt[0][1].pop_back();
		ans -= 3;
	}
	while (ans > n && cnt[0][2].size() >= 3)
	{
		cnt[0][2].pop_back();
		cnt[0][2].pop_back();
		cnt[0][2].pop_back();
		ans -= 3;
	}
	while (ans > n && cnt[1][0].size() >= 3)
	{
		cnt[1][0].pop_back();
		cnt[1][0].pop_back();
		ans -= 2;
	}
	while (ans > n && cnt[0][1].size() && cnt[0][2].size())
	{
		cnt[0][1].pop_back();
		cnt[0][2].pop_back();
		ans -= 2;
	}
	for (int i = 0;i < cnt[0][1].size();i++)
		S[++tot] = cnt[0][1][i];
	for (int i = 0;i < cnt[0][2].size();i++)
		S[++tot] = cnt[0][2][i];
	for (int i = 0;i < cnt[1][0].size();i++)
		S[++tot] = cnt[1][0][i];
	S[++tot] = 2;
	S[++tot] = 3;
	while (ans < n)
	{
		S[++tot] = cnt[0][0].back();
		cnt[0][0].pop_back();
		ans++;
	}
	sort(S + 1,S + n + 1);
	for (int i = 1;i <= n;i++)
		cout << S[i] << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>//..1..2..3:Correct:Solved by F2tekkz:)
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
int main(){
	sonic;
	ll n , cnt = 0;
	str s;
	cin >> n >> s;
	for(ll i = 0 ; i < n ; i ++){
		if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
			cnt ++;
		}
	}
	cout << cnt;
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *



Measured memory_bytes: 256
S = open(0).read()
N = len(S)
ans = 0

for i in range(N):
    for j in range(i, N):
        judge_list = ['ACGT'.count(c) for c in S[i : j + 1]]
        #print(judge_list)
        if all(judge_list):
            ans = max(ans, j - i + 1)
print(ans)

Measured memory_bytes: 2940
#include<iostream>
#include<queue>
 
using namespace std;
 
int n=0;
int q=0;
int total=0;
 
struct process {
    string name;
    int time;
};

int main(){
    queue<process> que;
    queue<process> ans;
    cin>>n>>q;
    
    for (int i=0;i<n;i++){
        process p;
        cin>>p.name>>p.time;
        que.push(p);
    }
    while(!que.empty()){
        if(que.front().time <= q){
            total = total+que.front().time;
            process p;
            p.name = que.front().name;
            p.time = total;
            ans.push(p);
            que.pop();
        }
        else{
            total+=q;
            process p;
            p.name=que.front().name;
            p.time=que.front().time-q;
            que.pop();
            que.push(p);
        }

    }
    
     while (!ans.empty()) {
        cout<<ans.front().name<<" "<<ans.front().time<<endl;
        ans.pop();
    }
    
    
    return 0;
}

Measured memory_bytes: 6216
//
// Created by 佐竹俊哉 on 2019/11/12.
//

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N, K;
    cin >> N >> K;
    V<int> a(N);
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        if (a[i] >= K) ++ans;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, H;
  cin >> N >> H;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  
  int M = 0;
  for (int i = 0; i < N; i++) M = max(M, A.at(i));
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  
  int ans = 0, S = 0;
  for (int i = 0; i < N; i++) {
    if (B.at(i) >= M) {
      ans++;
      S += B.at(i);
      if (S >= H) break;
    }
    else break;
  }
  while (S < H) {
    ans++;
    S += M;
  }
  
  cout << ans << endl;
}

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

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

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

    unordered_set<int> correct;

    int n;
    cin >> n;

    vector<int> a(n);

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

    sort(a.rbegin(), a.rend());

    vector<ll> pows(2 * n - 1);

    pows[0] = 1;
    for (int i = 1; i <= 2 * n - 2; i++) {
        pows[i] = pows[i - 1] * 2;
        pows[i] %= m;
    }

    ll ans = 0;

    for (int i = 0; i < n; i++) {
        ans += (pows[2 * n - 2] * a[i] % m)  * (i + 2);
        ans %= m;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 4224
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
const long long Maxn=1e6;
typedef long long ll;

map<string,int>b;
string s,t;
queue<string>Q;

int main(){
	int n,m;
	int Max=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		cin>>s;
		b[s]++;
		Q.push(s);
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		cin>>s;
		b[s]--;
		if(b[s]<=0) b[s]=0;
	}
	for(int i=1;i<=n;i++){
		t=Q.front();
		Max=max(Max,b[t]);
		Q.pop();
	}
	printf("%d",Max);
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		List<Integer>p=new ArrayList<>();
		List<Integer>m=new ArrayList<>();
		long ans=0;
		for(int i=0;i<n;i++){
			int a=scanner.nextInt();
			ans+=Math.abs(a);
			if(a>=0){
				p.add(a);
			}else{
				m.add(-a);
			}
		}
		if(m.size()%2==0){
			System.out.println(ans);
			return;
		}
		Collections.sort(p);
		Collections.sort(m);
		if(p.size()>0&&p.get(0)<m.get(0)){
			p.set(0,-p.get(0));
		}else if(p.size()>0&&p.get(0)>m.get(0)){
			m.set(0, -m.get(0));
		}else {
			m.set(0, -m.get(0));
		}
		ans=0;
		for(int i=0;i<p.size();i++){
			ans+=p.get(i);
		}
		for(int i=0;i<m.size();i++){
			ans+=m.get(i);
		}
		System.out.println(ans);
	}	
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 27432
import * as fs from 'fs';

namespace AtCoder.abc126 {

    class ProgramB {
        // 1905
        // YYMM
        //
        // 0112
        // AMBIGUOUS
        //
        // 1700
        // NA
        main(inp: string) {
            const s: number[] = inp.split('').map(Number);
            const s12: number = parseInt(s.slice(0, 2).join(''), 10);
            const s34: number = parseInt(s.slice(2, 4).join(''), 10);

            let yymm: boolean = true;
            let mmyy: boolean = true;

            if (s34 === 0) yymm = false;
            if (s34 >= 13) yymm = false;

            if (s12 === 0) mmyy = false;
            if (s12 >= 13) mmyy = false;

            if (yymm && mmyy) console.log('AMBIGUOUS');
            if (yymm && !mmyy) console.log('YYMM');
            if (!yymm && mmyy) console.log('MMYY');
            if (!yymm && !mmyy) console.log('NA');
        }
    }

    const func = new ProgramB();
    func.main(fs.readFileSync('/dev/stdin', 'utf8').trim());

}

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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    for (int hh = 0; hh < b; hh++)
    {
        for (int ww = 0; ww < a; ww++)
        {
            cout<<0;
        }
        for (int ww = a; ww < w; ww++)
        {
            cout<<1;
        }
        cout<<endl;
    }
    for (int hh = b; hh < h; hh++)
    {
        for (int ww = 0; ww < a; ww++)
        {
            cout<<1;
        }
        for (int ww = a; ww < w; ww++)
        {
            cout<<0;
        }
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1280
# 問題 https://abc076.contest.atcoder.jp/tasks/abc076_c
S = input()
T = input()
Tlen = len(T)
Slen = len(S)
# Tの入りうる箇所の探索
# Tは入りうる箇所の一番うしろに入れて
# 前の?をすべてaで埋め尽くせばよい

for i in range(Slen-Tlen, -1, -1):
    # print(i)
    for s, t in zip(S[i:i + Tlen], T):
        flg = True
        if s != t and s != '?':
            flg = False
            break
    if flg:
        insertidx = i
        break
else:
    print('UNRESTORABLE')
    import sys
    sys.exit()

ans = S[:insertidx] + T + S[insertidx + Tlen:]
ans = ans.replace('?', 'a')
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  char a;
  cin >> a;

  if ('A' <= a && a <= 'Z') cout << 'A' << '\n';
  else cout << 'a' << '\n';


  




  
  return 0;
}

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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int A = abs(n - a), B = abs(n - b);
	if(A < B) cout << "A" << endl;
	else cout << "B" << endl;
}

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

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

    int n, ans = 0;
    cin >> n;
    ll z = 0;
    vector<ll> a(n);
    vector<int> b(33);
    rep(i, 0, n) {
        cin >> a[i];
        z ^= a[i];
        int j = 0;
        while (!((a[i] >> j) & 1))
            j++;
        b[j]++;
    }

    for (int i = 32; i >= 0; i--) {
        if ((z >> i) & 1) {
            if (b[i] <= 0) {
                cout << -1 << endl;
                return 0;
            }
            b[i]--;
            z ^= (1 << (i + 1)) - 1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
h, w = gets.split.map(&:to_i)

def adelete(a, h, w)
	h.times do |i|
		count = 0
		w.times do |j|
			count += 1 if a[i][j] == "." || a[i][j] == "?"
		end

		if count == w
			w.times do |j|
				a[i][j] = '?'
			end
		end
	end
end





a = Array.new(h)
h.times do |i|
	a[i] = gets.chomp.split('')
end


adelete(a, h, w)
a = a.transpose.reverse
adelete(a, w, h)
a = a.transpose.map(&:reverse)


a.size.times do |i|
	count = 0
	a[i].size.times do |j|
		if a[i][j] !='?'
			print a[i][j]
		else
			count += 1
		end
	end
	if count != a[i].size
		puts
	end
end




Measured memory_bytes: 5756
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
map<int,P> ma;
int dist(int x,int y){
    P p=ma[x];
    P q=ma[y];
    return abs(p.fi-q.fi)+abs(p.se-q.se);
}
int main(){
    int h,w,d;
    cin>>h>>w>>d;
    vvi vec(h,vi(w));
    REP(i,h){
        REP(j,w){
            cin>>vec[i][j];
            ma[vec[i][j]]=P(i,j);
        }
    }
    vi ans(h*w+1);
    FOR(i,1,d+1){
        int now=i+d;
        while(now<=h*w){
            ans[now]=ans[now-d]+dist(now-d,now);           
            now+=d;
        }
    }
    int Q;
    cin>>Q;
    REP(i,Q){
        int a,b;
        cin>>a>>b;
        cout<<ans[b]-ans[a]<<endl;
    }
    return 0;
}

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

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

Measured memory_bytes: 4012
require 'pp'

R = [nil,2,5,5,4,5,6,3,7,6]

N,M = readline.chomp.split.map(&:to_i)
A = readline.chomp.split.map(&:to_i).sort.reverse

REQ = A.map {|a| R[a] }.uniq.sort
NUM = REQ.map {|r| A.find_all {|a| R[a]==r}.max }
# pp REQ,NUM

$max = 0
$max_matches = []
n_digits = Array.new(REQ.size, 0)

def match_to_int(digits)
  a = []
  digits.size.times do |i|
    a += [NUM[i]] * digits[i]
  end
  a.sort.reverse.map(&:to_s).join.to_i
end

def dfs(depth, n_digits, n)
  #pp "#{depth}, #{n_digits.inspect}, #{n}" if depth == n_digits.size
  if depth == n_digits.size
    if n == 0
      sum = n_digits.inject(:+)
      if sum > $max
        $max = sum
        $max_matches = [n_digits.dup]
      elsif sum == $max
        $max_matches << n_digits.dup
      end
    end
    return true
  end

  r = REQ[depth]
  cur_digits = n_digits[0..(depth-1)].inject(:+)
  return false if $max > cur_digits + n/r
  (0..n/r).to_a.reverse.each do |i|
    n_digits[depth] = i
    b = dfs(depth+1, n_digits, n-i*r)
    break unless b
  end
  true
end

dfs(0, n_digits, N)

puts $max_matches.map {|match| match_to_int(match) }.max


Measured memory_bytes: 2808
fun main(args: Array<String>) {
    val (n, m, x) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }
    val idx = -(a.binarySearch(x) + 1)
    println(Math.min(idx, m - idx))
}

Measured memory_bytes: 37616
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

string L;
int dp[2][2]; //i'th index, whether or not it's equal L
const int mod = 1e9+7;

void add(int &a, int b) {
	a = b;
	a %= mod;
}

int32_t main() {
	cin >> L;
	int pos;
	dp[1][1] = 1;
	for (int i =0;i<L.length();i++) {
		pos = i%2;
		if (L[i] == '1') {
			add(dp[pos][0],dp[!pos][0] * 3 + dp[!pos][1]); //3 options or 0 0
			add(dp[pos][1],dp[!pos][1]*2); //1 0 or 0 1
		} else {
			add(dp[pos][0],dp[!pos][0]*3); //3 options
			add(dp[pos][1],dp[!pos][1]); //No options.
		}
	}
	cout << (dp[pos][0] +dp[pos][1]) % mod;
}


Measured memory_bytes: 512
n,m = map(int, input().split())
h = list(map(int, input().split()))

ab = [0]*n
for _ in range(m):
  a,b = map(int, input().split())
  ab[a-1] = max(ab[a-1], h[b-1])
  ab[b-1] = max(ab[b-1], h[a-1])

ans = 0
for j in range(n):
  if h[j] > ab[j]:
    ans += 1
print(ans)

Measured memory_bytes: 20024
/*
for (int i = 0; i < N; ++i){}
 
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
 
sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
 
int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}
 
map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
 
 
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
 
using namespace std;

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
	// 入力
    int N;
    cin >> N;
 
    int ans = 100000;
    int sum;
    int A, B;
    for (int i = 1; i < N; ++i) {
    	A = i;
    	B = N - i;
    	sum = findSumOfDigits(A) + findSumOfDigits(B);
    	if (sum<ans) ans = sum;
    }
	//出力
    cout << ans << endl;
}
 
 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int n[] = { 0,1,2,3,5,7,8,9 };

int main() {
	while(true){
	vector<int>v;
	long long num;
	cin >> num;
	if (num == 0) return 0;
	while (num >= 1) {
		v.push_back(n[num % 8]);
		num /= 8;
	}
	for (int i = v.size() - 1; i >= 0; i--) cout << v[i];
	cout << endl;
}
}



Measured memory_bytes: 3128
# include <bits/stdc++.h>
using namespace std;
# define ll long long
ll f(ll x){
    if(x == 1)return 1;
    return 2 * f(x / 2) + 1;

}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    cout << f(n);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string s;
    cin >> s;
    int idx1 = 0;
    while ( s[idx1] != 'A' ) idx1++;
    int idx2 = s.length() - 1;
    while ( s[idx2] != 'Z' ) idx2--;
    cout << idx2 - idx1 + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  int x = 2;
  while (x <= n) x *= 2;
  dump(x/2);
  return 0;
}

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

int main()
{
    long N, K;
    cin>>N >> K;
    long arr[N];
    for (int i=0; i<N; ++i){
        cin >> arr[i];
    }
    bool dp[K+1] = {0};
    for (long i = 1; i<=K; ++i){
        for(int j = 0; j<N; ++j){
            if (i - arr[j] >= 0) {
                dp[i] = max(dp[i], !dp[i-arr[j]]);   
            }
        }
    }
    // for (int i = 0; i<K+1;++i)
    //     cout<<dp[i]<< " ";
    if (dp[K] == 1)
        cout << "First";
    else 
        cout << "Second";
    return 0;
}

Measured memory_bytes: 384