akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
typedef long long ll;
const int N=0;
int n,k,x,t,a,b,m;
string s;
vector<int>v;
int main(){

	cin >> n >>m;
	cout << (n*(n-1))/2 + (m*(m-1))/2;	
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3636
#include <cstdio>
#include <list>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define FORi(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FOR(i,n) FORi(i,1,n)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
using pdd=pair<double, double>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto& p: c) os << p << " ";
	return os<<']';
}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}


template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}


constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;
constexpr int maxw=31;
constexpr int maxn=100000;
int N, n1, n2, n3;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	while(cin>>N) {
		bool flag = false;
		int l= max(N/4, 1);
		FORi(i,l, 3500) {
			FORi(j, i+1,3500) {
			ll now = N;now*=i;now*=j;
			ll di = 4*i*j - N*(i+j);
			if(di<=0||now%di) continue;
			cout << i<<" " << j << " " << (now/di) << endl;
			flag = true;
			break;
			}
			if(flag) break;
		}
	}

	return 0;
}


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

std::vector<std::string> split(const std::string &s, std::regex delim) {
    std::vector<std::string> res;
    std::sregex_token_iterator itr(s.begin(), s.end(), delim, -1), end;
    for(; itr!=end; itr++){
        if(*itr != "") res.push_back(*itr);
    }
    return res;
}

int main(){
    string s;
    while(getline(cin, s)){
        vector<string> v = split(s, regex{" "});
        vector<double> nums;
        for(int i=0; i<(int)v.size(); i++){
            if(v[i]=="+" || v[i]=="-" || v[i]=="*" || v[i]=="/"){
                double b = nums.back();
                nums.pop_back();
                double a = nums.back();
                nums.pop_back();
                if(v[i]=="+") nums.push_back(a+b);
                if(v[i]=="-") nums.push_back(a-b);
                if(v[i]=="*") nums.push_back(a*b);
                if(v[i]=="/") nums.push_back(a/b);
            }else{
                nums.push_back(stoi(v[i]));
            }
        }
        cout << fixed;
        cout << setprecision(10);
        cout << nums[0] << endl;
    }
    return 0;
}



