akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int n;int w[110];cin>>n;rep(i,n)cin>>w[i+1];w[0] = 0;
  int sum = 0;
  repd(i,1,n+1){
    sum += w[i];w[i] += w[i-1];
  }
  int ans = INF;
  repd(i,1,n+1){
    int s1 = w[i];int s2 = sum-w[i];
    ans = min(ans, abs(s1-s2));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,y;
    cin >> n >> y;
    int man=-1,go=-1,sen=-1;
    for(int a=0;a<=n;a++){
        for(int b=0;b+a<=n;b++){
            int z=n-a-b;
            if(10000*a+5000*b+1000*z==y){
                man=a;
                go=b;
                sen=z;
                break;    
            }
        }
    }
    cout << man << ' ' << go << ' ' << sen << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int64_t ans = 0;
  int64_t k = 0;
  string s;
  cin >> s;
  int n=s.size();
  vector<int> A(n);
  
  for (int i = 0; i < n; i++) {
    A[i]=int(s.at(i))-int('0');
    //cout<<A[i]<<endl;
  }
  if(s.size()==1)ans=A[0];
  
 
  
 
 
  for (int tmp = 0; tmp < (1 << (n-1)); tmp++) {
       k=A[0];
      
    bitset<11> fugo(tmp); 
   
 
    // ビット列の1のビットに対応する所に+
   
    for (int i = 0; i < n-1; i++) {
        //cout<<i<<" "<<k<<" "<<ans<<endl;
      if(fugo.test(i)&&i==n-2){
          ans+=k+A[i+1];
      }else if(!(fugo.test(i))&&i==n-2){
          ans+=10*k+A[i+1];
      }
      else if (fugo.test(i)) {
        ans+=k;
        k=A[i+1];
      }else{
          k=10*k+A[i+1];
      }
      //cout<<i<<" "<<k<<" "<<ans<<endl;
    }
    
    }
  
 
    cout<<ans<<endl;
}

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

using namespace std;

const int MAXN = 2e3 + 10;
const int MOD = 1e9 + 7;

// sadkalsdglasdlkas
// asdogfsaldjkgljasdljasdf
// asdfjasljdgfjalsgdjklasdg
// asdkgfasljgflajsdgflasdf4
// alirhgalsidglasdg

int n, dp[2 * MAXN][2 * MAXN], go[2 * MAXN][2 * MAXN];
int fac[4 * MAXN];

long long po(long long v, long long u)
{
	return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1;
}

int ente(int i, int j) {
	return (((fac[j] * po(fac[i], MOD - 2)) % MOD) * po(fac[j - i], MOD - 2)) % MOD;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	fac[0] = 1;
	for (int i = 1; i < 4 * MAXN; i++)
		fac[i] = (1ll * fac[i - 1] * i) % MOD;
	cin >> n;
	long long res = 0;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		dp[MAXN - a][MAXN - b]++;
		go[MAXN + a][MAXN + b]++;
		res = (res - ente(2 * a , 2 * (a + b)) + MOD) % MOD;
	}
	for (int i = 1; i < 2 * MAXN; i++)
	{
		for (int j = 1; j < 2 * MAXN; j++)
		{
			dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= MOD;
			res += 1ll * go[i][j] * dp[i][j];
			res %= MOD;
		}
	}
	cout << (res * (MOD / 2 + 1)) % MOD << endl;
	return 0;
}

Measured memory_bytes: 95872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> C(N);
  int A = 0;
  int B = 0;
  int z,count;
  
  for(int i = 0; i < N; i++){
    cin >> C.at(i);
  }
  
  for(int i = 0; i < N; i++){
    z = 0;
    count = 0;
    for(int j = 0; j < N; j++){
      if(z < C.at(j)){
        z = C.at(j);
        count = j;
      }
    }
    
    C.at(count) = 0;
    if(i % 2 == 0){
     A = A + z;
    }else{
     B = B + z;
    }

    }

   cout << A - B << endl;
  
}


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

/*
10
3
11

4
2
5
*/

const int MAX_N = 1e6 + 10;
int N = 0;

bool is_prime[MAX_N + 1];
void sieve(int n) {
    fill(is_prime, is_prime + n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
}

void solve() {
    int res = 0;
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            res++;
        }
    }

    printf("%d\n", res);
}

int main() {
    sieve(MAX_N);
    while (scanf("%d", &N) != EOF) {
        solve();
    }

    return 0;
}



Measured memory_bytes: 4176
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int H, W, A, B; cin >> H >> W >> A >> B;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      cout << (i<=B xor j<=A);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include <stdio.h>
int main(void)
  
