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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n;
  cin >> n;
  set<int> se;
  REP(i,n){
    int x;cin >> x;
    se.insert(x);
  }
  cout << se.size() << endl;



  return 0;
}


Measured memory_bytes: 256
def solve():
    diff = [(i-1,j-1) for i in range(3) for j in range(3)]
    H,W,N = map(int, input().split())
    count_dict = {}
    ret = [0]*10
    ret[0] = (W-2)*(H-2)
    for i in range(N):
        a, b = map(int,input().split())
        # da = min(a, W-a, 2)+1
        # db = min(b, H-b, 2)+1
        # rect_num = da*db
        for da,db in diff:
            ra, rb = a+da, b+db
            if ra <= 1 or ra >= H or rb <= 1 or rb >= W : continue
            # if (ra,rb) == (4,2): print(i+1, a, b, ra, rb)
            if (ra,rb) in count_dict:
                dom = count_dict[(ra,rb)]
                ret[dom] -= 1
                ret[dom+1] += 1
                count_dict[(ra,rb)] += 1
            else:
                ret[0] -= 1
                ret[1] += 1
                count_dict[(ra,rb)] = 1
                
    # print(count_dict)
    print('\n'.join(map(str,ret)))
    
solve()

Measured memory_bytes: 166480
n, k = map(int, input().split())
mod = 10**9 + 7
arr = list(map(int, input().split()))
ans = 0
for i in range(n):
    a, b = 0, 0
    for j in range(i + 1):
        if arr[i] > arr[j]:
            a += 1
    for j in range(i + 1, n):
        if arr[i] > arr[j]:
            b += 1
    ans += b * k + (b + a) * k * (k - 1) // 2
print(ans % mod)


Measured memory_bytes: 3188
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array

main = do
  w <- inp toInt
  n <- inp toInt
  xs <- inps n (splt toInt)
  mapM_ print $ solve w xs

solve :: Int -> [[Int]] -> [Int]
solve w xs = elems narr
  where narr = foldl exchange iarr xs
        iarr = array (1,w) (zip [1..w] [1..w])

exchange :: Array Int Int -> [Int] -> Array Int Int
exchange arr [a, b] = arr // [(a,arr ! b),(b,arr ! a)]

toInt :: String -> Int
toInt s = read s

splt :: (String -> a) -> String -> [a]
splt f = map f . words . map (\s -> if s == ',' then ' ' else s)

inp :: (String -> a) -> IO a
inp f = f <$> getLine

inps :: Int -> (String -> a) -> IO [a]
inps n f = map f <$> replicateM n getLine

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

int main() {
  string s;
  cin >> s;
  int c = 0;
  rep(i,s.size()) if(s[i] == 'o') c++;
  if(c+15-s.size() >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
import itertools
import numpy
input = sys.stdin.readline
N,M = [int(i) for i in input().split()]
nes = [0] * M
for i in range(M) :
    lis = [int(i) for i in input().split()]
    lis.append(i+1)
    nes[i] = lis
nes.sort()
answer_sheet = ['0'] * M
count = 0
for i in range(M) :
    if i < M - 1 :
        if nes[i][0] == nes[i+1][0] :
            count+=1
            pre = str(nes[i][0]).rjust(6,'0')
            new = str(count).rjust(6,'0')
            answer_sheet[nes[i][2] - 1] = pre + new
        else :
            count+=1
            pre = str(nes[i][0]).rjust(6,'0')
            new = str(count).rjust(6,'0')
            answer_sheet[nes[i][2] - 1] = pre + new
            count = 0
    else :
        count+=1
        pre = str(nes[i][0]).rjust(6,'0')
        new = str(count).rjust(6,'0')
        answer_sheet[nes[i][2] - 1] = pre + new
for i in range(M) :
    print(answer_sheet[i])

Measured memory_bytes: 41936
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var n, ac, wa, tle, re int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n)

	for i := 0; i < n; i++ {
		scanner.Scan()
		switch scanner.Text() {
		case "AC":
			ac++
		case "WA":
			wa++
		case "TLE":
			tle++
		default:
			re++
		}
	}

	fmt.Println("AC x", ac)
	fmt.Println("WA x", wa)
	fmt.Println("TLE x", tle)
	fmt.Println("RE x", re)
}


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

using namespace std;

#define int long long

map<int, int> Cnt, Inv;

void mul(int &a, int b) {
	if(a == -1 || b == -1) {a = -1;return;}
	int r = a * b;
	if(r / b != a) {a = -1;return;}
	a = r;
}

int GetSquare(int x) {
	int sqr = sqrt(x);

	for(int d = 2; d >= -2; --d) {
		if((x + d) * (x + d) <= x)
			return x + d;
	}
}