Measured memory_bytes: 3232
;; -*- 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 (ql:quickload '(:cl-debug-print :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)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(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* ((s (read-line))
         (n (length s))
         (nexts (make-array (list n 26) :element-type 'uint32))
         (dp (make-array (+ n 1) :element-type 'uint32 :initial-element #xffffffff))
         (seqs (make-array (+ n 1) :element-type 'list)))
    (declare ((simple-array character (*)) s)
             (uint31 n))
    (let ((table (make-array 26 :element-type 'uint31 :initial-element n)))
      (loop for i from (- n 1) downto 0
            do (setf (aref table (- (char-code (aref s i)) 97)) i)
               (dotimes (c 26)
                 (setf (aref nexts i c) (aref table c)))))
    (setf (aref dp n) 1)
    (setf (aref seqs n) (list #\a))
    (loop for i from (- n 1) downto 0
          for res = #xffffffff
          do (dotimes (c 26)
               (if (= n (aref nexts i c))
                   (when (< 1 res)
                     (setf res 1)
                     (setf (aref seqs i) (list (code-char (+ c 97)))))
                   (let ((new-value (+ 1 (aref dp (+ 1 (aref nexts i c))))))
                     (when (< new-value res)
                       (setf res new-value)
                       (setf (aref seqs i)
                             (cons (code-char (+ c 97))
                                   (aref seqs (+ 1 (aref nexts i c)))))))))
             (assert (/= res #xffffffff))
             (setf (aref dp i) res))
    (dolist (c (aref seqs 0))
      (write-char c))
    (terpri)))

#-swank (main)


Measured memory_bytes: 43492
#include<bits/stdc++.h>
using namespace std;
int n,a[404];
long long dp[404][404];
long long sum(int l,int r){
    long long sum=0;
    for(int i=l;i<=r;i++) sum+=a[i];
    return sum;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int l=n-1;l>=0;l--)
        for(int r=l;r<n;r++){
            if(r==l) dp[r][l]=0;
            else{
                dp[l][r]=1e15;
                for(int k=l;k<r;k++){
                    dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]+sum(l,r));
                }
            }
        }
    cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int x;
    cin>>x;
    cout<<24-x+24<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
Tlist = deque([])
for i in range(N):
    list = []
    n = int(input())
    if n != 0:
        for i in range(n): #因数注意！
            o = input()    
            m = o.split()
            p = [int(j) for j in m] #1列の数列をリスト化
            list.append(p)
    Tlist.append(list)
max = 0
for i in range(2**N):
    p = format(i,'0'+str(N)+'b')
    ALL = True
    for j, value in enumerate(p):
        if value == '0':
            pass
        else:
            if len(Tlist[j]) == 0:
                pass
            else:
                for k in Tlist[j]:
                    if p[k[0]-1] == str(k[1]):
                        pass
                    else:
                        ALL = False
            if ALL:
                pass
            else:
                break
    else:
        new = p.count('1')
        if new > max:
            max = new

print(max)


Measured memory_bytes: 3316
/*
asnasncsja
asncansca
ascnasncaks
sacnjsc
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 100005
#define mod 998244353
#define INF 0x3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
int main() {
	int n, k;
	string s;
	cin >> n >> k;
	cin >> s;
	s[k - 1] += 32;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


vector<vector<long long int>>dp(51, vector<long long int>(51,-1));

long long int getnum(long long int eggnum, long long int time) {
	if (dp[eggnum][time] != -1)return dp[eggnum][time];
	if (time == 0)return dp[eggnum][time] = 0;
	else {
		if (eggnum ==1)return dp[eggnum][time] = time;
		return dp[eggnum][time] = min(static_cast<long long int>(1e18+1e17),getnum(eggnum-1,time-1) + getnum(eggnum,time-1) + 1);
	}
}

int main() {
	int T; cin >> T;
	while (T--) {
		long long int N; int E; cin >> N >> E;
		int ans = 100;
		for (int t = 0; t <= 50; ++t) {
			if (getnum(E, t) >= N) {
				ans = t;
				break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int x=0;
    rep(i,4){
        if(s[i]=='+'){
            x++;
        }else if(s[i]=='-'){
            x--;
        }
    }
    cout << x << endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int num = 1;
    for (int i = 1; i < n; ++i){
        num += s[i] != s[i-1];
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
/*int main()
{
	int a,b,c,d;
	cin >> a >>b >> c >> d;
	cout << min(a,b) + min(c,d);
}*/
int a[105];
int main()
{
	int n,d,x;
	cin >> n >> d >> x;
	int total = x ;
	for(int i = 1;i <= n;i ++)
	{
		cin >> a[i];
	}

	for(int i = 1;i <= n;i ++)
	{
	for(int j = 1;j <= d;j += a[i])total ++;
	}
	cout << total;
	
}

Measured memory_bytes: 256
x,size=map(int,input().split())
weight=[]
value=[]
weight.append(0)
value.append(0)
for i in range(x):
    a,b=map(int,input().split())
    weight.append(a)
    value.append(b)
max_value=sum(value)
dp=[[float('inf') for i in range(max_value+1)] for j in range(x+1)]
for i in range(x+1):
    dp[i][0]=0
for i in range(1,x+1):
    w=weight[i]
    v=value[i]
    for knap_v in range(1,max_value+1):
        if v<=knap_v:
            dp[i][knap_v]=min(dp[i-1][knap_v],w+dp[i-1][knap_v-v])
        else:
            dp[i][knap_v]=dp[i-1][knap_v]
ans=0
# print(dp)
for i in range(max_value+1):
    if dp[x][i]<=size:
        ans=i
print(ans)
        

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

int main(){
  string s;
  vector<char> c;
  cin >> s;
  bool flag = false;
  rep(i,(int)s.size()){
    if(s[i]=='A' && flag == false){
      c.push_back('A');
      flag = true;
    }
    else if(s[i]=='Z' && flag==true){
      c.push_back('Z');
      flag = false;
    }
  }
  if(c.size() != 0 && c[c.size()-1]=='A') c.pop_back();
  if(c.size() ==0 ) cout << -1 << endl;
  else {
    rep(i,(int)c.size()) cout << c[i];
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3216
import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

l,r=a[0]*2,a[n-1]*2
while True:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
        
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0

for q in range(n-1,-1,-1):
    while p<n and a[q]+a[p]<=md:
        p+=1

    if p==n: break
    cnt+=n-p
    ans+=a[q]*(n-p)*2


ans+=(m-cnt)*md
print(ans)


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

int main()
{

	int H, W;

	while( cin >> H >> W, H || W ) {

		for( int i = 1; i <= H; i++ ) {
			for( int j = 1; j <= W; j++ ) {

				if( !( i % 2 ) && !( j % 2 ) ) cout << "#";
				else if( !( i % 2 ) && ( j % 2 ) ) cout << ".";

				if( ( i % 2 ) && !( j % 2 ) ) cout << ".";
				else if( ( i % 2 ) && ( j % 2 ) ) cout << "#";

			}
			cout << endl;
		}

		cout << endl;

	}

	return 0;

}

Measured memory_bytes: 1152
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
	int n, h;
	cin >> n >> h; 
	vll a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
  
	sort(rall(b));
	sort(rall(a));

	ll sum = 0;
	ll ans = 0;
	rep(i,n) {
		if(b[i] > a[0]) {
			sum += b[i];
			ans++;
		}
		if(sum >= h){
			cout << ans << endl;
			return;
		}
	}
	// cout << h - sum << endl;
	ll rem = (h - sum + a[0] - 1)/a[0];
	ans += rem;
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main(void) {
	int s;
	int a[1000000];
	scanf("%d", &s);
	a[0] = s;
	int n = 0;
	int b[1000000] = { 0 };
	int x = 0;

	for (int i = 1; i < 1000000; i++) {
	if (a[i-1]%2 == 0) {
		a[i] = a[i - 1] / 2;
	}
	else {
		a[i] = a[i-1]*3 + 1;
	}
}
	for (int i = 0; i < 1000000; i++) {
		x = a[i];
		if (b[x] != 1) {
			b[x] = 1;
		}
		else {
			printf("%d\n", i + 1);
			break;
		}
	}



	



	return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl a(n);rep(i,n)cin >>a[i];
    vl x(100010,0);
    rep(i,n)x[a[i]]++;
    ll sum=0;
    rep(i,n)sum+=a[i];
    ll q;cin >> q;
    rep(i,q){
        ll b,c;cin >> b >> c;
        ll p=x[b];
        x[b]=0;
        sum-=p*b;
        sum+=p*c;
        x[c]+=p;
        cout << sum <<endl;
       /* rep(i,10)cout << x[i] <<" ";
        cout << endl;*/
    }
}   

Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    long double L;
    cin >> L;
    long double eps = 1.0E-14;
    cout << fixed << setprecision(15) << (L / 3. * L / 3. * L / 3.) << endl;
}

Measured memory_bytes: 256
N,X = map(int,input().split())
num = 0
count = 0
listA=list(map(int,input().split()))
    #listA<-[1,2,2,3,1]
    #ここに逐次処理を書けばいいと思う。

for i in range(N+1):
    if num<=X and i==N:
        count=i+1
        break
    elif num<=X:
        num = num+listA[i]
        count=count+1
    else:
        break
print(count)

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

const ll mod=1000000007;

int main(){
    string s,t;
    cin>>s>>t;
    int lens=s.size();
    int lent=t.size();
    int ans=1001;
    rep(i,lens-lent+1){
        int cnt=0;
        rep(j,lent){
            if(s[i+j]!=t[j])cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;

}

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

int main()
{
  int x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
  cin >> x1 >> y1 >> x2 >> y2;
    x3 = x2 - x1;
    y3 = y2 - y1;
    cout << x2 - y3 << " " << y2 + x3;
    cout << " ";
    cout << x1 - y3 << " " << y1 + x3;
  cout << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    cout << k*((int)pow(k-1,n-1));
    

    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(a):
        if len(a) == 1:
            if a[0] == 'n':
                return 0
            return 90
        t = f(a[1:])
        if a[0] == 'n':
            return t - 90 / (2**(len(a)-1))
        return t + 90 / (2**(len(a)-1))

    while True:
        s = S()
        if s == '#':
            break
        a = []
        while len(s) > 0:
            if s[:5] == 'north':
                a.append('n')
                s = s[5:]
            else:
                a.append('w')
                s = s[4:]
        t = f(a)
        b = 2**(len(a))
        a = int(t*b)
        g = fractions.gcd(a,b)
        a //= g
        b //= g
        if b > 1:
            rr.append('{}/{}'.format(a,b))
        else:
            rr.append(a)

    return '\n'.join(map(str, rr))


print(main())




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

int main(){
    char s[1000],t[1000];
    scanf("%s",s);
    int ls=strlen(s);
    scanf("%s",t);
    int lt=strlen(t);

    int a[ls-lt+1];
    for(int i=0;i<(ls-lt+1);i++){
        a[i]=0;
    }
    for(int i=0;i<(ls-lt+1);i++){
        for(int j=0;j<lt;j++){
            if(s[i+j]!=t[j]){
                a[i]++;
            }
        }
    }
    for(int i=0;i<(ls-lt);i++){
        for(int j=(ls-lt);j>i;j--){
            if(a[j-1]>a[j]){
                int temp=a[j];
                a[j]=a[j-1];
                a[j-1]=temp;
            }
        }
    }
    printf("%d\n",a[0]);
    return 0;
}

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


void solve(long long A, long long B, long long N){
    ll val = min(B-1, N); 
    // cout << val << endl; 
    ll ans = A * val / B + A*(val/B);
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


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

#define endl "\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1n(i, n) for (int i = 1; i < (int)(n); ++i)
#define forln(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define forl1n(i, n) for (long long i = 1; i < (long long)(n); ++i)

const ld EPS = 1e-9;
#define mod 1000000007
const int N = 1000000;

ll GetMod(ll n, ll z) { // func to get mod for positive num and negitive nums
    return (n % z + z) % z;
}
//          U   R  D  L
int dx[] = {-1, 0, 1, 0, -1, +1, +1, -1}; // dx for the 8 adjacent places in matrix
int dy[] = {0, 1, 0, -1, +1, +1, -1, -1};// dy for the 8 adjacent places in matrix
vector<ll> v;
vector<ll> v2;
vector<ll> v3;
int main() {

    ios_base::sync_with_stdio(false), cin.tie(NULL);
    int n;
    cin >> n;
    v.resize(n+1);
    v2.resize(n);
    forn(i,n+1){cin>>v[i];v3.push_back(v[i]);}
    forn(i,n)cin>>v2[i];

    forn(i,n){
        ll a=v[i];
        ll c =v2[i];
        v[i] = max((ll)0,a-c);
        v2[i] = max((ll)0,c-a);
        ll d=v[i+1],k=v2[i];
        v[i+1] = max((ll)0,d-k);
        v2[i] = max((ll)0,k-d);

    }

    ll sum  = 0;
    forn(i,v.size()){
        sum +=v3[i]-v[i];
    }
    cout<<sum<<endl;


}

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

#define ld long double
#define int long long

int32_t main()
{
    int n;
    cin>>n;
    
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    
    int meda,medb;
    if(n&1)
    {
        meda=a[n/2];
        medb=b[n/2];
        cout<<medb-meda+1;
    }
    else
    {
        meda=(a[n/2]+a[n/2-1]);
        medb=(b[n/2]+b[n/2-1]);
        
        long long ans=(medb-meda);
        cout<<ans+1;
    }
}

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

bool hasVisited[26];

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

    while(true) {
        if(a < b) break;
        if(k == 0) break;

        b <<= 1;
        k--;
    }

    while(true) {
        if(b < c) break;
        if(k == 0) break;

        c <<= 1;
        k--;
    }

    if(a < b && b < c) std :: cout << "Yes\n";
    else std :: cout << "No\n";
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define double long double
const long long mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
struct edge { int to,cost; };
vector<P>G[114514];
int par[114514], rnk[114514];
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rnk[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {

	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x] < rnk[y])par[x] = y;
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}
typedef pair<int, int> P;
int p[114514];
int x[114514], y[114514];
signed main(){
	int n, m; cin >> n >> m;
	rep(i, n)cin >> p[i];
	rep(i, m)cin >> x[i] >> y[i];
	rep(i, n)p[i]--;
	init(n);
	rep(i, m) {
		unite(x[i] - 1,y[i] - 1);
	}

	rep(i, n) {
		G[find(i)].push_back(P(p[i], i));
	}
	/*rep(i, n) {
		rep(j, G[i].size()) {
			if (j)cout << ' ';
			cout << G[i][j].first << ' ' << G[i][j].second << "  ";
		}
		cout << endl;
	}*/
	int ans = 0;
	rep(i, n) {
		vector<int>v1, v2;
		rep(j, G[i].size()) {
			v1.push_back(G[i][j].first);
			v2.push_back(G[i][j].second);
		}
		sort(v1.begin(), v1.end());
		sort(v2.begin(), v2.end());
		rep(j, v1.size()) {
			if (binary_search(v2.begin(), v2.end(), v1[j]))ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 11632
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
const int INF=1<<29;
/*
Status:Writing
Type:Problemset/HB
Problem ID:Atcoder/ARC/84
Author:XIZCM
*/
int k;
deque<int> dq;
int d[100005];
int main(){
	cin>>k;
	fill(d,d+100005,INF);
	d[1]=1;
	dq.push_front(1);
	while(!dq.empty()){
		int t=dq.front();
		dq.pop_front();
		if(d[(t*10)%k]>d[t]){
			d[(t*10)%k]=d[t];
			dq.push_front((t*10)%k);
		}
		if(d[(t+1)%k]>d[t]+1){
			d[(t+1)%k]=d[t]+1;
			dq.push_back((t+1)%k);
		}
	}
	cout<<d[0]<<endl;
	return 0;
}


Measured memory_bytes: 896
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){

    uint64_t N;
    cin>>N;


    FOR(h,1,3501){
        FOR(n,1,3501) {
            
            if((4*h*n-N*n-N*h)==0) continue;

            if((N*h*n)%(4*h*n-N*n-N*h)==0&&(N*h*n)/(4*h*n-N*n-N*h)>0){
                cout<<h<<" "<<n<<" "<<(N*h*n)/(4*h*n-N*n-N*h)<<endl;
                exit(0);
            }
               
        }
    }   

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int a,b,c;
	read(a),read(b),read(c);
	puts(a+b+c>=22?"bust":"win");
	return 0;
}

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

#define THIS "this"
#define THE "the"
#define THAT "that"

int main(void)
{
	int i, j;
	int flag;
	char str[100];
	
	
	while (1){
		flag = 0;
		if (fgets(str, 100, stdin) == NULL){
			break;
		}
		while (1){
			for (j = 0; str[j + 3] != '\0'; j++){
				if (strncmp(&str[j], THIS, 4) == 0){
					flag = 1;
				}
				else if (strncmp(&str[j], THE, 3) == 0){
					flag = 1;
				}
				else if (strncmp(&str[j], THAT, 4) == 0){
					flag = 1;
				}
			}
			if (flag == 1){
				break;
			}
			for (j = 0; str[j] != '\0'; j++){
				if (str[j] == 'z'){
					str[j] = 'a';
				}
				else if (str[j] != ' ' && str[j] != '.'){
					str[j] += 1;
				}
			}
		}
		if (flag == 1){
			str[strlen(str) - 1] = '\0';
			printf("%s\n", str);
		}
	}
	
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a == b && b == c){
        printf("No");
    }else if(a == b || b == c || a == c){
        printf("Yes");
    }else{
        printf("No");
    }
  
}


Measured memory_bytes: 1700
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    char W[10], T[25];
    int count = 0, i;
    scanf("%s", W);
    while (scanf("%s", T) != EOF && strcmp(T, "END_OF_TEXT")) {
        for (i = 0; T[i]; i++) {
            T[i] = tolower(T[i]);
        }
        if (!strcmp(W, T)) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

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

int main() {
	int n;
	string s;
	scanf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		getline(cin, s);
		while (s.find("Hoshino") != string::npos) {
			s.replace(s.find("Hoshino"), 7, "Hoshina");
		}
		cout << s << endl;
	}
}


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
int main()
{
    int n;
    double sum=0;
    cin >> n;
    vector<int> array(n);
    for(int i=0;i<n;i++){
        cin >> array[i];
    }

    sort(array.begin(), array.end());

    sum = array[0];
    for(int i=1;i<n;i++){
        sum = (sum + array[i]) / 2;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))
a,b,c = 0,0,0
for i in range(n):
    if s[i] % 2 == 1:
        a += 1
    elif s[i] % 4 == 0:
        b += 1
    else:
        c += 1

if b >= a:
    print("Yes")
elif c == 0 and a - b ==1:
    print("Yes")
else:
    print("No")

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

int main(){
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << w * h / 2.0;
    if(w / 2 == x && h / 2 == y){
        cout << " " << 1 << endl;
    } else {
        cout << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n,a,b;
    cin>>n;
    int d1[100100];//1からの距離
    int d2[100100];//Nからの距離
    REP(i,100100)d1[i]=d2[i]=-1;
    vector<int> r[100100];
    REP(i,n-1){
        cin>>a>>b;
        a--;b--;
        r[a].PB(b);
        r[b].PB(a);
    }
    queue<int>q;
    d1[0]=0;
    REP(i,r[0].size()){
        q.push(r[0][i]);
        d1[r[0][i]]=1;
    }
    while(q.size()){
        int p=q.front();q.pop();
        REP(i,r[p].size()){
            if(d1[r[p][i]]!=-1)continue;
            q.push(r[p][i]);
            d1[r[p][i]]=d1[p]+1;
        }
    }
    d2[n-1]=0;
    REP(i,r[n-1].size()){
        q.push(r[n-1][i]);
        d2[r[n-1][i]]=1;
    }
    while(q.size()){
        int p=q.front();q.pop();
        REP(i,r[p].size()){
            if(d2[r[p][i]]!=-1)continue;
            q.push(r[p][i]);
            d2[r[p][i]]=d2[p]+1;
        }
    }
    int cnt1=0;
    REP(i,n){
        if(d1[i]<=d2[i])cnt1++;
    }
    if(cnt1>(n-cnt1))cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}

Measured memory_bytes: 6656
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, k = map(int, readline().split())

ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += float(1 / n)
    else:
        ans += (1 / (2 ** math.ceil(math.log(k / i, 2)))) * (1 / n)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  double n;
  cin >> n;
  if((int)n%2==0) {
    cout << fixed << setprecision(10) << (n/2)/n << endl;
  }
  else {
    cout << fixed << setprecision(10) << ((n+1)/2)/n << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 4e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << ENDL;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <cstring>
#include <cstdlib>
using namespace std;


int masu[10][10];
vector< pair<int,int> > kitens;

int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};


int done[10][10];
int test[10][10];
int n;

int search(int x,int y,int p,int cv){
	if( cv < 0 ) return 0;
	else if( cv == 0 ){
		p++;
		if( p == kitens.size() ){
			return 1;
		}
		cv = -masu[kitens[p].first][kitens[p].second];
		y = kitens[p].first;
		x = kitens[p].second;
	}else{
		if( x < 0 || y < 0 || y >= n || x >= n || done[y][x] || masu[y][x] < 0 )
			return 0;
		cv -= masu[y][x];
		if( cv == 0 ){
			done[y][x] = true;
			if( search(x,y,p,cv) ) return true;
			done[y][x] = false;
			return 0;
		}
	}
	if( cv < 0 ) return 0;
	done[y][x] = true;
	
	for(int i = 0 ; i < 4 ; i++){
		if( search(x+dx[i],y+dy[i],p,cv) ) return 1;
	}
	done[y][x] = false;
	return 0;
}
int main(){
	while(cin >> n && n){
		kitens.clear();
		int checksum = 0;
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < n ; j++){
				done[i][j] = 0;
				cin >> masu[i][j];
				if( masu[i][j] < 0 ){
					kitens.push_back(make_pair(i,j));
				}
				checksum += masu[i][j];
			}
		}
		
		if( checksum != 0 || !search(-1,-1,-1,0) )
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
		
	}
}

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

int main()
{
	int N, Q;
	cin >> N >> Q;
	vector<ll> A(N), sum(N + 1), sum2(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum[i + 1] = sum[i] + A[i];
		sum2[i + 1] = (i ? sum2[i - 1] : 0) + A[i];
	}
	while (Q--) {
		ll X;
		cin >> X;
		int lb = 0, ub = N + 1;
		while (ub - lb > 1) {
			int t = (lb + ub) >> 1;
			if (abs(A[N - (t + 1) / 2] - X) < abs(A[N - t] - X)) {
				ub = t;
			}
			else {
				lb = t;
			}
		}
		cout << sum2[max(N - lb - (lb & 1), 0)] + (sum[N] - sum[N - (lb + 1) / 2]) << endl;
	}
	return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    int ans=INT32_MAX;
    for (int i = 0; i+k-1 < n; ++i) {
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
s = " 012 345 678 036 147 258 048 246 "
a = [input().split() for i in range(3)]
b = a[0] + a[1] + a[2]

for i in [input()for i in range(int(input()))]:
  if i in b:
    s = s.replace(str(b.index(i)), "")
print("Yes" if "  " in s else "No")

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

const long long mod = 1e9 + 7;

vector < bool > to_bin (long long x) {
	vector < bool > res(60, 0);
	long long cur = (1LL << 59LL);
	int cnt = 59;
	while (cur) {
		if (x >= cur) {
			x -= cur;
			res[cnt] = 1;
		}
		cur >>= 1;
		--cnt;
	}
	return res;
}

signed main () {
	int n;
	cin >> n;
	vector < vector < bool > > a(n);
	for (int i = 0; i < n; ++i) {
		long long x;
		cin >> x;
		a[i] = to_bin(x);
	}
	vector < vector < vector < long long > > > pref(2, vector < vector < long long > > (n + 1, vector < long long > (60, 0LL)));
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 60; ++j) {
			pref[0][i + 1][j] = pref[0][i][j];
			pref[1][i + 1][j] = pref[1][i][j];
		}
		for (long long j = 0; j < 60; ++j) {
			(ans += ((pref[!a[i][j]][i][j] * ((1LL << j) % mod)) % mod)) %= mod;
			++pref[a[i][j]][i + 1][j];
		}
	}
	cout << ans << '\n';
}


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

int main(void){
  int N,K; cin >> N >> K;
  vector<int> p(N);
  while(N--) cin >> p[N];
  sort(p.begin(), p.end());
  int total=0;
  while(K--) total += p[K];
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int head[100001],to[100001],nxt[100001],tot=0;
int degree[100001],f[100001];
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
int dfs(int index)
{
	if(head[index]==0)
		return f[index]=0;	
	if(f[index]>=0)
		return f[index];
	int i,v;
	for(i=head[index];i;i=nxt[i])
	{
		v=to[i];
		f[index]=max(f[index],dfs(v)+1);
	}
	//return f[index];
}
int main()
{
	int n,m,i,j,v,u,max_v=0;
	scanf("%d %d",&n,&m);
	memset(f,0xff,sizeof(f));
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	for(i=1;i<=n;i++)
		dfs(i);
	for(i=1;i<=n;i++)
		max_v=max(f[i],max_v);
	printf("%d",max_v);
	return 0;
}

Measured memory_bytes: 3584
package main

import (
	"fmt"
	"reflect"
)

type (
	//   1
	// 4 2 3 5
	//   6
	Dice struct {
		face [6]int
	}
)

func (d *Dice) Rotate(direction rune) int {
	switch direction {
	case 'W':
		d.face[0], d.face[2], d.face[5], d.face[3] =
			d.face[2], d.face[5], d.face[3], d.face[0]
	case 'E':
		d.face[0], d.face[2], d.face[5], d.face[3] =
			d.face[3], d.face[0], d.face[2], d.face[5]
	case 'N':
		d.face[0], d.face[1], d.face[5], d.face[4] =
			d.face[1], d.face[5], d.face[4], d.face[0]
	case 'S':
		d.face[0], d.face[1], d.face[5], d.face[4] =
			d.face[4], d.face[0], d.face[1], d.face[5]
	default:
		panic(fmt.Sprintf("Undefind direction: %c", direction))
	}
	return d.Get()
}

func (d *Dice) Roll(direction rune) int {
	switch direction {
	case 'R':
		d.face[3], d.face[1], d.face[2], d.face[4] =
			d.face[1], d.face[2], d.face[4], d.face[3]
	default:
		panic(fmt.Sprintf("Undefined derection: %c", direction))
	}
	return d.Get()
}

func (d *Dice) Get() int {
	return d.face[0]
}

func (d Dice) String() string {
	return fmt.Sprintf(
		`  %d
%d %d %d %d 
  %d
`, d.face[0], d.face[3], d.face[1], d.face[2], d.face[4], d.face[5])
}

func main() {
	var dice [2]Dice
	for i := 0; i < 2; i++ {
		for j := 0; j < len(dice[i].face); j++ {
			fmt.Scan(&dice[i].face[j])
		}
	}

	for k := 0; k < 4; k++ {
		for i := 0; i < 4; i++ {
			for j := 0; j < 4; j++ {
				if reflect.DeepEqual(dice[0].face, dice[1].face) {
					fmt.Println("Yes")
					return
				}
				dice[0].Roll('R')
			}
			dice[0].Rotate('N')
		}
		dice[0].Roll('R')
	}
	fmt.Println("No")
}



Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    ll n;
    cin >> n;
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    int i = 1;
    vector<int> s;


    while(n != 0){
        if(n % 2 != 0){
            s.push_back(1);
            if(i % 2 == 0) n += 1;
            else n -= 1;
        }else{
            s.push_back(0);
        }
        n /= 2;
        i++;
    }
    for(int j = s.size()-1; j >= 0; j--){
        cout << s[j];
    }cout << endl;

    return 0;
}

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

int main()
{
	int N;
	int f = 0;
	while (cin >> N && N != 0)
	{
		if (f != 0)cout << "" << endl;
		f = 1;
		int kind[4] = {};
		int sum = 0;
		for (int i = 0; i < 4; i++)
		{
			cin >> kind[i];
			sum += kind[i];
		}

		int ans = 0;
		int minCoins = 100000;
		int retKind[4] = {};
		for (int i = 0; i <= kind[0]; i++)
		{
			int ii = i * 10;
			for (int j = 0; j <= kind[1]; j++)
			{
				int jj = j * 50;
				for (int k = 0; k <= kind[2]; k++)
				{
					int kk = k * 100;
					for (int l = 0; l <= kind[3]; l++)
					{
						int ll = l * 500;
						int payMoney = kk + ll + jj + ii;
						if (N > payMoney)continue;
						int returnMoney = payMoney - N;

						int payMoneyNum = i + j + k + l;

						int returnCoinNum = returnMoney / 500;
						returnMoney = returnMoney % 500;
						returnCoinNum += returnMoney / 100;
						returnMoney = returnMoney % 100;
						returnCoinNum += returnMoney / 50;
						returnMoney= returnMoney % 50;
						returnCoinNum += returnMoney / 10;
						int s = sum - payMoneyNum + returnCoinNum;
						if (s < minCoins)
						{
							minCoins = s;
							retKind[0] = i;
							retKind[1] = j;
							retKind[2] = k;
							retKind[3] = l;
						}
					}
				}
			}
		}
		if (retKind[0] != 0)
		{
			cout << 10 <<" "<<retKind[0] << endl;
		}

		if (retKind[1] != 0)
		{
			cout << 50 << " " << retKind[1] << endl;
		}

		if (retKind[2] != 0)
		{
			cout << 100 << " " << retKind[2] << endl;
		}

		if (retKind[3] != 0)
		{
			cout << 500 << " " << retKind[3] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(void){
	int a,b,c,d;
	scanf("%d %d %d %d", &a,&b,&c,&d);
	if(a+b<c+d)printf("Right\n");
	else if(a+b==c+d)printf("Balanced\n");
	else printf("Left\n");
	return 0;
}


Measured memory_bytes: 128
//By Don4ick
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234

const double PI = acos(-1.0);
const int DIR = 8;
const int X[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int Y[] = {0, 1, 0, -1, 1, -1, 1, -1};

const int N = 55;

using namespace std;

string s[N];
int n, m;

bool in(int x, int y)
{
	return x >= 0 && x < n && y >= 0 && y < m;
}

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	cin >> n >> m;
	forn(i, n)
	{
		cin >> s[i - 1];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (s[i][j] == '#')
				cout << s[i][j];
			else
			{
				int cnt = 0;
				for (int k = 0; k < DIR; k++)
					if (in(i + X[k], j + Y[k]) && s[i + X[k]][j + Y[k]] == '#')
						cnt++;
				cout << cnt;
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)


////////////////////////////////////////////////////////////
template<class X> bool is_prime( X n ){
	if(n <= 0 )
		return false;
	else if( n == 1 )
		return false;
	else if( n == 2 )
		return true;
	else{
		X limit = sqrt(n)+1;
		if( n % 2 == 0 )
			return false;
		for(X i = 3 ; i <= limit ; i += 2 ){
			if( n % i == 0 )
				return false;
		}
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	
	
	int pri[1001] = {};
	rep(i,0,n+1){
		rep(j,2,i+1){
			if( is_prime(j) ){
				long long tmp = i;
				long long cnt = 0;
				while( tmp % j == 0 ){
					//cout << "tmp:" << tmp << endl;
					tmp /= j;
					cnt++;
				}
				//cout << "i:" << i << " j:" << j << " cnt:" << cnt << endl;
				pri[j] += cnt;
			}
		}	
	}

	long long ans = 1;
	rep(i,0,1001){
		ans *= pri[i]+1;
		ans %= 1000000007;
	}

	P(ans);
	ret 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
	
	public static void main (String[] args) throws IOException{
        String s = br.readLine();
        String t = br.readLine();
        int ans = 0;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)!=t.charAt(i))    ans++;
        }
        bw.write(ans + "");
		bw.flush();
	}
}


Measured memory_bytes: 39940
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

x, k, d = rm()
c = abs(x)//d
if k<c:
    print(abs(x)-d*k)
else:
    e=abs(x)-d*c
    if c%2==k%2:
        print(e)
    else:
        print(d-e)

Measured memory_bytes: 77316