akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	string s;
	cin >> s;

	int sz = s.size();
	int i = 0, j = sz - 1;
	int min_operations = 0;
	while (i < j) {
		if (s[i] == s[j]) {
			++i;
			--j;
		} else {
			if (s[i] != 'x' && s[j] != 'x') {
				break;
			}
			else if (s[i] == 'x') {
				++i;
			} else {
				--j;
			}

			++min_operations;
		}
	}

	if (i < j) {
		cout << "-1\n";
	} else {
		cout << min_operations << "\n";
	}

	return 0;

}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
    public static int calc(List<Integer> list){
        int A = list.size();
        int ans = 0;
        //p^74
        for(int i=0;i<A;i++){
            if(list.get(i)>=74) ans++;
        }
        //p^24 q^2, p^14 q^4
        for(int i=0;i<A;i++) for(int j=0;j<A;j++) if(i!=j){
            if(list.get(i)>=24 && list.get(j)>=2) ans++;
            if(list.get(i)>=14 && list.get(j)>=4) ans++;
        }
        //p^4 q^4 r^2 (p<q)
        for(int i=0;i<A;i++)for(int j=i+1;j<A;j++) for(int k=0;k<A;k++) if(i!=k && j!=k){
            if(list.get(i)>=4 && list.get(j)>=4 && list.get(k)>=2) ans++;
        }
        return ans;
    }


    public static int solve(int N){
        int[] primes = new int[101];
        for(int n=2; n<=N; n++){
            int m=n;
            int d=2;
            while(m>1){
                if(m%d==0){
                    m /= d;
                    primes[d]++;
                }else{
                    d++;
                }
            }
        }
        List<Integer> p = new ArrayList<>(25);
        for(int x: primes) if(x>0) p.add(x);



        return calc(p);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(solve(N));

    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
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;
}
int main() {
	ll n,k;
	cin>>n>>k;
    COMinit();	
	vector<ll>ch;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		ch.push_back(x);
	}
	sort(ch.begin(),ch.end());
	ll ma=0,mi=0;
	for(ll i=0;i<n;i++){
		ll zan=n-(i+1);
		if(zan<=0){
			continue;
		}
		ll now=(ch[i]*COM(zan,k-1));
		mi+=now;
		mi%=inf;
		if(mi<0){
			mi+=inf;
		}
	}
	reverse(ch.begin(),ch.end());
	for(ll i=0;i<n;i++){
		ll zan=n-(i+1);
		if(zan<=0){
			continue;
		}
		ll now=(ch[i]*COM(zan,k-1));
		ma+=now;
		ma%=inf;
		if(ma<0){
			ma+=inf;
		}
	}
	if(ma-mi<0){
		cout << ma-mi+inf;
		return 0;
	}
	cout << ma-mi;
	return 0;
}

Measured memory_bytes: 16192
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NMAX=2000,VALMAX=2*1e4;
int n,y,billets[3]={1,5,10},prec[2][VALMAX];
bool possible[2][VALMAX];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> y;
	y/=1000;
	
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			int k=n-i-j;
			if(10*i+5*j+k==y){
				cout << i << ' ' <<j << ' ' << k << '\n';
				return 0;
			}
		}
	}
	
	cout << "-1 -1 -1\n";
}


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

using namespace std;
typedef pair<int, int> P;

const int INF = 1000000000;
int n, m;
vector<vector<P>> map;
int dp[150][10][80];

int main() {
	while (cin >> n >> m, n + m) {
		map.resize(n);
		for (int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			for (int j = 0; j < tmp; j++) {
				int a, b;
				cin >> a >> b;
				map[i].push_back(P(a - 1, b));
			}
		}
		for (int i = 0; i < 150; i++)for (int j = 0; j < 10; j++)for (int k = 0; k < 80; k++)dp[i][j][k] = INF;
		for (int i = 0; i < map[0].size(); i++) {
			dp[0][i][m] = 0;
		}
		for (int i = 0; i < map[1].size(); i++) {
			if (m != 0)dp[1][i][m - 1] = 0;
		}
		for (int i = 0; i < n - 1; i++) {
			for (int j = 0; j < map[i].size(); j++) {
				for (int k = 0; k <= m; k++) {
					if (i + 1 < n) {
						for (int l = 0; l < map[i + 1].size(); l++) {
							auto now = map[i][j];
							auto next = map[i + 1][l];
							dp[i + 1][l][k] = min(dp[i + 1][l][k],
								dp[i][j][k] + abs(next.first - now.first) * (now.second + next.second));
						}
					}
					if (i + 2 < n && k != 0) {
						for (int l = 0; l < map[i + 2].size(); l++) {
							auto now = map[i][j];
							auto next = map[i + 2][l];
							dp[i + 2][l][k - 1] = min(dp[i + 2][l][k - 1],
								dp[i][j][k] + abs(next.first - now.first) * (now.second + next.second));
						}
					}
					//cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
				}
			}
		}
		int ans = INF;
		for (int i = 0; i < map[n - 2].size(); i++) {
			for (int j = 1; j <= m; j++) {
				ans = min(ans, dp[n - 2][i][j]);
			}
		}
		for (int i = 0; i < map[n - 1].size(); i++) {
			for (int j = 0; j <= m; j++) {
				ans = min(ans, dp[n - 1][i][j]);
			}
		}
		cout << ans << endl;
		map.clear();
	}
	return 0;
}