{
  int i,N,M,X;
  scanf("%d %d %d",&N,&M,&X);
  
  int a[M];
  
  for(i=0;i<M;i++)
  {  
    scanf ("%d",&a[i]);
  }
  
    int s,t,min;
		s=0;
		t=0;
  
  for (i=0;i<M;i++)
  {
    if(a[i]>X)
      break;
    s=++s;
  }
  
  for (i=M-1;i>=0;i--)
  {
    if(a[i]<X)
      break;
    t=++t;
  }
    
  if (s>=t)
      min=t;
    
  else 
    min=s;
  
  printf("%d",min);
 
}


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

N, Y = map(int, input().split())
result_10000, result_5000, result_1000 = -1, -1, -1
found = False

# 効率を考えて、1万円札 → 5000円札 → 1000円札の順で求める
# 1万円札の数をY//10000から一つずつ減らして調べていく
for num_10000 in reversed(range(0, Y//10000 + 1)):
    y_10000 = Y - 10000 * num_10000
    n_10000 = N - num_10000
    if y_10000 == 0 and n_10000 == 0:
        result_10000, result_5000, result_1000 = num_10000, 0, 0
        found = True
        break
    else:
        for num_5000 in reversed(range(0, y_10000//5000 + 1)):
            y_5000 = y_10000 - 5000 * num_5000
            n_5000 = n_10000 - num_5000
            if y_5000 < 0 or n_5000 < 0:
                break
            if y_5000 == 0 and n_5000 == 0 and num_10000 + num_5000 == N:
                result_10000, result_5000, result_1000 = num_10000, num_5000, 0
                found = True
                break
            else:
                # 10000円札と5000円札の枚数が決まれば必然的に1000円札の枚数は決まる
                num_1000 = y_5000 // 1000
                y_1000 = y_5000 - 1000 * num_1000
                n_1000 = n_5000 - num_1000
                if y_1000 == 0 and n_1000 == 0 and num_10000 + num_5000 + num_1000 == N:
                    result_10000, result_5000, result_1000 = num_10000, num_5000, num_1000
                    found = True
                    break
            if found:
                break
        if found:
            break
    
print(result_10000, result_5000, result_1000)



Measured memory_bytes: 3188
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 33;

int n, m, k, x, tot, A[MAXN];

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &k);

        for (int j = 0; j < k; j++) {
            scanf("%d", &x);
            A[x]++;
        }
    }

    for (int i = 1; i <= m; i++) {
        if (A[i] == n) {
            tot++;
        }
    }

    printf("%d\n", tot);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int x,y,cnt[200001],fnt[200002];
vector<int>vec[200001];
bitset<200001>vis;
void dfs(int a){
    static int ans=1;
    vis[a]=true;
    cnt[a]=ans;
    ans++;
    for(int i=0;i<vec[a].size();i++){
        if(!vis[vec[a][i]]){
            dfs(vec[a][i]);
        }
    }
    fnt[a]=ans;
}
class FT{
private:
    vector<ll>ft;
public:
    FT(int n){
        ft.assign(n+1,0);
    }
    ll sum(int a){
        ll ans=0;
        for(;a;a-=(a&-a))
            ans+=ft[a];
        return ans;
    }
    ll rsq(int a,int b){
        ll x=sum(b)-sum(a-1);
        return x;
    }
    void update(int a,int b){
        for(;a<(int)ft.size();a+=(a&-a))
            ft[a]+=b;
    }
};
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>x>>y;
    for(int i=0;i<x-1;i++){
        int a,b;
        cin>>a>>b;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    dfs(1);
    FT bit(x+1);
    for(int i=1;i<=x;i++){
        bit.update(cnt[i],0);
    }
    for(int i=0;i<y;i++){
        int a,b;
        cin>>a>>b;
        bit.update(cnt[a],b);
        bit.update(fnt[a],-b);
    }
    for(int i=1;i<=x;i++)
        cout<<bit.sum(cnt[i])<<' ';
}


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


using namespace std;


int main(void){
  
  int A,B,C;
  string ans;
  
  cin >> A >> B >> C;

  if(A == B && B == C ){
    ans = "No";
  }else if(A != B && B == C ){
    ans = "Yes";
  }else if(A == B && B != C ){
    ans = "Yes";
  }else if(A == C && B != C ){
    ans = "Yes";
  }else {
    ans = "No";
  }

  cout << ans << endl;
  

  return 0;
}



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

using namespace std;

int main()
{
    int n,i,ans=0,count=0,j,in[100],m,low2,low1,k,l;

    cin >> n ;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            for(k=1; k<=n; k++)
            {
                low1 = min(i,j);
                low2 = min(low1,k);
                for(l=low2;l>0;l--)
                {
                    if(i%l == 0 && j%l == 0 && k%l == 0 )
                    {
                        ans = ans + l;
                        break;
                    }
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

class UnionFindTree {
private:
    vector<int> parent;
public:
    UnionFindTree(int n) : parent(n) {
        // 最初は全てを根として初期化
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int get_root(const int x) {
        // データxが属する木の根を取得する
        if (parent[x] == x) return x;
        // 取得したものは直接木の根をつなぐ(経路圧縮)
        return parent[x] = get_root(parent[x]);
    }

    void unite(const int x, const int y) {
        // xとyの木を併合する
        int rx = get_root(x);
        int ry = get_root(y);
        // 元から同じ木に属している場合は何もしない
        if (rx == ry) return;
        // xの属する木をyの属する木につける
        parent[rx] = ry;
    }

    bool is_same_root(const int x, const int y) {
        return get_root(x) == get_root(y);
    }

    void print() {
        for (auto i = 0; i < (int)parent.size(); i++) {
            cout << parent[i] << " ";
        }
        cout << endl;
    }
};

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

    UnionFindTree tree(n);

    vector<int> p(n);
    for (auto i = 0; i < n; i++) cin >> p[i];

    for (auto i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        tree.unite(--x, --y);
    }

    uint64_t ans = 0;
    for (auto i = 0; i < n; i++) {
        if(tree.is_same_root(--p[i], i)) ans++;
    }

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

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

int main(){
  int a,b;
  char op;
  while(1){
    cin >> a;
    cin >> op;
    cin >> b;
    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;
    }else if(op == '?'){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3120
#!/usr/bin/env python3

N = int(input())
A = list(map(int, input().split()))

P = 1000
k = 0
for i in range(1, N):
    if A[i-1] < A[i]:
        k = P // A[i-1]
        P -= k*A[i-1]
        P += k*A[i]

print(P)


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

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  for(int i = 1; i < n; i++){
    if(s[i-1] == s[i]){
      cout << i << " " << i+1 << endl;
      return 0;
    }
    if(i >= 2)
      if(s[i-2] == s[i]){
        cout << i-1 << " " << i+1 << endl;
        return 0;
      }
  }
  cout << "-1 -1" << endl;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    int takahashi = 0;
    int aoki = 0;
    while (A>0) {
        A-=D;
        takahashi++;
    }
    while (C>0) {
        C-=B;
        aoki++;
    }

    if (takahashi>=aoki) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
 
int main()
{
    int D,N;
    cin >> D >> N;
    int init = pow(100, D);
    if(D==0 && N == 100)
    {
        cout << "101" << endl;
    } 
    else if(D==1 && N == 100)
    {
        cout << "10100" << endl;
    }
    else if(D==2 && N == 100)
    {
        cout << "1010000" << endl;
    }
    else cout << init * N << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func run() {
	a := nextInt()
	b := nextInt()
	ans := -1000000
	if ans < a+b {
		ans = a + b
	}
	if ans < a*b {
		ans = a * b
	}
	if ans < a-b {
		ans = a - b
	}
	Println(ans)
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024

func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}

func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = nextInt()
	}
	return res
}

func nextFloats(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = nextFloat()
	}
	return res
}

func nextStrings(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = next()
	}
	return res
}

func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
ll dp[N][2],arr[N];
void solve()
{
	int n;
	cin >> n;

	for (int i = 1; i < n + 1; i++)
		cin >> arr[i];
	memset(dp, 0, sizeof(dp));
	dp[2][1] = arr[2];
	dp[2][0] = arr[1];
	for (int i = 3; i < n + 1; i++)
	{
		if (i & 1)
		{
			ll temp = max({dp[i-3][1],dp[i-3][0],dp[i-2][1],dp[i-2][0]});
			//位置i选择
			//i：x个
			//i-1 x个
			//i-2：x-1个
			//i-3：x-1个
			//i-4: x-2个
			dp[i][1] = arr[i] + temp;

			dp[i][0]=max({dp[i-1][1],dp[i-1][0],arr[i-2]+dp[i-3][0]});
			//arr[i-3]+dp[i-2][1] :不合法
			//该位置不选，从x继承dp[i-1]
			//i-1：x个
			//i-2：x-1个
			//i-3: x-1个
		}
		else
		{
			dp[i][1]=arr[i]+max({dp[i-2][1],dp[i-2][0],dp[i-1][0]});
			//选当前位置 x=i/2
			//i-1:x-1个
			//i-2:x-1个


			//位置i不选，从x位置转移 由于没有x位置
			//i-1:x-1个
			//i-2 x-1个
			//i-3：x-2个
			//结论：一定选i-1  维护前i个必须选i/2个的特性
			dp[i][0] = arr[i-1]+dp[i-2][0];
		}
	}
	cout << max(dp[n][1], dp[n][0]) << endl;
	return;
}

int main()
{
	solve();
	return 0;
}
/*
没有两个相邻的被选上
8
1 2 3 4 -1 -2 -3 -4
*/


Measured memory_bytes: 8312
#include<stdio.h>
int main(){
	int i,j,k,d[1000];
	long long n,_n,sum=0,ten=1;
	for(;scanf("%lld",&n)&&n+1;ten=1,sum=0){
		_n=n;
		for(j=0;_n!=0;j++){
			d[j]=_n%4;
			_n/=4;
		}
		for(k=0;k<j;k++){
			sum+=ten*(long long)d[k];
			ten*=10;
		}
		printf("%lld\n",sum);}return 0;}

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

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	int c = 0;
	ll tmp = k;
	while (tmp) {
		tmp /= 2;
		c++;
	}
	const int MAX = c;
	ll ans = 0;
	vector<int> cnt(MAX);
	rep(i, n) {
		rep(j, MAX) {
			if (a[i]>>j & 1) cnt[j]++; 
		}
	}
	ll d = 1;
	ll x = 0;
	rep(i, MAX) {
		if(cnt[i] <= n / 2) {
			x += d;
		}
		d *= 2;
	}
	if(x > k) {
		int now = MAX;
		for(int i = MAX; i >= 0; i--) {
			if(x <= k) break;
			if((x>>i & 1) && !(k>>i & 1)) x -= d;
			d /= 2; 
		}
	}
	rep(i, n) ans += a[i]^x;
	cout << ans << endl;
	// rep(i, MAX) cout << cnt[i] << " ";
	// cout << endl;
	return 0;
}

Measured memory_bytes: 1024
N,K=map(int,input().split())
S=str(input())
a=["a","b","c"]
A=["A","B","C"]
T=str()
for i in range(N):
    if i==K-1:
        T=T+a[A.index(S[i])]
    else:
        T=T+S[i]
print(T)

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

class Program
{
    public static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);
        int q = int.Parse(s[2]);

        int[] a = new int[q];
        int[] p = new int[n];

        for(int i = 0; i < q; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }
        for(int i = 0; i < n; i++)
        {
            p[i] = k;
            p[i] -= q;
        }

        for(int i = 0; i < q; i++)
        {
            p[a[i] - 1] += 1;
        }

        for(int i = 0; i < n; i++)
        {
            if (p[i] > 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

using namespace std;

#define N 60

int n,ans,a[N],b[N];
map<int,map<int,int> > mp;

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d%d",a+i,b+i);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j) if (i!=j) ans=max(ans,++mp[a[i]-a[j]][b[i]-b[j]]);
	printf("%d\n",n-ans);
	
	return 0;
}
			


Measured memory_bytes: 640
X,Y,A,B,C = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i).sort.reverse
q = gets.chomp.split.map(&:to_i).sort.reverse
r = gets.chomp.split.map(&:to_i).sort.reverse
array = []
array = array.push(p[0..X-1]).push(q[0..Y-1]).push(r[0..C-1]).flatten!.sort.reverse
puts array[0..X+Y-1].inject(:+)

Measured memory_bytes: 32904
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=0; cin>>n;
    rep(i,n) ans+=(i+1)*(n-i);
    rep(i,n-1){
        ll u,v; cin>>u>>v;
        if(u>v) swap(u,v);
        ans-=(n-v+1)*u;
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    string a,b;
    cin >> a >> b;
    cout << b << a;
    return 0;
}


Measured memory_bytes: 256
def search(s1, s2):
    len1 = len(s1)
    len2 = len(s2)
    for i in range(len1):
        if i + len2 > len1:
            break

        for j in range(len2):
            if s1[i+j] != s2[j]:
                break
        else:
            yield i


def run():
    s1 = input()
    s2 = input()
    for idx in search(s1, s2):
        print(idx)


if __name__ == '__main__':
    run()



Measured memory_bytes: 5576
n, x = map(int, input().split())
b = [1]#l番目がレベルlの厚さを要素にもつ配列
p = [1]#l番目がレベルlのバーガーに入っているパティの数

for i in range(n):
  b.append(2*b[i]+3)
  p.append(2*p[i]+1)

def dfs(f, x):
  if x == 1:
    if f == 0:
      return 1
    else:
      return 0
  elif x <= b[f]//2:return dfs(f-1, x-1)
  elif x ==  b[f]//2 + 1: return p[f]//2+1
  elif x < b[f]: return p[f]//2 + 1 + dfs(f-1, x-b[f]//2-1)
  else:return p[f]
    
print(dfs(n, x))
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;


int main() {
    string s;
    cin >> s;
    int n = s.size();
    int a, b;
    rep(i, n) {
        if (s[i] == 'A') {
            a = i;
            break;
        }
    }
        for (int i = n-1 ; i >= 0; i--) {
            if (s[i] == 'Z') {
                b = i;
                break;
            }
        }
        cout << b - a +1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 100005
#define LL long long
#define INF (1LL<<60)
using namespace std;
multiset<int> S;
int n,x,y,z; LL f[N],g[N],ans,res=-INF;
struct node{
	int a,b,c;
	node(int _a=0,int _b=0,int _c=0){ a=_a,b=_b,c=_c;}
}A[N];
bool cmp(node p,node q){ return p.b-p.c>q.b-q.c;}
int main()
{
	int i;
	scanf("%d %d %d",&x,&y,&z),n=x+y+z;
	for(i=1;i<=n;i++){
		scanf("%d %d %d",&A[i].a,&A[i].b,&A[i].c);
		ans+=A[i].a,A[i].b-=A[i].a,A[i].c-=A[i].a;
	  }
	sort(A+1,A+n+1,cmp);
	for(i=1;i<=n;i++){
		f[i]=f[i-1]+A[i].b;
		S.insert(A[i].b);
		if(S.size()>y)
			f[i]-=(*(S.begin())),S.erase(S.begin());
	  }
	S.clear();
	for(i=n;i>=1;i--){		
		g[i]=g[i+1]+A[i].c;
		S.insert(A[i].c);
		if(S.size()>z)
			g[i]-=(*(S.begin())),S.erase(S.begin());
	  }
	for(i=y;i<=n-z;i++)
		res=max(res,f[i]+g[i+1]);
	cout<<ans+res;
	return 0;
}


Measured memory_bytes: 7424
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示
		int N = sc.nextInt();
		int K = sc.nextInt();
		List<Integer> list = new ArrayList<>();

		
		for (int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);

		int ans = 0;
		for (int i = 0; i < K; ++i) {
			ans += list.get(i);
		}
		System.out.println(ans);
      
    }
}

Measured memory_bytes: 30304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++){
        cin >> vec.at(i);
    }

    //sort algorith
    for (int i = 0; i < N; i++){
        for(int j = 0; j < N-1; j++){
            if(vec.at(i) > vec.at(j)){
                int A = vec.at(i);
                int B = vec.at(j);
                vec.at(j) = A;
                vec.at(i) = B;
            }
        }
    }

    vector<int> kagami(1);
    for(int i = 0; i < N; i++){
        if(kagami.at(kagami.size()-1) != vec.at(i)){
            kagami.push_back(vec.at(i));
        }
    }
    
    kagami.erase(kagami.begin());
    cout << kagami.size() << endl;
    

}

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

long long gcd(long long a, long long b)
{
  if(a < b)
  {
    swap(a, b);
  }
  long long r;
  r = a % b;
  while(r != 0)
  {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main()
{
  long long n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  long long ch = 0;
  long long lc = n * m / gcd(n, m);
  long long i;
  for(i = 0; i < lc; i += lc / n)
  {
    if(i % (lc / n) == 0 && i % (lc / m) == 0)
    {
      if(s.at(i / (lc / n)) != t.at(i / (lc / m)))
      {
        ch = 1;
        break;
      }
    }
  }
  if(ch == 0)
  {
    cout << lc << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int a, b; cin >> a >> b;
	for(int i=1;i<=1300;i++){
		int c = i*0.08;
		int d = i*0.1;
		if(c==a && d==b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  int q;
  cin>>q;
  int t[q];
  for(int i=0;i<q;i++) cin>>t[i];
  int ans=0;
  int used[q];
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++){
    for(int j=0;j<q;j++){
      if(used[j]) continue;
      if(s[i]==t[j]){
	ans++;
	used[j]=1;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  long long n;
  long long m=1000,pre,post,kabu=0;
  cin >> n >> pre;
  for(int i = 0; i < n-1;i++){
    cin >> post;
    if(pre<post){
      kabu = m/pre;
      m += kabu *(post-pre);
    }
    pre = post;
  }
  cout << m << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset> //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip> //do setprecision
#include <ctime>
#include <complex>
using namespace std;

int main(void){
	int N,M,flag=-1,j=0,i,k,max=0; 
	string w;
 	struct data{
 		int count;
 		string word;
 	};
 	struct data s[200];
 	for (int i = 0; i < 200; ++i){
 		s[i].count=0;
 	}
 	scanf("%d",&N);
 	for (k = 0; k < N; ++k){
 		cin >> w;
 		flag = -1;
 		for (i = 0; i < 200; ++i){
 			if(s[i].word.compare(w)==0){
 			s[i].count++;
 			flag=i;
 			}
 		}
 		if(flag==-1){
 			s[j].word=w;
 			s[j].count++;
 			j++;
 		}
 	}
 	scanf("%d",&M);
 	for (k = 0; k < M; ++k){
 		cin >> w;
 		flag = -1;
 		for (i = 0; i < 200; ++i){
 			if(s[i].word.compare(w)==0){
 			s[i].count--;
 			flag=i;
 			}
 		}
 		if(flag==-1){
 			s[j].word=w;
 			s[j].count--;
 			j++;
 		}
 	}
 	for (int i = 0; i < j; ++i){
 		if(max < s[i].count){
 			max=s[i].count;
 		}
 	}
 	printf("%d\n",max);
 	/*for(i=0;i<j;i++){
 		cout << s[i].word << s[i].count << endl;
 	}*/
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        double x1, y1, x2, y2, x3, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

        double a1 = 2 * (x2 - x1), a2 = 2 * (x3 - x1),
               b1 = 2 * (y2 - y1), b2 = 2 * (y3 - y1),
               c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2,
               c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3,
               px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1),
               py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1),
               r = sqrt(pow(x1 - px, 2) + pow(y1 - py, 2));
        printf("%.3f %.3f %.3f\n", px, py, r);
    }
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define debug(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
#define endl "\n"
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> ii;

void err(istream_iterator<string> it){}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define maxn 100006

int n, h[maxn], k;
int dp[maxn];

int solve(){
  dp[0] = 0;
  for(int i=1;i<n;i++){
    dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
    for(int j=1;j<=k;j++){
        if(i-j>=0){
          dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    }      
  }
  return dp[n-1];
}


int solve(int i){
  if(i==n-1)
    return dp[n-1] = 0;
  if(dp[i+1]==-1){
    solve(i+1);
    dp[i] = dp[i+1] + abs(h[i]-h[i+1]);
  }
  if(i+2<=n-1 && dp[i+2]==-1){
    
    dp[i] = min(dp[i],dp[i+2]+abs(h[i]-h[i+2]));
  }
  return dp[i];
}

int main(){
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> h[i];
    dp[i] = -1;
  }
  cout << solve() << '\n';
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
} //三項演算子を使ったgcd(最大公約数)

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

    int K;
    cin >> K;
    ll ans = 0;
    for (int i = 1; i < K + 1; i++)
    {
        for (int j = 1; j < K + 1; j++)
        {
            for (int k = 1; k < K + 1; k++)
            {
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }

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


Measured memory_bytes: 3640
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
	int n,num=1,cnt=0;cin>>n;
	vi v(n);
	bool flag=0;
	loop(n,i,0)cin>>v[i];
	loop(n,i,0){
		if(v[i]==1)flag=1;
		if(v[i]!=num)cnt++;
		else num++;
	}
	if(flag)cout<<cnt<<endl;
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    map<string, long long> ma;
    int N; cin >> N;
    for (int i = 0; i < N; ++i) {
        string str; cin >> str;
        sort(str.begin(), str.end());
        ma[str]++;
    }
    long long res = 0;
    for (auto it : ma) res += it.second * (it.second - 1) / 2;
    cout << res << endl;
}


Measured memory_bytes: 11136
n,k = map(int,input().split())
dp = [0]*(k+1)
last = max(n,k)

for i in range(1,last+1):
  if i <= n and i <= k:
    dp[i] += 1 / n
  elif k < i:
    dp[k] += 1 / n
  if i*2 < k:
    dp[i*2] += dp[i] / 2
  elif i < k:
    dp[k] += dp[i] / 2
print(dp[k])

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

using namespace std;

int main() {

	// your code goes here
  long long modulo = 1000000007;

	long long h, w;

	cin >> h >> w;

	char grid[h][w];

	long long dp[h][w];

	for(long long i=0; i<h; i++) {

		for(long long j=0; j<w; j++) {

			cin >> grid[i][j];

			dp[i][j] = 0;

		}

	}

	for(long long i=0; i<h && grid[i][0]=='.'; i++) {

		dp[i][0] = 1;

	}

	for(long long i=0; i<w && grid[0][i]=='.'; i++) {

		dp[0][i] = 1;

	}

	for(long long i=1; i<h; i++) {

		for(long long j=1; j<w; j++) {

			if(grid[i][j] == '.') {

				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%modulo;

			}

		}

	}

	cout << dp[h-1][w-1] << endl;

	return 0;

}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define pb push_back
#define li long int

using namespace std;

li h,w;
vector < vector < char > > arr;

void FAST()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

li calc()
{
	li mod=1000000007;
	li i,j;
	li dp[h][w];
	memset(dp,0,sizeof(dp));
	for(i=0;i<h;i++)
	{
		if(arr[i][0]=='#')	break;
		else	dp[i][0]=1;
	}	
	for(i=0;i<w;i++)
	{
		if(arr[0][i]=='#')	break;
		else	dp[0][i]=1;
	}
	
	for(i=1;i<h;i++)
	{
		for(j=1;j<w;j++)
		{
			if(arr[i][j]=='#')	continue;
			else
				dp[i][j]=((dp[i-1][j])%mod+(dp[i][j-1])%mod)%mod;
		}
	}
	
	
	return ((dp[h-1][w-1])%mod);
}

int main()
{
    FAST();
    cin>>h>>w;
    arr=vector < vector < char > > (h);
    for(li i=0;i<h;i++)
    {
    	string ss;cin>>ss;	
    	for(li j=0;j<w;j++)	arr[i].pb(ss[j]);
    }
    cout<<calc();	
}

Measured memory_bytes: 12400
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T> inline bool chmax(T& a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int N, K;
  cin >> N >> K;
  vector<double> ps(N + 1, 0);
  vector<double> ts(N + 1, 0);
  for(int i = 1; i <= N; ++i) {
    cin >> ps[i];
    ts[i] = ts[i - 1] + (ps[i] + 1) / 2.0;
  }
  double ans = 0.0;
  for(int i = K; i <= N; ++i) {
    chmax(ans, ts[i] - ts[i - K]);
  }
  cout << fixed << setprecision(8) << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

int n,s;
int saiki(int n1,int u,int m){
    if(n1 > s) return 0;
    else if(m==1){
	int d = s-n1;
	if(d <= 9 && (u & (1<<d))==0) return 1;
	else return 0;
    }else if(m==2){
	if(s-n1>26) return 0;
    }else if(m==3){
	if(s-n1>50) return 0;
    }else if(m==4){
	if(s-n1>80) return 0;
    }else if(m==5){
	if(s-n1>115) return 0;
    }else if(m==6){
	if(s-n1>154) return 0;
    }

    int ans;
    for(int i=9;i>=0;i--){
	if((u & (1<<i))==0){
	    ans += saiki(n1+m*i,u|(1<<i),m-1);
	}
    }
    return ans;
}

void main(){
    while(true){
	auto ss = readln();
	if(stdin.eof()) break;
	int[] s1 = ss.split().to!(int[]);
	n = s1[0];
	s = s1[1];
	if(n <= 330)
	    writeln(saiki(0,0,n));
	else writeln(0);
    }
}

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

int roundup(int i) {
    return (i + 9) / 10 * 10;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector<int> tms(5);
    int s = 0;
    for (int i = 0; i < 5; i++) {
        cin >> tms[i];
        if (roundup(tms[i]) - tms[i] > roundup(tms[s]) - tms[s]) {
            s = i;
        }
    }
    int sum = 0;
    for (int i =0 ; i < 5; i++) {
        if (i != s) {
            tms[i] = roundup(tms[i]);
        }
        sum += tms[i];
    }
    cout << sum;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


// double c(double x)
// {
//   double X = x;
//   X = int(X) % 10;
//   return X;
// }

ll gcd(ll a,ll b)
{
  ll x = a*b;
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  ll r;
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

int main()
{
  ll a,b;
  cin >> a >> b;
  cout << gcd(a,b) << endl;
}



Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N, Q = sc.nextInt
    val X = Array.tabulate[Int](N)(i => i)
    var Y = Set[Int](0, 1)
    var position1 = 0
    for (idx <- 0 until Q) {
      val A, B = sc.nextInt - 1
      if (A == position1) {
        position1 = B
      } else if (B == position1) {
        position1 = A
      }

      val Z = X(A)
      X(A) = X(B)
      X(B) = Z

      if (position1 != 0) Y += X(position1 - 1)
      if (position1 != N - 1) Y += X(position1 + 1)
    }
    println(Y.size)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 72356
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
const int maxn = 110;
char s[maxn][maxn];
int mp[maxn],cnt1,cnt2;
int main(){
    scanf("%d%d",&n,&m);
    for(int i = 0 ; i < n ; i++){
        scanf("%s",s[i]);
        for(int j = 0 ;  j < m ; j++){
            mp[s[i][j]-'a']++;
        }
    }
    for(int i = 0 ; i < 26 ; i++){
        if(mp[i] == 0)  continue;
        if(mp[i] % 4 == 3){
			cnt1++;
			cnt2++;
        }
        if(mp[i] % 4 == 1)  cnt1++;
        if(mp[i] % 4 == 2)  cnt2++;
    }
    if(n%2 == 1 && m%2 == 1){
        if(cnt1 > 1 || (cnt2 > (n-1)/2+(m-1)/2) ){
            printf("No\n");
            return 0;
        }
    }
    else if(n%2 == 0 && m%2 == 0){
        if(cnt1 || cnt2){
			printf("No\n");
            return 0;
        }
    }
    else if(n %2 == 0 && m%2 == 1){
        if(cnt1 || cnt2 > n/2){
			printf("No\n");
            return 0;
        }
    }
    else{
		if(cnt1 || cnt2 > m/2){
			printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
}

Measured memory_bytes: 256
mod = 10**9+7
N,K = map(int,input().split())
ans = [0]*(K+1)

for k in range(K,0,-1):
    ans[k] = pow(K//k,N,mod)
    for l in range(2,K//k+1):
        ans[k] -= ans[k*l]
    ans[k] %= mod

for i in range(K+1):
    ans[i] *= i

ans = sum(ans)%mod

print(ans)

Measured memory_bytes: 69380
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size()
#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n) for (int i = n; i >= 0; i--)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define foreach(itr, c) for (__typeof((c).begin(), (c).end()) itr = c.begin(); itr != c.end(); itr++)
#define fill(a, b) memset(a, b, sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<char> vs;
typedef vector<pi> vpi;

using namespace std;

int main()
{
    string n;
    ll ans = 0;

    cin >> n;

    rep(i, n.length())
    {
        ans += n[i] - '0';
    }
    if (ans % 9 == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3732
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int X;
	scan(X);
	if(X==3||X==5||X==7) prin("YES");
	else prin("NO");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define ll long long int
using namespace std;

int main(int argc, char const* argv[])
{
	int h, w;
	cin >> h >> w;
	char **str = new char*[h];
	for(int i = 0; i < h; i++){
			str[i] = new char[w];
			cin >> str[i];
	}
	for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
					if(str[i][j] == '.')continue;
					if((i > 0 && str[i-1][j] == '#') || (j > 0 && str[i][j-1] == '#') || (i < h-1 && str[i+1][j] == '#') || (j < w-1 && str[i][j+1] == '#'))continue;
					else{
							cout << "No" << endl;
							return 0;
					}
			}
	}
	cout << "Yes" << endl;
	return 0;
}


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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    int n; cin >> n;

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

    sort(a.rbegin(), a.rend()); //降順ソート

    ll alice = 0;
    ll bob = 0;

    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    cout << alice - bob << endl;
}

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

using namespace std;

const int INF = 1e9 + 5;

int main()
{
    string s;
    int t[26];
    int mt[26];
    int ans = INF;

    cin >> s;
    int slen = s.length();

    for (int i = 0; i < 26; i++)
    {
        t[i] = -1;
        mt[i] = 0;
    }
    for (int i = 0; i < slen;i++)
    {
        int idx = s[i] - 'a';
        mt[idx] = max(mt[idx], i - t[s[i] - 'a']);
        t[s[i] - 'a'] = i;
    }
    ans = INF;
    for (int i = 0; i < 26; i++)
    {
        mt[i] = max(mt[i], slen - t[i]);
        if(t[i] != -1)
        {
            ans = min(ans, mt[i]);
        }
    }
    cout << ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 888
import math

n = int(input())
mod = 10 ** 9 + 7

ab = {}
for i in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        pass
    elif a == 0:
        b = 1
    else:
        gcd = math.gcd(a, b)
        a //= gcd
        b //= gcd
        if a < 0:
            a, b = -a, -b
    num = (a, b)
    ab.setdefault(num, 0)
    ab[num] += 1
bin_n = [2]
for i in range(len(bin(n)) - 3):
    temp = bin_n[-1]
    temp = temp ** 2
    temp %= mod
    bin_n.append(temp)
def beki2(n):
    num = bin(n)
    temp = 1
    for i in range(len(num) - 2):
        if num[-i-1] == "1":
            temp *= bin_n[i]
            temp %= mod
    return temp

ans = 0
if (0, 0) in ab.keys():
    temp2 = ab[(0, 0)]
    ans += temp2
    n -= temp2
s = set(ab.keys())
pairs = []
for i in ab.keys():
    if i == (0, 0):
        continue
    else:
        a, b = i[0], i[1]
        if (-b, a) in s:
            pairs.append([ab[(a, b)], ab[(-b, a)]])
temp3 = 1
for i in range(len(pairs)):
    num2 = pairs[i][0]
    num3 = pairs[i][1]
    temp3 *= (beki2(num2) + beki2(num3) - 1)
    n = n- num2 - num3
    temp3 %= mod
temp3 *= beki2(n)
temp3 -= 1
temp3 %= mod
ans += temp3
ans %= mod
print(ans)

Measured memory_bytes: 59468
import numpy as np

N = int(input())

A = np.zeros((10,10))
 
for i in range(1, N+1):
    
    A[int(str(i)[0])][int(str(i)[-1])] += 1 
    
count = 0

for i in range(1, 10):
    for j in range(1, 10):
        count += A[i][j] * A[j][i]

print(int(count))

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

#define ll long long
#define ii pair<int,int>
#define INF 1e9 + 7
#define vi vector<int>
#define add emplace_back


int main(){ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vi a(n);
    for(int i=0; i<n; ++i) cin >> a[i];
    
    vi 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(a[i]-a[j]));
        }
    }
    
    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    int N, K;
    std::cin >> N >> K;

    if (N % 2 != 0) {
        N++;
    }

    if (N / K >= 2) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO"  << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256