pair<int, int> FactorizeAndReduce(int x) {
	int no = 1, inv = 1;

	for(int d = 2; d <= x && d <= 700; ++d) {
		if(x % d) continue;

		int e = 0;
		while(x % d == 0)
			x /= d, e += 1;
		e %= 3;

		if(e == 0) continue;
		if(e == 1) {
			mul(inv, d); mul(inv, d); mul(no, d);
		} else {
			assert(e == 2);
			mul(inv, d); mul(no, d); mul(no, d);
		}
	
	}

	if(x != 1) {
		int d = GetSquare(x);
		if(d * d == x) {
			mul(inv, d);
			mul(no, x);
		} else {
			mul(no, x);
			mul(inv, x);
			mul(inv, x);
		}
	}

	// cerr << no << " " << inv << '\n';
	return make_pair(no, inv);
}

int32_t main() {
	int n;
	cin >> n;

	int ans = 0;

	bool take1 = 0;

	for(int i = 1; i <= n; ++i) {
		int x;
		cin >> x;

		auto p = FactorizeAndReduce(x);
		if(p.first == 1) {
			if(take1) continue;
			take1 = 1;
			ans += 1;
		} else {
			Inv[p.first] = p.second;
			Cnt[p.first] += 1;
		}
	}

	while(Cnt.size()) {
		int no = Cnt.begin()->first;
		ans += max(Cnt[no], Cnt[Inv[no]]);
		Cnt.erase(Inv[no]);
		Cnt.erase(no);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12800
import java.io.*;

class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		String str=br.readLine();
		
		int i=0;
		
		do{
			i++;
			sb.append("Case ").append(i).append(": ").append(str).append("\n");
			str=br.readLine();
			
		}while(!str.equals("0"));
		System.out.print(sb);
	}
}

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

ll mod = 1e9+7;

/*
#define NMAX 10001
ll fac[NMAX];
ll inv[NMAX];

ll mod_pow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod-2, mod);
}

void mae_nck(){
    fac[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < NMAX; i++){
        fac[i] = (fac[i-1] * i)%mod;
        inv[i] = (inv[i-1] * mod_inv(i, mod))%mod;
    }
}
*/

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

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

ll mod_nck(ll n, ll k){
  if(k == 0 || k == n) return 1;
  ll ret = ((fac[n] * inv[k])%mod * inv[n-k])%mod;
  return ret;
}

ll nck(ll n, ll k){
  if(k == 0 || k == n) return 1;
  ll nume = 1, deno = 1;
  for(int i=0; i<k; i++){
    nume *= (n-i);
    deno *= (i+1);
  }
  return (ll)(nume/deno);
}