Measured memory_bytes: 3484
(N,) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)

n1 = 1 + ((N - 2) // 2)
n2 = N - n1

print(sum(A[:n1]) + sum(A[1:n2]))


Measured memory_bytes: 94256
from fractions import Fraction
N , K = list(map(int,input().split()))
denom_list = []
Z=0


def detame_keisan( N , K , i ):
    kijun = K
    score = i
    count = 0
    
    while score < kijun:
        count += 1
        score = ( score *  2 )
    return N * (2 ** count)

for i in range( 1,N+1 ):
    X = detame_keisan( N , K , i)
    denom_list.append( X )

for item in denom_list:
    #Z += 1/item
    Z += Fraction(1, item)
#print( Z)
print( float( Z ))

Measured memory_bytes: 14220
#include<iostream>
#include<algorithm>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int h,n;
    cin >> h >> n;
    int a[n];
    F(i,0,n) cin >> a[i];
    sort(a,a+n,greater<>());
    F(i,0,n){
        h-=a[i];
        if(h<=0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int digit(int n, int k) {
    int ret = 0;
    while(n) {
        n /= k;
        ret++;
    }
    return ret;
}

int main() {
    int N, K;
    cin >> N >> K;
    cout << digit(N, K) << endl;
    return 0;
}

Measured memory_bytes: 256
//itp1_topic4_a

#include<bits/stdc++.h>

using namespace std;


    int main(){

	cout<<fixed<< setprecision(12);

	
	int a, b;

	cin>>a>>b;

	cout<< a / b << " " ;

	cout<< a % b << " " ;

	cout<< (double)a / b <<endl;


	return 0;

}



Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    int N;
    cin >> N;
    vector<ll> X(N);
    vector<ll> Y(N);

    ll l;
    for(int i=0;i<N;i++){
        cin >> l;
        X[i] = Y[i] = l;
    }
    sort(Y.begin(),Y.end());
    ll L = Y[(N-2)/2];
    ll R = Y[(N-2)/2+1];
    for(int i=0;i<N;i++){
        if(X[i] <= L){
            cout << R << endl;
        }
        else{
            cout << L << endl;
        }
    }
}


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

int find_sum_of_digits(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int total = 0;
    
    for(int i = 1; i <= n; ++i){
        int sum = find_sum_of_digits(i); // iの各桁の総和
        if(sum >= a && sum <= b){ // iの各桁の和がa以上b以下であるかどうか
            total += i;
        }
    }
    
    cout << total << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=sc.nextInt();
		}
		int min[]=new int[n];
		min[0]=0;
		min[1]=(int)Math.abs(h[1]-h[0]);
		for(int i=2;i<n;i++)
		{
			int h1=(int)Math.abs(h[i]-h[i-1])+min[i-1];
			int h2=(int)Math.abs(h[i]-h[i-2])+min[i-2];
			min[i]=h1<h2?h1:h2;
		}
		System.out.println(min[n-1]);
	}

}


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

using namespace std;

int val[13];

vector <int> last;
vector <int> at;


int main() {
	int n;
	scanf("%d", &n);
	val[0]++;
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		val[x]++;
	}
	int ans = 0;
	last.push_back(0);

	for(int i = 0; i <= 12; i++){
		if(i == 0 || i == 12){
			if(val[i] == 0){
				for(int x: last){
					at.push_back(x);
				}
			}
			else if(val[i] == 1){
				for(int x: last){
					at.push_back(x|(1<<i));
				}
			}
			else{
				ans = -1;
				break;
			}
		}
		else{
			if(val[i] == 0){
				for(int x: last){
					at.push_back(x);
				}				
			}
			else if(val[i] == 1){
				for(int x: last){
					at.push_back(x|(1<<i));
					at.push_back(x|(1<<(24-i)));
				}			
			}
			else if(val[i] == 2){
				for(int x: last){
					at.push_back(x|(1<<i)|(1<<(24-i)));
				}						
			}
			else{
				ans = -1;
				break;
			}
		}
		last.clear();
		last = at;
		at.clear();
	}
	if (ans == -1) {
		printf("0\n");
		return 0;
	}
	for (int x : last) {
		vector <int> pos;
		for(int i = 0; i < 25; i++){
			if(x & (1 << i)){
				pos.push_back(i);
			}
		}
		int pn = pos.size();
		int an = 24;
		for (int j = 0; j < pn; j++) {
			int calc = pos[(j+1)%pn]-pos[j];
			if(calc < 0) calc += 24;
			//printf("%x %d\n", x, calc);
			an = min(an, calc);
		}
		ans = max(ans, an);
	}
	printf("%d\n", ans);

}

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

using namespace std;

int main()
{
	int n;
	vector<int> num;
	do
	{
		cin >> n;
		num.push_back(n);
	}while (n != 0);
	num.pop_back();

	int dp[30];
	dp[0] = 1;
	dp[1] = 2;
	dp[2] = 4;

	for (int i = 3; i < 30; i++)
	{
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}

	for (auto it = num.begin(); it != num.end(); it++)
	{
		cout << dp[*it - 1]/3650 + 1 << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a + b < 24) {
        cout << a + b << "\n";
    } else {
        cout << (a + b) % 24 << "\n";
    }


}









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

int main(){
    ll n,qq,i;
    map<ll,ll> mp;
    cin>>n;
    ll arr[n],sum=0,a,b;
    for(auto &x:arr){
        cin>>x;
        sum^=x;
    }
    for(auto &x:arr){
        cout<<(sum^x)<<" ";
    }

}


Measured memory_bytes: 5152
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int N, A;
	cin >> N >> A;

	int a = N % 500;

	if (a <= A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	
}


Measured memory_bytes: 3640
n, k = map(int, input().split())

mod = 10 ** 9 + 7

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % mod
        x = x * x % mod
        n //= 2

    return K * x % mod


memo = {}
ans = 0

for x in reversed(range(1, k + 1)):
    memox = pow_k((k // x), n)
    for i in range(2, k // x + 1):
        memox -= memo[i * x]
        memox %= mod
    memo[x] = memox
    ans += x * memox % mod
    ans %= mod

print(ans)


Measured memory_bytes: 20572
N, M = STDIN.gets.split(' ').map{|s| s.to_i}

index = 1
problems = []
while line = STDIN.gets
  n, a= line.chomp.split(' ')
  problems[index] = [n.to_i, a]
  index += 1
end

ans = []
ac = 0
wa = 0
1.upto(M) do |i|
  n, a = problems[i]
  if ans[n].nil?
    # 初めてでてくる問題番号
    ans[n] = [-1, 0]
  end
  if ans[n][0] != -1
    # すでにこの問題は正解済み
    next
  end

  if a == 'WA'
    # 間違えた
    ans[n][1] += 1
  else
    # 正解した
    ans[n][0] = 1
    ac += 1
    wa += ans[n][1]
  end

end

puts "#{ac} #{wa}"


Measured memory_bytes: 20476
N = int(input())
A = list(map(int, input().split()))
A.sort()
sumA = sum(A)-A[N-1]
memo = 0

for i in range(N-1,-1,-1):
  if sumA*2<A[i] or i==0:
    memo = i
    break
  sumA -= A[i-1]
print(N-memo)

Measured memory_bytes: 14320
N = int(input())
C = {(i,j):0 for i in range(1,10) for j in range(1,10)}
num = list(range(1,10))
for k in range(1,N+1):
    k = str(k)
    i = int(k[0])
    j = int(k[-1])
    if i in num and j in num:
        C[(i,j)] += 1
cnt = 0
for i in range(1,10):
    for j in range(1,10):
        cnt += C[(i,j)]*C[(j,i)]
print(cnt)

Measured memory_bytes: 73720
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
S = list(str(input()))

if S[0] != "A" :
  print ("WA")
  exit()
else :
  S[0] = "a"

cflag = False
for i in range(2, len(S)-1) :
  #print(S[i])
  if S[i] == "C" :
    S[i] = "c"
    cflag = True
    break

if cflag == False :
  print ("WA")
  exit()
    
for j in range(len(S)) :
  if S[j].islower() == False :
    print ("WA")
    exit()
print ("AC")
  
  
  

Measured memory_bytes: 38384
N = int(input())

def digsum(n):
    total = 0
    while n > 0:
        total += n%10
        n /= 10
        n = int(n)
    return total

ans = float('inf')
for i in range(2, N//2+2):
    A = i
    B = N-A
    s = digsum(A)+digsum(B)
    ans = min(ans, s)

print(ans)

Measured memory_bytes: 3060
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.chomp.to!int).array;
    auto S = new int[](100001);
    foreach (i; 0..100001)
        S[i] = int.max;
    S[0] = -1;
    S[1] = A[0];
    auto SS = S.assumeSorted;

    int ans = 1;
    foreach (i; 1..N) {
        auto lb = SS.lowerBound(A[i]).length.to!int;
        ans = max(ans, lb);
        if (S[lb] > A[i])
            S[lb] = A[i];
    }
    ans.writeln;
}

Measured memory_bytes: 3964
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  vector<ll> s(N+1); // s[i] .. sum of [0, i)
  rep(i, N) {
    s[i+1] = s[i] + A[i];
  }
  // For Debug
  // rep(i, N+1) {
  //   cout << s[i] << endl;
  // }

  vector<ll> l(N); // the left index of each middle i. the middle in [0, i].
  vector<ll> r(N); // the left index of each middle i. the middle in [i+1, N-1].
  ll left = 0;
  for (int i = 1; i < N-2; ++i) { // calculate l in [1, N-3]
    ll summed = s[i+1]; // The sum of [0, i]
    while ((left <= N) && abs(summed - s[left+1]*2) < abs(summed - s[left]*2)) {
      ++left;
    }
    // Here, left is the index of minimum. summed - s[left] is minimum.
    l[i] = left;
  }
  ll right = 1;
  for (int i = 1; i < N-2; ++i) { // calculate r in [1, N-3]
    while ((right <= N) && abs((s[N]-s[right+1]) - (s[right+1]-s[i+1])) < abs((s[N]-s[right]) - (s[right]-s[i+1]))) {
      ++right;
    }
    // Here, right is the index of minimum. s[N] - s[right] is minimum.
    r[i] = right;
  }

  ll ans = INF;
  for (int i = 1; i < N-2; ++i) {
    ll left = l[i];
    ll right = r[i];

    ll l1 = s[left];
    ll l2 = s[i+1] - s[left];
    ll r1 = s[right] - s[i+1];
    ll r2 = s[N] - s[right];
    // For Debug
    // cout << l1 << "," << l2 << "," << r1 << "," << r2 << endl;
    ll min_v = min(min(l1, l2), min(r1, r2));
    ll max_v = max(max(l1, l2), max(r1, r2));
    ans = min(ans, abs(max_v - min_v));
  }

  cout << ans << endl;
}


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

int main() {
    ll n, m, a, b, c;
    std::vector<pair<ll, ll>> ps;
    cin >> n >> m;
    for (int i=0; i<n; ++i) {
        cin >> a;
        ps.push_back(make_pair(a, 1));
    }
    for (int i=0; i<m; ++i) {
        cin >> b >> c;
        ps.push_back(make_pair(c, b));
    }

    std::sort(ps.rbegin(), ps.rend());

    ll i = 0, num = 0, ans = 0;
    while (true) {
        if (ps[i].second + num > n) {
            ans += max(n - num, ll(0)) * ps[i].first;
            break;
        } else {
            ans += ps[i].second * ps[i].first;
            num += ps[i].second;
            i += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	bool is_prime[100000];

	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<100000;i++){
		is_prime[i]=true;
	}

	for(int i=2;i*i<100000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<100000;j+=i){
				is_prime[j]=false;
			}
		}
	}

	while(true){

		int n;
		cin>>n;

		if(cin.eof()){
			break;
		}

		int tmp = n;
		while(true){
			tmp--;
			if(is_prime[tmp]==true){
				cout << tmp << " ";
				break;
			}
		}
		tmp = n;
		while(true){
			tmp++;
			if(is_prime[tmp]==true){
				cout << tmp << endl;
				break;
			}
		}
	}
	return 0; 
}


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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

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

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int m=s.size();
  int flag=0;
  for(int i=0; i<m; i++){
    if(s.at(i)!=t.at(i))flag=1;
  }
  if(flag==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int coin[]={500,100,50,10,5,1};
int main(){
    int N;
    while(scanf("%d",&N),N){
        N=1000-N;
        int ans=0;
        for(int i=0;i<6;i++){
            ans+=N/coin[i];
            N%=coin[i];
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1188
object Main{
  def main(args:Array[String]) = {
    val s = scala.io.StdIn.readLine.split("").map(_.toString).sortWith((a,b) => a < b).toList.mkString("")
    val t = scala.io.StdIn.readLine.split("").map(_.toString).sortWith((a,b) => a > b).toList.mkString("")
    if(s < t){
      println("Yes")
    } else {
      println("No")
    }
  }
}


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

N = int(input())
s = [input() for i in range(N)]

output = 0
dic = dict()
for i in range(N):
    tmp = ''.join(sorted(s[i]))
    if tmp not in dic:
        dic[tmp] = 1
    else:
        output += dic[tmp]
        dic[tmp] += 1

print(output)


Measured memory_bytes: 24976
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++) h[i] = scan.nextInt();
        Arrays.sort(h);
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < n - k + 1; i++){
            min = Math.min(min, h[i + k - 1] - h[i]);
        }
        System.out.println(min);
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 57780
awk 'function abs(x){return x<0?-x:x}
NR>2{
    j=0
    m=10000000
    for(i=1;i<=NF;++i){
        tmp = abs(t-$i*0.006-a)
        if (tmp < m) {
            m = tmp
            j = i
        }
    }
    print j
}
{t=$1;a=$2}'


Measured memory_bytes: 680
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  string a;
  cin>>a;
  int b=-1,c=-1,d=a.size();
  fo(i,d-2){
    if(a[i]==a[i+1]||a[i]==a[i+2]){
      b=i+1;
      c=i+3;
    }
  }
  if(a[d-2]==a[d-1]){
    b=d-1;
    c=d;
  }
  cout<<b<<' '<<c<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define dl double
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL)
#define cases ll t; cin>>t; while(t--)
#define rep1(qq,pp) for(ll i=qq;i<pp;i++)
#define rep2(qqq,ppp) for(ll i=qqq;i>=ppp;i--)
#define nl "\n"
#define Y cout<<"Yes\n"
#define N cout<<"No\n"
//cout<<fixed<<setprecision(13);

int main(){
	faster;

    ll n,ans=0;
	
	cin>>n;
	
	ll a[n];
	
	rep1(0,n){
	    cin>>a[i];
	    
	    if(i>0 && a[i]<a[i-1]){
	        ans+=(a[i-1]-a[i]);
	        a[i]+=(a[i-1]-a[i]);
	    }
	}
	
	cout<<ans<<nl;
}

Measured memory_bytes: 5196
#include <iostream>
#include <cstdio>

int main(){
	while(1){
		int n, m, now=1, count=0;
		int p[1001] = {0};
		
		scanf(" %d %d", &n, &m);
		if(n==0 && m==0) break;
		
		int max=n;
		
		while(count < n-1){
			int i=0;
			while(i<m-1){
				
				if(p[now]==0){
					++i;
					if(now==n) now=1;
					else ++now;	
				}
				while(p[now]==1){
					if(now==n) now=1;
					else ++now;
				}
				
				//printf("now=%d\n", now);
			}
		
			p[now]=1;
			//3printf("%d,out\n", now);
			++count;
		}
	
		for(int j=1; j<=n; ++j){
			if(p[j]==0){
				printf("%d\n", j);
			}
		}
	
	}

	return 0;
}

Measured memory_bytes: 1192
def gcd(a, b):
    big, small = max(a, b), min(a, b)
    if big % small == 0:
        return small
    div = None
    while big % small != 0:
        div = big % small
        big, small = small, div
    else:
        return div


N, X = map(int, input().split())
x = map(int, input().split())
x = [xi - X for xi in x]

d = x[0]
for xi in x[1:]:
    d = gcd(d, xi)
print(abs(d))


Measured memory_bytes: 14224
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int rev_mod(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

long long int A[110000];
long long int fact[110000], factM[110000];

int main(){
	fact[0] = factM[0] = 1;
	for(int i = 1; i < 110000; i++){
		fact[i] = fact[i - 1] * i % MOD;
		factM[i] = factM[i - 1] * rev_mod(i) % MOD;
	}
	long long int N, K;
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	sort(A, A + N);
	long long int ans = 0;
	for(int i = 0; i <= N - K; i++){
		// (N - 1 - i)C(K - 1)
		ans -= (A[i] + MOD) * fact[N - 1 - i] % MOD * factM[K - 1] % MOD * factM[N - i - K] % MOD;
		ans += MOD;
		ans %= MOD;
	}
	reverse(A, A + N);
	for(int i = 0; i <= N - K; i++){
		ans += (A[i] + MOD) * fact[N - 1 - i] % MOD * factM[K - 1] % MOD * factM[N - i - K] % MOD;
		ans += MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int ii = a; ii <= (b); ++ii) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	int n;
	cin >> n;
	vector<ll>a(n);
	ll temp = -1;
	bool sc = true;
	rep0(i, n - 1) {
		scanf("%lld", &a[i]);
	}
	rep0(j, n - 1) {
		if (temp > a[j]) {
			sc = false;
		}
		else if (temp < a[j]) {
			temp = a[j] - 1;
		}
		else {
			temp = a[j];
		}
	}
	cout << ((sc) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1024
def main():
  K, A, B = map(int, input().split())

  if ((B-A) <= 2):
    print(str(K+1))
    return
  
  if (K < (A - 1 + 2)):
    print(str(K+1))
    return
  
  r = K - (A - 1)
  a = r // 2
  b = r % 2

  print(a*(B-A) + A + b)

main()



Measured memory_bytes: 3060
import numpy as np

n, m, c = map(int, input().split())

b_list = np.array(list(map(int, input().split())))

counter = 0

for _ in range(n):
  a_list = np.array(list(map(int, input().split())))
  if np.dot(a_list, b_list) + c > 0: counter += 1 
    
print(counter)

Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin>>N;
    vector<int> t(N+1), x(N+1), y(N+1);
    for(int i=0; i<N; i++) cin>>t[i+1]>>x[i+1]>>y[i+1];

    bool can=true;
    for(int i=0; i<N; i++) {
        int elapse=t[i+1]-t[i];
        int x_dist=abs(x[i+1]-x[i]);
        int y_dist=abs(y[i+1]-y[i]);
        int dist=x_dist+y_dist;

        if(elapse<dist) can=false; 
        if(t[i]%2!=(x[i]+y[i])%2) can=false;
    }
    
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n;
  cin>>n;
  set<string> st;
  rep(i,n){
    string s;
    cin>>s;
    st.insert(s);
  }
  cout<<st.size()<<endl;
}


Measured memory_bytes: 19080
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

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

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

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

int cnt[10][10];
void solve() {
	int n; cin >> n;
	ll ans = 0;
	rep1(i, n) {
		string s = to_string(i);
		int goa = s.back() - '0';
		int sta = s[0] - '0';
		cnt[sta][goa]++;
	}
	rep1(i, n) {
		string s = to_string(i);
		int sta = s.back() - '0';
		int goa = s[0] - '0';
		if (sta == 0)continue;
		ans += cnt[sta][goa];
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 256
import heapq
def main():
    K,T = map(int,input().split())
    A = [-int(x) for x in input().split()]
    if T == 1:
        print(K-1)
        exit()

    heapq.heapify(A)
    first = heapq.heappop(A)
    while 1:
        second = heapq.heappop(A)
        if second==0:
            break
        else:
            heapq.heappush(A,first+1)
            first = second
    print(-first-1)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 43484
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

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

	if(n==m) cout<<"Yes";
	else cout <<"No";
	return(0);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int dp[45];
	dp[0]=1;
	dp[1]=1;
	for(int i=2; i<45; i++){
		dp[i]=dp[i-1]+dp[i-2];
	}
	int n;
	cin>>n;
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = std::numeric_limits<T>::max() / 10;
std::mt19937 mt{std::random_device{}()};
int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<std::vector<int>> t(N);
    std::vector<int> P(M), Y(M);
    for (int i = 0; i < M; i++) { std::cin >> P[i] >> Y[i], P[i]--, t[P[i]].push_back(Y[i]); }
    for (int i = 0; i < N; i++) { std::sort(t[i].begin(), t[i].end()); }
    for (int i = 0; i < M; i++) {
        const int ord = std::lower_bound(t[P[i]].begin(), t[P[i]].end(), Y[i]) - t[P[i]].begin() + 1;
        std::string p = std::to_string(P[i] + 1), o = std::to_string(ord);
        for (int i = 0; i < 6 - p.size(); i++) { std::cout << 0; }
        std::cout << p;
        for (int i = 0; i < 6 - o.size(); i++) { std::cout << 0; }
        std::cout << o << std::endl;
    }
    return 0;
}


Measured memory_bytes: 7808
//package compilers;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner in=new Scanner(System.in);
	String s=in.next();
	String t=in.next();
	 int dp[][]=new int[s.length()+1][t.length()+1];
	 for(int i=0;i<=s.length();i++) {
		 for(int j=0;j<=t.length();j++) {
			 if(i==0 || j==0)
				 dp[i][j]=0;
			 else if(s.charAt(i-1)==t.charAt(j-1))
				 dp[i][j]=dp[i-1][j-1]+1;
			 else 
				 dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
			 
		 }
	 }
	 int i=s.length();
	 int j=t.length();
	 String ans="";
	 while(i>0 && j>0) {
		 if(s.charAt(i-1)==t.charAt(j-1)) {
			 ans+=s.charAt(i-1);
			 i--;
			 j--;
		 }
		 else if(dp[i-1][j]>dp[i][j-1])
			     i--;
		 else j--;
		 
	 }
	for(int k=ans.length()-1;k>=0;k--)
		System.out.print(ans.charAt(k));
}
}


Measured memory_bytes: 98248
using System;
using System.Linq;
using System.Collections.Generic;

namespace Competition
{
    class Program
    {
        static int[] dx = { 1, 0, -1, 0 };
        static int[] dy = { 0, 1, 0, -1 };
        static int H, W;
        static int sx, sy, gx, gy;
        static string[] field = new string[55];
        static long[,] d = new long[55, 55];

        public static long bfs()
        {
            Queue<Tuple<int, int>> que = new Queue<Tuple<int, int>>();
            sx = sy = 0;
            gx = W-1; gy = H-1;

            for(int i = 0; i < H; i++)
            {
                for(int j = 0; j < W; j++)
                {
                    d[i, j] = 1 << 29;
                }
            }
            que.Enqueue(new Tuple<int, int>(sy, sx));
            d[sy, sx] = 1;

            while (que.Count() > 0)
            {
                var p = que.Dequeue();
                if (p.Item1 == gy && p.Item2 == gx) break;
                for(int i = 0; i < 4; i++)
                {
                    var ny = p.Item1 + dy[i];
                    var nx = p.Item2 + dx[i];

                    if (nx >= 0 && nx < W && ny >= 0 && ny < H && field[ny][nx] != '#' && d[ny,nx] == 1 << 29)
                    {
                        que.Enqueue(new Tuple<int, int>(ny,nx));
                        d[ny,nx] = d[p.Item1, p.Item2] + 1;
                    }
                }
            }
            return d[gy,gx];
        }

        static void Main(string[] args)
        {
            var hw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            H = hw[0]; W = hw[1];

            for(int i = 0; i < H; i++)
            {
                field[i] = Console.ReadLine();
            }
            var path = bfs();
            var black = 0;
            for(int i = 0; i < H; i++)
            {
                for(int j = 0; j < W; j++)
                {
                    if (field[i][j] == '#') black++;
                }
            }
            if (path == 1 << 29) Console.WriteLine(-1);
            else Console.WriteLine(H*W - black - path);

        }
    }
}


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

int main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); ++i) {
        if (i != A) {
            if (S[i] < '0' || S[i] > '9') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

    return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll C, K, T[int(1e5+5)];

int main(){
  cin >> N >> C >> K;
  for (int i = 0; i < N; i++) cin >> T[i];
  sort(T, T + N);

  int ans = 0, cnt = 0;
  ll next = 0;

  for (int i = 0; i < N; i++){
    if (cnt == 0){
      next = T[i] + K; cnt++;
    }else if (next >= T[i]){
      cnt++;
    }else{
      ans++; cnt = 1; next = T[i] + K;
    }
    if (cnt == C) ans++, cnt = 0;
  }
  if (cnt > 0) ans++;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4328
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int num[N];
bool tc[N];
int main(){
	int n,m,x,y,ans=0;
	scanf("%d%d",&n,&m);
	tc[1]=true;
	for(int i=1;i<=n;i++) num[i]=1;
	for(int i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		if(tc[x]){
			tc[y]=true;
		}
		num[x]--;
		num[y]++;
		if(num[x]==0) tc[x]=false;
	}
	for(int i=1;i<=n;i++) if(tc[i]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

bool checkAbleThreeDivision(int x){
  if(x%3==0){
    return true;
  } else {
    return false;
  }
}

bool checkIncludeThree(int x){
  int work = x;
  while(true){
    if(work%10 == 3) return true;
    work /= 10;
    if(!work) break;
  }
  return false;
}

int main(){
  int n;
  scanf("%d",&n);

  for(int i=1;i<n+1;i++){
    if(checkAbleThreeDivision(i) || checkIncludeThree(i))
      printf(" %d",i);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2736
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    char a[3];
    int n;
    scanf("%s",a);
    if(a[0] == '1')
    {n = n + 1;}
    if(a[1] == '1')
    {n = n + 1;}
    if(a[2] == '1')
    {n = n + 1;}
        cout << n << endl;
}

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

int main() {
    ll A;
    cin >> A;

    double B;
    cin >> B;

    ll B100;
    B100 = (ll) round(B * 100);

    ll ans = (A * B100) / 100;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<int> a(M),b(M);
    for(int i = 0; i < M; i++) cin >> a[i] >> b[i];
    map<int,int> mp;
    for(int i = 0; i < M; i++){
        mp[a[i]]++;
        mp[b[i]]++;
    }
    for(int i = 1; i <= N; i++){
        cout << mp[i] << endl;
    }
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from itertools import accumulate


def main():
    input = stdin.buffer.readline
    MAX = 10 ** 5
    q = int(input())
    lr = [list(map(int, input().split())) for _ in range(q)]

    dp = [1] * (MAX + 1)
    dp[0] = dp[1] = 0
    for i in range(2, MAX + 1):
        if dp[i]:
            x = 2
            while i * x < MAX + 1:
                dp[i * x] = 0
                x += 1
    for i in reversed(range(2, MAX + 1)):
        if not dp[(i + 1) // 2]:
            dp[i] = 0

    summary = list(accumulate(dp))

    for l, r in lr:
        print(summary[r] - summary[l - 1])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 62556
n=int(input())
s=input()
l='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans=''
for i in s:
  for j in range(26):
    if i==l[j]:
      ans+=str(l[j+n])
print(ans)





Measured memory_bytes: 42604
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0505>
?????????============================================================
??????????????§??????????????????????¨?????????????.?????????????????¢?????±????????????????????£???.
????????? 1 ?????? n ?????§????????????????????????,??????????£??????´?????? 1 ?????? m ?????§???????????§??¨???,
??????????????´?????? ???,????????????????????´?????????????°??????????????????????????????.
????????¨???, ??????????????´???????????°???????????????,??´???????????????????????????????????°?????????????????????.
?????°???????????¨??????,??´?????????????????¨??????.
??\???????????? ??? 1 ???????????????????????° n ??¨??????????£??????´????????° m ???????????§????????????, i + 1 ??????
?????? i ?????¢?????±??????????????? ??? ??? 1 ??§????? 0 ??§??¨???,????????§??????????????? m ????????°??????????????§??????.
1 ??? n ??? 1000, 1 ??? m ??? 100 ??¨??????.
=================================================================

??\???=============================================================
??\???????????°????????????????????????????????????n, m ?????¨?????? 0 ?????¨?????\?????????????????????
???????????????????????°??? 5 ????¶?????????????
================================================================
??????=============================================================
???????????????????????¨????????´???????????? ???????????????????????????
================================================================

?§£??¬=============================================================
?????????????£?
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n, m;
	while (cin >> n >> m, n | m) {
		vector<pair<ll, ll>> vp(m);
		for (int i = 0; i < m;i++) vp[i] = { 0,-i};
		for (int i = 0; i < n;i++) {
			for (int j = 0; j < m;j++) {
				ll x; cin >> x;
				if (x == 1) {
					vp[j].first++;
				}
			}
		}
		sort(vp.begin(), vp.end());
		reverse(vp.begin(), vp.end());
		for (int i = 0; i < m;i++) {
			if (i != 0) cout << " ";
			cout << -vp[i].second + 1;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL p[100005], q[100005];

int main() {
    LL w, h;
    cin >> w >> h;
    for (int i = 0; i < w; i++) {
        cin >> p[i];
    }
    p[w] = 999999999;
    sort(p, p + w);
    for (int i = 0; i < h; i++) {
        cin >> q[i];
    }
    q[h] = 999999999;
    sort(q, q + h);
    LL pi = 0, qi = 0;
    LL wc = 0, hc = 0;
    LL need = w * h + w + h;
    // printf("need %lld\n", need);
    LL ans = 0;
    while (true) {
        if (p[pi] < q[qi]) {
            LL num = h - hc + 1;
            // printf("use %d, %d\n", p[pi], num);
            if (num >= need) {
                ans += p[pi] * need;
                break;
            } else {
                ans += p[pi] * num;
                need -= num;
            }
            wc++;
            pi++;
        } else {
            LL num = w - wc + 1;
            // printf("use %d, %d\n", q[qi], num);
            if (num >= need) {
                ans += q[qi] * need;
                break;
            } else {
                ans += q[qi] * num;
                need -= num;
            }
            hc++;
            qi++;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 5280
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<60)
#define EPS (1e-10)
typedef __int128 Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

long long  n, X;
long long res = INF;
long long sum[216000];
Int solve(Int robot){
  Int res = (robot + n) * X;
  Int cnt = 1;
  for(Int i = n-1;i >= 0;i-=robot){
    Int r = i;
    Int l = max(0, r - robot + 1);
    Int tmp= sum[r];
    if(l)tmp -= sum[l-1];
    res += tmp * (max(cnt, 2) * 2 + 1);
    cnt++;
  }
  return res;
}

int main(){
  cin >> n >> X;
  for(Int i = 0;i < n;i++){
    cin >> sum[i];
    if(i)sum[i] += sum[i-1];
  }
  for(Int i = 1;i <= n;i++){
    //    cout << i << " " << solve(i) << endl;
    res = min(res, solve(i));
  }
  cout << res << endl;
  return 0;
}

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

long calc(long s, long t, long x){
  return min(abs(x-s)+abs(s-t), abs(x-t)+abs(t-s));
}

int main(){
  int a, b, q;
  cin >> a >> b >> q;
  vector<long>s(a+2), t(b+2);
  s[0]=t[0]=-100000000000L;
  s[a+1]=t[b+1]=10000000000000L;
  long x;
  for(int i=1; i<=a; i++)cin >> s[i];
  for(int i=1; i<=b; i++)cin >> t[i];
  for(int i=0; i<q; i++){
    cin >> x;
    decltype(s)::iterator slit = lower_bound(s.begin(), s.end(), x);
    decltype(t)::iterator tlit = lower_bound(t.begin(), t.end(), x);
    long ret=1000000000000L;
    ret=min(ret, calc(*(slit-1), *(tlit-1), x));
    ret=min(ret, calc(*(slit-1), *(tlit), x));
    ret=min(ret, calc(*(slit), *(tlit-1), x));
    ret=min(ret, calc(*(slit), *(tlit), x));
    cout << ret << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

using namespace std;

int ans[10];

void solve(vector<int> a,int n)
{
	int count = 0;
	rep(i,a.size()) count += a[i];

	if(count == 0)
	{
		ans[n] = 1;
		return;
	}

	REP(i,1,10)
	{
		if(a[i] >= 3)
		{
			a[i] -= 3;
			solve(a,n);
			a[i] += 3;
		}
	}

	REP(i,3,10)
	{
		if(a[i-2] && a[i-1] && a[i])
		{
			a[i-2]--; a[i-1]--; a[i]--;
			solve(a,n);
			a[i-2]++; a[i-1]++; a[i]++;
		}
	}
}


int main()
{
	string s;
	while(cin >> s)
	{
		vector<int> a;
		memset(ans,0,sizeof(ans));

		rep(i,10) a.pb(0);
		rep(i,s.size()) a[s[i] - '0']++;

		REP(i,1,10)
		{
			if(a[i] == 4)
			{
				continue;
			}
			else
			{
				a[i]++;
				REP(j,1,10)
				{
					if(a[j] >= 2)
					{
						a[j] -= 2;
						solve(a,i);
						a[j] += 2;
					}
				}
				a[i]--;
			}
		}

		bool count_0 = true;
		int ans_max = 0;
		REP(i,1,10)
		{
			if(ans[i])
			{
				count_0 = false;
				ans_max = max(ans_max,i);
			}
		}

		if(count_0) 
		{
			cout << 0 << endl;
		}
		else
		{
			bool flag = true;
			REP(i,1,10)
			{
				if(ans[i] == 1)
				{
					if(i == ans_max)
					{
						cout << i << endl;
					}
					else
					{
						cout << i << " ";
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1204
# coding: utf-8
# Your code here!
odd={0:1}
even={0:1,1:3}
M=10**9+7
def memo(N):
    if N ==0:
        return 1
    if N==1:
        return 2
    return (memoodd((N-1)//2)+memoeven(N//2))%M

def memoodd(N):
    if N in odd:
        return odd[N]
    odd[N] = memo(N)
    return odd[N]

def memoeven(N):
    if N in even:
        return even[N]
    even[N] = (memo(N)+memo(N-1))%M
    return even[N]

n=int(input())
print(memo(n))


Measured memory_bytes: 3064