int main(){
    ll n, k;
    cin >> n >> k;
    COMinit();
    rep(i, 1, k+1){
        ll ans = COM(n-k+1, i) * COM(k-1, i-1);
        cout << ans%mod << endl;
    }

    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <cstdio>
#define N 1000005
using namespace std;

typedef long long ll;
ll n, s, fac[N]{1, 1}, inv[N]{1, 1}, fiv[N]{1, 1};
ll M = 1e9 + 7;
int main()
{
	ll i, t, old = 0;
	cin >> n;
	for (i = 2; i <= n; i++) {
		fac[i] = fac[i - 1] * i % M;
		inv[i] = inv[M % i] * (M - M / i) % M;
		fiv[i] = fiv[i - 1] * inv[i] % M;
	}
	for (i = (n + 1) / 2; i < n; i++) {
		t = fac[i] * fac[i - 1] % M * fiv[2 * i - n] % M;
		s = (s + (t - old + M) * i % M) % M;
		old = t;
	}
    cout << s << endl;
    return 0;
}

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

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class AKyuInAtCoder {
public:
  static void solve(istream &cin, ostream &cout) {
    int X;
    cin >> X;
    REP(i, 1, 9) {
      if (X >= 200 + 200 * i and X < 200 + 200 * (i + 1)) {
        cout << 9 - i << endl;
      }
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  AKyuInAtCoder solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
using namespace std;
const int INF = 1e9 + 5;
int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j : {i + 1, i + 2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 4012
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char c[]="LDUR";
long long x[1005],y[1005];
int main(){
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		x[i]=a+b;
		y[i]=a-b;
	}
	bool ok=1;
	for(int i=1;i<=N;i++)if((x[i]&1)!=(x[1]&1))ok=0;
	if(!ok){puts("-1"); return 0;}
	bool t=!(x[1]&1);
	printf("%d\n",39+t);
	long long sum=0;
	if(t)printf("%d ",1),sum+=1;
	for(int i=0;i<39;i++)printf("%lld ",1ll<<i),sum+=1ll<<i;
	puts("");
	for(int i=1;i<=N;i++){
		x[i]+=sum;
		y[i]+=sum;
		if(t)putchar(c[0]);
		for(int j=1;j<=39;j++)
			putchar(c[( ( (x[i]>>j)&1 )<<1 )|( (y[i]>>j)&1 )]);
		puts("");
	}
	return 0;
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] SP; } cout BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout BR;

ll M, K;

int main() {

    cin >> M >> K;

    if ( M == 0 ) {
        if ( K == 0 ) {
            cout << "0 0\n";
        } else {
          cout << "-1\n";
        }
        return 0;
    }

    if (M == 1) {
      if (K == 0) {
        cout << "0 0 1 1\n";
      } else {
        cout << "-1\n";
      }
      return 0;
    }

    if (K >= pow(2, M)) {
      cout << "-1\n";
      return 0;
    }

    for (ll i = 0; i < pow(2, M); i++) {
        if ( i != K ) cout << i << SP;
    }
    cout << K << SP;
    for (ll i = pow(2, M) - 1; i >= 0; i--) {
      if (i != K) cout << i << SP;
    }
    cout << K << BR;

    return 0;
}

Measured memory_bytes: 1792
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	double PI = 45.0 / atan(1);
	double a, b, x; cin >> a >> b >> x;
	if (a*a*b / 2 > x)
	{
		double c = (2 * x) / (a*b);
		printf("%.10f", atan(b / c)*PI);
	}
	else
	{
		double c = 2*b - ((2 * x) / (a * a));
		printf("%.10f", atan(c / a)*PI);
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[1010];
ll dp[1010];
int from[1010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll ma=-1LL<<60;
	int best=-1;
	
	for(i=1;i<=N;i++) {
		cin>>A[i];
		dp[i]=A[i];
		for(x=1;x<i;x++) if((i-x)%2==0) {
			if(dp[x]+A[i]>dp[i]) {
				from[i]=x;
				dp[i]=dp[x]+A[i];
			}
		}
		if(dp[i]>ma) {
			ma=dp[i];
			best=i;
		}
	}
	
	cout<<ma<<endl;
	vector<int> V;
	for(x=N;x>best;x--) V.push_back(x);
	while(from[x]>0) {
		y=from[x];
		while(y<x) {
			V.push_back((x+y)/2);
			x-=2;
		}
	}
	FOR(i,x-1) V.push_back(1);
	
	cout<<V.size()<<endl;
	FORR(v,V) cout<<v<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import bisect
# from collections import deque
# from collections import Counter
# from fractions import gcd # >=Python3.5 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # <Python3.5
# from math import sqrt
 
n = int(input())
li = [int(input()) for i in range(n)]
li = [-x for x in li]

X = []
X.append(li[0])

for i in range(1,n):
    idx = bisect.bisect_right(X,li[i])
    if idx==len(X):
        X.append(li[i])
    else:
        X[idx] = li[i]

print(len(X))

Measured memory_bytes: 11052
/* Don't try to copy it!
                    nhi too,
                         goli maar ke cheed bana dunga...;););)
 
                 
    _/﹋\_
    (҂`_´)
    <,︻╦╤─҉- - - - - - - - => - => - =>
    _/﹋\_
                
*/
 
#include "bits/stdc++.h"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define T ll t; cin>>t; while(t--)
#define freeopen freopen("input.txt","r",stdin);
#define freeclose freopen("output.txt","w",stdout);
#define MOD 1000000007
using namespace std;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll a[100004];
ll n;
ll dp[100004];
ll min_cost(ll p)
{
    
    if(p>=n-1)
        return 0;

    if(dp[p]!=-1)
        return dp[p];

    if(p!=n-2)
        dp[p]=min(abs(a[p]-a[p+1])+min_cost(p+1),abs(a[p]-a[p+2])+min_cost(p+2));
    else
        dp[p]=abs(a[p]-a[p+1])+min_cost(p+1);

    return dp[p];
}

main()
{
    //ll n;
    cin>>n;
    //ll a[n];
    memset(dp,-1,sizeof(dp));
    f(n)
    cin>>a[i];

    ll ans=min_cost(0);

    cout<<ans;

}



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

typedef long long ll;

int main(){
   int X, Y, Z, K;
   std::cin >> X >> Y >> Z >> K;
   std::vector<ll> A(X), B(Y), C(Z);
   for(int i=0; i<X; ++i)
      std::cin >> A[i];
   for(int i=0; i<Y; ++i)
      std::cin >> B[i];
   for(int i=0; i<Z; ++i)
      std::cin >> C[i];

   std::vector<ll> AB(X*Y);
   ll index = 0;
   for(int i=0; i<X; ++i){
      for(int j=0; j<Y; ++j){
	 AB[index++] = A[i] + B[j];
      }
   }
   std::sort(AB.begin(),AB.end(), std::greater<ll>());
   std::sort(C.begin(),C.end(), std::greater<ll>());
   
   std::vector<ll> sum(K*K);
   index = 0;
   for(int i=0; i<std::min(K,X*Y); ++i){
      for(int j=0; j<std::min(K,Z); ++j){
	 sum[index++] = AB[i] + C[j];
      }
   }
   
   std::sort(sum.begin(),sum.end(), std::greater<ll>());

   for(int i=0; i<K; ++i){
      std::cout << sum[i] << std::endl;
   }

   return 0;
}


Measured memory_bytes: 78464
import java.util.*;
public class Main {
    public static long gcd(long x,long y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
    public static long lcm(long x,long y){                                                              
        return x*y/gcd(x,y);                                                                                                                                                                                                                
    }
    public static long fac(long x){
        if(x==0) return 1;
        return x*fac(x-1);
    }
    public static long per(long x,long y){
        return fac(x)/fac(x-y);      
    }
    public static long com(long x,long y){
        return per(x,y)/fac(y);      
    }
    public static long com2(long x,long y){
        if(y==0 || y==x) return 1;
        if(x < y) return 0;
        return com2(x-1,y-1)+com2(x-1,y);
    }
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
		long [] in = new long [a];
        long [] [] pascal = new long [51][51];
        for(int i=0;i<=50;i++){
        for(int j=0;j<=i;j++){if(j==0 || j==i){pascal[i][j]=1;}
                             else{pascal[i][j]=pascal[i-1][j-1]+pascal[i-1][j];}
                             }
        }
        double d = 0;
        for(int i=0;i<a;i++){
                             in[i] = sc.nextLong();
                            }
		Arrays.sort(in);
        long e = 0;
        int f = 0;
        int g = 0;       
        for(int i=0;i<b;i++){d+=in[a-i-1];                                               
                            }
        d/=b;
        for(int i=0;i<a;i++){if(in[i]==in[a-b]){f++;if(i>=a-b){g++;}}
                            }
       
        if(d==in[a-1]){for(int i=b;i<=c;i++){e+=pascal[f][i];}}
        else{e=pascal[f][g];}
		System.out.println(d);
        System.out.println(e);
	}
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int solve(string s) {
    int res = 0;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
            ++res;
            s[i] = '#';
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    string s;
    cin >> s;
    int k;
    cin >> k;
    set <char> d;
    for (auto c : s) d.insert(c);
    if (d.size() == 1) {
        cout << ((ll)k * s.size()) / 2 << '\n';
        return 0;
    }
    ll b = solve(s);
    ll x = solve(s + s);
    cout << b + (x - b) * (k - 1) << '\n';
}

Measured memory_bytes: 256
sa = list(input())
sb = list(input())
sc = list(input())

turn = "a"
while True:
   if turn == "a":
      if len(sa) == 0:
         print("A")
         import sys
         sys.exit()
      turn = sa.pop(0)
   elif turn == "b":
      if len(sb) == 0:
         print("B")
         import sys
         sys.exit()
      turn = sb.pop(0)
   elif turn == "c":
      if len(sc) == 0:
         print("C")
         import sys
         sys.exit()
      turn = sc.pop(0)



Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let x: i32 = read();
    let mut ans = None;
    'outer: for i in 0..n + 1 {
        for j in 0..n - i + 1 {
            let k = n - i - j;
            if i * 10000 + j * 5000 + k * 1000 == x {
                ans = Some((i, j, k));
                break 'outer;
            }
        }
    }
    let (x, y, z) = ans.unwrap_or((-1, -1, -1));
    println!("{} {} {}", x, y, z);
}


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

int N;
int main(){
   cin >> N;
   if(N%2==0){
       cout << N*(N-1)/2-N/2 << endl;
       for(int i=1;i<N;i++){
           for(int j=i+1;j<=N;j++){
               if(i+j!=N+1) cout << i << " " << j << endl;
           }
       }
   }else{
       cout << N*(N-1)/2-(N-1)/2 << endl;
       for(int i=1;i<N-1;i++){
           for(int j=i+1;j<=N-1;j++){
               if(i+j!=N) cout << i << " " << j << endl;
           }
       }
       for(int i=1;i<N;i++){
           cout << i << " " << N << endl;
       }
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
using namespace std;
#define ll long long
int n,m;
map<int,int> mp;
int main()
{
    scanf("%d",&n);
    int cnt = 0 ,x;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(mp[x] == 0)
        {
            mp[x] = 1;
            cnt++;
        }
        else{
            if(mp[x] == 1)
            {
                mp[x] = 0;
                cnt--;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 4864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true) {
			String[] strArray = br.readLine().split(" ");
			int H = Integer.parseInt(strArray[0]);
			int W = Integer.parseInt(strArray[1]);

			if (H ==0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if ((i + j) %2 == 0) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 31296
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

vll comb2(int n) {
  vll v(n + 1, 0);
  REP(i, 1, n + 1) {
    v[i] = (i * (i - 1)) / 2;
  }
  return v;
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  umll M;
  REP(i, 0, N) {
    ll a;
    cin >> a;
    A[i] = a;
    if (M.find(a) == M.end()) {
      M[a] = 1;
    } else {
      M[a] += 1;
    }
  }

  ll max = 0;
  for (const auto& kv : M) {
    if (kv.second > max) {
      max = kv.second;
    }
  }

  auto v = comb2(max);

  ll maxresult = 0;
  for (const auto& kv : M) {
    maxresult += v[kv.second];
  }

  REP(i, 0, N) {
    cout << maxresult - v[M[A[i]]] + v[M[A[i]] - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,l,r,S,i;
  S = 0;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> l >> r;
    S += r-l+1;
  }
  cout << S;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int n;
	
	cin >> n;

	ll x[n];
	ll y[n];
	ll total = 0;

	rep(i, n)
	{
		cin >> x[i];
		y[i] = x[i];
		total += x[i];
	}

	sort(y, y+n, greater<ll>());

	ll tmp1 = y[n/2-1];
	ll tmp2 = y[n/2];

	rep(i, n)
	{
		if (x[i] >= tmp1)
		{
			cout << tmp2 << endl;
		}
		else
		{
			cout << tmp1 << endl;
		}
	}

	
	return 0;
}


Measured memory_bytes: 5376
/////////////////////////////////////////////////
//                                             //
//                 _ooOoo_                     //
//                o8888888o                    //
//                88" . "88                    //
//                (| -_- |)                    //
//             ____/`---'\\____                //
//           .'  \|     |//  `.                //
//           /  \|||  :  |||// \               //
//          /  _||||| -:- |||||- \             //
//          |   | \\  -  /// |   |             //
//          | \_|  ''\---/''  |  |             //
//          \  .-\__  `-`  ___/-. /            //
//         ___`. .'  /--.--\  `. . __          //
//      ."" '<  `.___\_<|>_/___.'  >'"".       //
//     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     //
//     \  \ `-.   \_ __\ /__ _/   .-` /  /     //
//=====`-.____`-.___\_____/___.-`____.-'=======//
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//.............................................//
/////////////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll modn=998244353;
const ll INF = 0x3f3f3f3f;
int a[100100];
int inva[100100];
int b[100100];
int aa[100100];
int bb[100100];
int n;
int main(){

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        aa[i]=a[i];
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
        bb[i]=b[i];
    }
    sort(aa,aa+n);
    sort(bb,bb+n);
    int flag = 0;
    for(int i=0;i<n;i++){
           if(aa[i]>bb[i])
            flag = 1;
    }

    if(flag == 1){
        printf("No\n");
        return 0;
    }
    for(int i=1;i<n;i++){
           if(aa[i]<=bb[i-1]  ||aa[i]==aa[i-1] || bb[i]==bb[i-1])
            flag = 1;
    }
    if(flag == 1){
        printf("Yes\n");
        return 0;
    }
    for(int i=0;i<n;i++){
        a[i]=lower_bound(aa,aa+n,a[i])-aa;
        aa[a[i]]--;
        inva[a[i]]=i;
        b[i]=lower_bound(bb,bb+n,b[i])-bb;
        bb[b[i]]--;
    }
    int cnt = 0;
    int pos = 0;
    do{
        pos = inva[b[pos]];
        cnt++;
    }while(pos);
    if(cnt <=n-2)flag = 1;

    if(flag == 1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 2304
//F  按位枚举 
#include<iostream>
#include<cstdio>
using namespace std;
int f[15];
int p[15];
int cnt[1030];
void initialize()
{
	for(int i=0;i<1024;i++)
	{
		for(int j=0;j<10;j++)
		{
			if((i>>j)&1)
				cnt[i]++;
		}
	}
}
int main()
{
	initialize();
	int n,m,ans=0;//n:switch m:light
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x;
		scanf("%d",&x);
		for(int j=1;j<=x;j++)
		{
			int y;
			scanf("%d",&y);
			y--;////位运算从0开始
			f[i]|=1<<y; 
		} 
	}	
	for(int i=1;i<=m;i++)
		scanf("%d",&p[i]);
	for(int i=0;i<(1<<n);i++)
	{
		bool ok=1;
		for(int j=1;j<=m;j++)
		{
			if(cnt[f[j]&i]%2!=p[j]) ok=0;
		}
		if(ok) 
		{
			ans++;	
		}
	}
	printf("%d",ans);
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import math
N,M=map(int, input().split())
if abs(N - M) > 1:
  print(0)
elif N == M:
  print((2*math.factorial(N)*math.factorial(M))%int(1e9+7))
else:
  print((math.factorial(N)*math.factorial(M))%int(1e9+7))


Measured memory_bytes: 5180
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
 char s;cin>>s;
 if(s=='A') cout<<"T"<<endl;
 if(s=='T') cout<<"A"<<endl;
 if(s=='G') cout<<"C"<<endl;
 if(s=='C') cout<<"G"<<endl;

}


Measured memory_bytes: 256
#pragma once

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define ooi 1000000007

using namespace std;
string S;
long long int N, A[2], B[2] ,X,M;
long long int a[200001];
long long int myMax,myMin;
long long int result=5000000000;
int step[2] = { 1,1 };


int main() {
	cin >>N;
	A[0] = 0;
	B[0] = 0;
	A[1] = 0;
	B[1] = 0;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	
	for (int i = 0; i < N; i++) {
		A[0] += a[i];
		if (A[0] > 1000000000) {
			A[1] += A[0] / 1000000000;
			A[0] = A[0] % 1000000000;
		}
	}
	myMax = A[0] + A[1] * 1000000000;
	for (int i = 0; i < N-1; i++) {
		B[0] += a[i];
		//if (B[0] > 1000000000) {
			B[1] += B[0] / 1000000000;
			B[0] = B[0] % 1000000000;
			if (myMax - (B[0] + B[1] * 1000000000) <= B[0] + B[1] * 1000000000) {
				if ((B[0] + B[1] * 1000000000) -( myMax - (B[0] + B[1] * 1000000000))< result) {
					result = (B[0] + B[1] * 1000000000) - (myMax - (B[0] + B[1] * 1000000000));
				}
			}
			else {
				if (myMax-( B[0] + B[1] * 1000000000) - (B[0] + B[1] * 1000000000 ) < result) {
					result = myMax - (B[0] + B[1] * 1000000000) - (B[0] + B[1] * 1000000000);
				}
			}
		//}
	}

	/*
	while (step[0] + step[1] < N) {

		if (A[1] < B[1]) {
			A[0] += a[step[0]];
			step[0]++;
			if (A[0] > 1000000000) {
				A[1] += A[0] / 1000000000;
				A[0] = A[0] % 1000000000;
			}
		}
		else if (A[1] < B[1]) {
			B[0] += a[N-step[1]-1];
			step[1]++;
			if (B[0] > 1000000000) {
				B[1] += B[0] / 1000000000;
				B[0] = B[0] % 1000000000;
			}
		}
		else if (A[0]<=B[0]) {
			A[0] += a[step[0]];
			step[0]++;
			if (A[0] > 1000000000) {
				A[1] += A[0] / 1000000000;
				A[0] = A[0] % 1000000000;
			}
		}
		else {
			B[0] += a[N - step[1] - 1];
			step[1]++;
			if (B[0] > 1000000000) {
				B[1] += B[0] / 1000000000;
				B[0] = B[0] % 1000000000;
			}
		}

	}
	
	if (A[1] > B[1]) {
		result = (A[1] - B[1]) * 1000000000 + A[0]-B[0];
	}
	else if (A[1] < B[1]) {
		result = (B[1] - A[1]) * 1000000000 - A[0] + B[0];
	}
	else if (A[0] > B[0]) {
		result = A[0] - B[0];
	}
	else {
		result = B[0] - A[0];
	}
	*/
	cout << result<< endl;

	return 0;
}




Measured memory_bytes: 1792
import java.util.*;
class Main {
	public static void main(String...args) {
		Scanner scan = new Scanner(System.in);
		int count = 0;
		int aryLen = scan.nextInt();
		int[] ary = new int[aryLen];
		boolean flag = true;
		for(int i = 0 ; i < aryLen; i++) {
			ary[i] = scan.nextInt();
		}
		while(flag) {
			flag = false;
			for(int n = aryLen-1; n > 0; n--) {
			int tmp = ary[n];
				if(ary[n] < ary[n-1]) {
					ary[n] = ary[n-1];
					ary[n-1] = tmp;
					flag = true;
					count++;
				}
			}
		}
		for(int i = 0 ; i < aryLen; i++) {
			System.out.print(ary[i]);
			if(i != aryLen-1){
				System.out.print(" ");
			} else {
				System.out.println();
		    }
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26356
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool b = true;
    for(int i = 0; i < n; i++){
        int c;
        cin >> c;
        if(c % 2 == 0){
            if(c % 3 != 0 && c % 5 != 0)
            b = false;
        }
    }
    b == true ? cout << "APPROVED" : cout << "DENIED";
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N; 
  cin >> N;
  vector<int> vec(N);
  int Alice, Bob;
  
  for (int i = 0; i < vec.size();i++) cin >> vec.at(i);
  
  sort(vec.begin(),vec.end(),greater<int>());
  
  for (int i = 0; i < vec.size(); i++){
    if(i % 2 == 1) Bob += vec.at(i);
    if(i % 2 == 0) Alice += vec.at(i);
  }
  
  cout << Alice - Bob << endl;
  
}

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a[2],b[2];
  for (int i = 0; i < 2; i++){
    cin >> a[i];
  }
  for (int i = 0; i < 2; i++){
    cin >> b[i];
  }
  sort (a,a+2);
  sort (b,b+2);
  cout << a[0] + b[0] << '\n';
  
  return 0;
}

Measured memory_bytes: 256
#define TEST

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;


class Node
{
    public int color = -1;
    public List<int> child = new List<int>();
    public List<int> leng = new List<int>();
}

class Program
{
    static int n;
    static Node[] g;
    static bool[] visited;

    static void Main()
    {
        n = int.Parse(Console.ReadLine());
        g = new Node[n];
        for (int i = 0; i < n; i++) g[i] = new Node();
        visited = new bool[n];
        for (int i = 0; i < n - 1; i++)
        {
            int u, v, w;
            string[] s = Console.ReadLine().Split();
            u = int.Parse(s[0]) - 1;
            v = int.Parse(s[1]) - 1;
            w = int.Parse(s[2]) % 2;
            g[u].child.Add(v);
            g[u].leng.Add(w);
            g[v].child.Add(u);
            g[v].leng.Add(w);
        }
        g[0].color = 0;
        dfs(0);
        for (int i = 0; i < n; i++)
            Console.WriteLine(g[i].color);
    }

    static void dfs(int v)
    {
        visited[v] = true;
        for (int i = 0; i < g[v].child.Count; i++)
        {
            int u = g[v].child[i];
            int l = g[v].leng[i];
            if (l == 0)
            {
                g[u].color = g[v].color;
            }
            else
            {
                g[u].color = g[v].color == 0 ? 1 : 0;
            }
            if (!visited[u]) dfs(u);
        }
    }
}

Measured memory_bytes: 41760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],d,ab[500][50],ac[50];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>d;
    rep(i,26){
        cin>>aa[i];
    }
    rep(i,d){
        rep(j,26){
            cin>>ab[i][j];
        }
    }
    rep(i,d){
        cnt=0;
        int as=0;
        rep(j,26){
            m=0;
            m+=ab[i][j];
            rep(k,26){
                if(k!=j){
                    m-=(ac[k]+1)*aa[k];
                }
            }
            if(cnt<m){
                as=j+1;
                cnt=m;
            }
        }
        cout<<as<<endl;
    }
}

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

int main(){
  int i,j,cnt=0;
  ll s;
  cin>>s;
  ll n=(ll)round(sqrt(s));
  ll p=1;
  for(i=0;i<9;i++)p*=10;
  if(s==p*p){
    cout<<0<<" "<<p<<" "<<p<<" "<<0<<" "<<0<<" "<<0;
    return 0;
  }
  ll a=s/n+1,b=n,c=1,d=n-s%n;
  cout<<a<<" "<<d<<" "<<c<<" "<<b<<" "<<0<<" "<<0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int a,b,i;
        scanf("%d%d",&a,&b);
        if(a>b){
           for(i=0;i<a;i++)
              printf("%d",b);
           printf("\n");
        }

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

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

        return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>

//??´?§?????§???¢?????????????????????????????¢??°
int triangle(int a, int b, int c){
  if(a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b){
    return 1; //??´?§?????§???¢??§????????¨???
  }
  else
    return 0; //??´?§?????§???¢??§????????¨???
}

int main(){
  int a, b, c; //3???????????°
  int n; //???????????????????????°
  
  //std::cout << "Input the number of dataset\n";
  std::cin >> n;

  int ans[n];
  for(int i=0; i<n; i++){
    std::cin >> a >> b >> c;
    ans[i] = triangle(a, b, c);
  }

  for(int i=0; i<n; i++){
    if(ans[i] == 1)
      std::cout << "YES\n";
    else if(ans[i] == 0)
      std::cout << "NO\n";
  }
  
  return 0;
  
}

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

vector<long long>v(1e7+1,1);
vector<long long>v1(1e7+1,1);
void solve(){
    for(long long i=2;i<=1e7;i++){
       for(long long j=i;j<=1e7;j+=i){
           v[j]++;
       }
       v1[i]=i*v[i];
       v1[i]=v1[i]+v1[i-1];
    }
}
int main(){
     long long a;
     cin>>a;
     solve();
     cout<<v1[a];
}

Measured memory_bytes: 159360
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

const debug = false

func (p *problem) solve() {
	a, b, c, d := p.NextInt(), p.NextInt(), p.NextInt(), p.NextInt()
	p.PrintInt(min(a, b) + min(c, d))
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	if debug {
		log.SetOutput(os.Stdout)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	string s, t, u;
	cin >> n >> s >> t;
	
	inc(i, n) { u += s[i]; u += t[i]; }
	
	cout << u << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ps = list(mapint())

m = 10**18
ans = 0
for p in Ps:
    if p<=m:
        ans += 1
        m = p

print(ans)

Measured memory_bytes: 99924
#include<bits/stdc++.h>
#include<stdio.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pwi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<pair<ll,ll > > > wGraph;
typedef vector<vector<ll> > graph;
//typedef vector<vector<ll> > matrix;

int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);

    string a,b;
    cin>>a;
    cin>>b;

    int cnt = 0;
    for(int i = 0;i<a.size();++i){
        if(a[i]!=b[i]) ++cnt;
    }

    cout<<cnt<<endl;

    return 0;   
}


Measured memory_bytes: 3824
def is_ok(mid):   
    global N, K, A
    cnt = 0
    flag = True
    for i in range(N):
        if A[i] <= mid:
            break
        if cnt + A[i] // mid > K:
            flag = False
            break
        cnt += A[i] // mid
    if flag:
        return True
    return False

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

ok = max(A)
ng = 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid
print(ok)


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

int main(){
    int a,b,c;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '?')break;
        
        if(op == '+'){ cout << a+b << endl;}
        else if(op == '-'){ cout << a-b << endl;}
        else if(op == '*'){ cout << a*b << endl;}
        else if(op == '/'){ cout << a/b << endl;}
    
    }
    return 0;
}


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

int main(){
  int i,j,n,m,a[1000],ans;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    for(i=0;i<n;i++) cin >> a[i];

    sort(a,a+n);
    ans = 0;
    j = 1;
    for(i=n-1;i>=0;i--){
      if(j == m) j = 0;
      else ans += a[i];
      j++;
    }
    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() 
{ 
    ll a,b,c,k; cin >> a >> b >> c >> k;
    ll sum=0;
    ll count=0;
    while(a--)
    {
        sum=sum+1;
        count++;
        if(count==k)
        {
            cout << sum;
            return 0;
        }
    }
    while(b--)
    {
        sum=sum+0;
        count++;
        if(count==k)
        {
            cout << sum;
            return 0;
        }
    }
    while(c--)
    {
        sum=sum-1;
        count++;
        if(count==k)
        {
            cout << sum;
            return 0;
        }
    }
}

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

int main() {
	int n, cp, s=0;
	cin >> n;
	cp = n;
	for (int i = 0; i < 10; i++) {
		s += n % 10;
		n /= 10;
	}
	if (cp%s)cout << "No\n";
	else cout << "Yes\n";
}

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

using namespace std;

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

  int n, h;
  cin >> n;
  int res = 0, mx = 0;
  for (int i = 0; i < n; ++i) {
    cin >> h;
    if (h >= mx) {
      ++res;
      mx = h;
    }
  }
  cout << res << endl;


  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

char hi[5], ji[5];
int main()
{
    for (int i = 0; i < 3; i++)
    {
        scanf("%c",&hi[i]);
    }
    getchar();
    for (int j = 0; j < 3; j++)
    {
        scanf("%c",&ji[j]);
    }
    if(hi[0] == ji[2] && hi[1] == ji[1] && hi[2] == ji[0])
        printf("YES\n");
    else
        printf("NO\n");
}

Measured memory_bytes: 128
s = input()

i = len(s)
while i > 0:
    if s[i - 5:i] == 'dream':
        i -= 5
    elif s[i - 7:i] == 'dreamer':
        i -= 7
    elif s[i - 5:i] == 'erase':
        i -= 5
    elif s[i - 6:i] == 'eraser':
        i -= 6
    else:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 9244
H,W = map(int,input().split())
HW = []
for i in range(H+2):
    if i == 0 or i == H+1:
        HW.append(["."]*(W+1))
    else:
        HW.append(["."]+list(input())+["."])

for i in range(1,H):
    for j in range(1,W):
        if HW[i][j] == "#":
            if HW[i-1][j] == "#" or HW[i][j-1] == "#" or HW[i+1][j] == "#" or HW[i][j+1] == "#":
                continue
            else:
                print("No")
                exit()
print("Yes")





Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();
		int[] d=new int[100];
		int i,k,cnt=1,min;
		for(i=0;i<N;i++) {
			d[i]=sc.nextInt();
		}
		for(i=0;i<N-1;i++){
		      for(k=N-1;k>i;k--){
		    	  if(d[k]<d[k-1]){
		    		  int t=d[k];
		    		  d[k]=d[k-1];
		    		  d[k-1]=t;
		    	  }
		      }
		}
		min=d[0];
		for(i=1;i<N;i++) {
			if(min<d[i]) {
				cnt++;
				min=d[i];
			}
		}
		System.out.println(cnt);
	}
}



Measured memory_bytes: 23508