akhauriyash/Code-Regression huggingface dataset:
/*
A0410.c Akabeko 20
2019/11/08 rte
 */
#include <stdio.h>
#include <string.h>

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

int m,n,n2,q[41],p[20];
int  from[8000];
char to[8000];
int cntr; //割り切れる順列の数
int primes[]={2,3,5,7,11,13,17,19,23,29,31,37};
char gt_[20][12]; //２０個（まで）の引数をゲーデル表記に変換

int gcd(int a, int b)
{       int c;
        while (b > 0) {
                c = a % b;
                a = b;
                b = c;
        }
        return a;
}
void dump(int mask,int m2)
{ int i,j;

  for(i=0,j=1;i<n;i++,j<<=1)
    {
      if(j & mask)
	printf("%d,",p[i]);
    }
  printf(":%d\n",p[m2]);
}
int check(int x)
{
  int i,f,t,mask;
  
  for(i=0;i<cntr;i++)
    {
      mask=from[i];
      t   =to[i];
      //dump(mask,t);
      if((x & mask)==mask && (x & (1<<t))==0)
	{
	  return(0);
	}
    }
  return(1);
}


int solve()
{
  int i,ret;
  for(i=1,ret=0;i<(1<<n);i++)
  {
      
    if(check(i))
      ret++;
  }
  return(ret);

}
void dump_fact(char gt[])
{
  int i;
  for(i=0;i<12;i++)
    if(gt[i]>0)
      printf("%d[%d]:",primes[i],gt[i]);
    printf("\n------\n");
}
void factorize(int num,char gt[])
{
  int i;

  memset(gt,0,12);
  while(num>1)
    {
      for(i=0;i<12;i++)
	if((num % primes[i])==0)
	{
	    gt[i]++;
	    num /= primes[i];
	}
    }
  //dump_fact(gt);
}

int lcm(char outgt[],char gt[],char gt2[])
{
  int i;
  //dump_fact(gt);
  //dump_fact(gt2);
  for(i=0;i<13;i++)
    {
      outgt[i]=max(gt[i],gt2[i]);
      //if(outgt[i]>0)
	//printf("%d[%d]%d\n",i,primes[i],gt[i]);
    }
}
int divisor(char gt[],char gt2[])
{  int i,ret;
  
  //dump_fact(gt);
  //dump_fact(gt2);

  
  for(i=0;i<12;i++)
    if(gt[i]>gt2[i])
       return(0);
  //printf("*!*");
  return(1);
}


void make_gt()
{
  int i;
  
  for(i=0;i<20;i++)
    factorize(p[i],&gt_[i][0]);
}

void prepare()
{ int i,j,k,l,mask;
  char gt[13],gt2[13],gt3[13];
  
  cntr=0;

  for(i=0;i<n;i++)
  {  
    memcpy(gt,&(gt_[i][0]),sizeof(gt));
    for(j=i;j<n;j++)
    {
      lcm(gt2,gt,&(gt_[j][0]));
      {
	for(k=j;k<n;k++)
	{
	  lcm(gt3,gt2,&(gt_[k][0]));
	  for(l=0;l<n;l++)
	  {
	    if(l!=i && l!=j && l!=k && divisor(&gt_[l][0],gt3))
	    {
		from[cntr]=mask=(1<<i)|(1<<j)|(1<<k);
		to  [cntr]=l;
		cntr++;
		//dump(mask,l);
	    }
	    
	  }
	}
      }
    }
  }
}
void dump_gt()
{
  int i;
  for(i=0;i<n;i++)
  {
    dump_fact(&gt_[i][0]);

  }
}
void dump1()
{
  int i;
  printf("n=%d\n",n);
  for(i=0;i<n;i++)
    printf("%d ",p[i]);
  printf("\n",n);
}

int main()
{
  int i,j,k,ret,c;
  
  
  scanf("%d",&n2);
  n=0;
  for(i=0;i<n2;i++)
  {
        scanf("%d",&c);
	  q[c]++;
	   
	  
  }
  for(i=2,n=0;i<=40;i++)
    {
      if(q[i]>0)
	{
	  p[n]=i;
	  n++;
	}
    }
  //dump1();
  make_gt();
  //dump_gt();
  
  if(n<=1)
    { if(q[1]==n2 || q[1]==0)  // 1種類だけのとき
	ret=1;
      else          //　１と他１種だけのとき
	ret=2;
    }
  else
  {
    prepare();
    //printf(":cntr=%d\n",cntr);  
    ret=solve();
    if(q[1]>0)
      ret++;
  }
  printf("%d\n",ret);
  
  return(0);
}




Measured memory_bytes: 2144
//  Created by liszt on 2019/07/26.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> l(n),r(n);
    string s; cin>>s;
    
    l[0]=0; r[n-1]=0;
    for(int i=1;i<n;i++){
        l[i]=l[i-1]+(s[i-1]=='W');
        r[n-1-i]=r[n-i]+(s[n-i]=='E');
    }
    
    int ans=INT_MAX;
    for(int i=0;i<n;i++){
        if(i==0)ans=r[0];
        if(i!=0||i!=n-1)ans=min(ans,l[i]+r[i]);
        if(i==n-1)ans=min(ans,l[n-1]);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3204
from math import factorial

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


def comb(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


counts = [0] * (N + 1)
for a in A:
    counts[a] += 1
total = sum(map(lambda n: comb(n, 2), filter(lambda n: n > 1, counts)))

for a in A:
    print(total - (counts[a] - 1))


Measured memory_bytes: 26140
#include<stdio.h>
int main()
{
    int w,a,b,r;
    scanf("%d %d %d",&w,&a,&b);

    if(a<=b)
        r=a+w-b;
    else
        r=b+w-a;
    if(r>0)
        printf("0");
    else
        printf("%d",-r);
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

int main(){
    // input
    string S;
    cin >> S;

    // calc
    int ans, L, half;
    L    = S.length();
    half = L / 2;

    ans = 0;
    char S1, S2;
    for (int i=0; i<half; i++){
        S1 = S[i];
        S2 = S[ L-1-i ];
        if( S1 != S2 ) ans++;
    }

    // output
    cout << ans << endl;
} 

Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use itertools::Itertools;

#[fastout]
fn main() {
    input! {
    n: usize,
    ab: [(usize, usize); n]
    }
    let a = (0..n).map(|x| ab[x].0).sorted().collect::<Vec<usize>>();
    let b = (0..n).map(|x| ab[x].1).sorted().collect::<Vec<usize>>();
    let m = n / 2;
    let ans = if n % 2 == 1 {
        b[m] - a[m] + 1
    } else {
        b[m] + b[m - 1] - (a[m] + a[m - 1]) + 1
    };
    println!("{}", ans);
}


Measured memory_bytes: 12872
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, x, y, z; cin>>n>>x>>y>>z;
    int ngbit = 0;
    ngbit |= (1 << (z - 1));
    ngbit |= (1 << (y + z - 1));
    ngbit |= (1 << (x + y + z - 1));

    int sum = x + y + z;
    int mask = (1 << sum) - 1;

    vector<vector<ll>> dp(n+1, vector<ll>((1<<sum), 0));
    dp[0][0] = 1;

    for(int i=0; i<n; i++){
        for(int bit=0; bit<(1<<sum); bit++){
            for(int j=1; j<=10; j++){
                int nbit = mask & ((bit << j) ^ (1 << (j - 1)));
                if((nbit & ngbit) == ngbit) continue;
                dp[i+1][nbit] += dp[i][bit];
                dp[i+1][nbit] %= MOD;
            }
        }
    }

    ll sub = 0;
    for(int bit=0; bit<(1<<sum); bit++){
        sub += dp[n][bit];
        sub %= MOD;
    }

    ll all = 1;
    for(int i=0; i<n; i++){
        all *= 10;
        all %= MOD;
    }

    cout << (all - sub + MOD) % MOD << endl;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

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

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

ll dp[2001][2001];

int main() {
    int n;
    ll a[2000];
    pair<ll, int> p[2000];
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        p[i].first = a[i];
        p[i].second = i;
    }
    sort(p, p + n, greater<pair<ll, int>>());

    fill(dp[0], dp[2001], -1);
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int l = 0; l <= i; ++l) {
            int r = i - l;
            chmax(dp[l + 1][r], dp[l][r] + p[i].first * abs(p[i].second - l));
            chmax(dp[l][r + 1], dp[l][r] + p[i].first * abs(p[i].second - (n - r - 1)));
        }
    }
    ll ans = 0;
    for (int i = 0; i <= n; ++i)
        chmax(ans, dp[i][n - i]);
    cout << ans << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector <int> v;
    vector <int> neww(n+1);
    for (int i=0; i<n; i++)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    for (int i=1; i<=n; i++)
    {
        neww[v[i-1]] = i;
    }
    for (int i=1; i<=n; i++)
    {
        cout << neww[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 1784
'''
1つの始点から全頂点への最短距離を求めるアルゴリズム
辺の数E,頂点の数Vに対し、O((E+V)log(V))
edge[u]=[(d1, v1), (d2, v2), ...]が頂点uと頂点viに距離diの辺があることを表す隣接リストが入力
無向グラフにて検証済み。有効グラフのたぶんいけるので確認したらここを書き換えて欲しい。
'''

from heapq import heappush, heappop

INF = 10**15
 
def dijkstra(s, edges):
    que = []
    d = [INF] * n
    d[s] = 0
    heappush(que, (0, s))

    while len(que) > 0:
        (c, v) = heappop(que)
        if d[v] < c:
            continue
        for (cc, w) in edges[v]:
            if d[w] > d[v] + cc:
                d[w] = d[v] + cc
                heappush(que, (d[w], w))

    return d

n, m, s, t = map(int, input().split())
s, t = s-1, t-1
yen_edge = [[] for i in range(n)]
snook_edge = [[] for i in range(n)]
for i in range(m):
    ui, vi, ai, bi = map(int, input().split())
    ui, vi = vi-1, ui-1
    yen_edge[ui].append((ai, vi))
    yen_edge[vi].append((ai, ui))
    snook_edge[ui].append((bi, vi))
    snook_edge[vi].append((bi, ui))

distance_yen = dijkstra(s, yen_edge)
distance_snook = dijkstra(t, snook_edge)

ans_lst = [0 for i in range(n)]
temp_min = 10**15
for i in range(n)[::-1]:
    now = distance_yen[i] + distance_snook[i]
    temp_min = min(temp_min, now)
    ans_lst[i] = 10**15 - temp_min

for i in range(n):
    print(ans_lst[i])

Measured memory_bytes: 80244
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll t;
	cin>>t;
	if(t>=30)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}



Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n, m;
  cin >> n >> m;

  vector<pii> a(n);
  rep(i, n) {
    cin >> a[i].first >> a[i].second;
  }

  sort(all(a));

  priority_queue<int> p;

  int ans = 0;

  int j = 0;
  rep(i, m) {
    while (j < n && a[j].first == i+1) {
      p.push(a[j++].second);
    }

    if (p.size()) {
      ans += p.top();
      p.pop();
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 1660
KN = input("").split()
A = input("").split()

K = int(KN[0])
N = int(KN[1])
A_0 = int(A[0])
A_N = int(A[N-1])
L = A_0

for j in range(N-1):
    A_i = int(A[j+1])
    A_m = int(A[j])
    if A_i - A_m > L:
        L = A_i - A_m

if L > K - A_N + A_0:
    print(K-L)
else:
    print(A_N - A_0)


Measured memory_bytes: 18484
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	P(max(a*b,c*d));
}

int main() {
    solve();
    return 0;
}



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

int main() {

  int N=0;
  cin >> N;
  string r = "Yes";
  int a = N / 100;
  int b = (N - a*100) / 10;
  int c = (N - a*100 - b*10);
  if( a==7 || b==7 || c==7){
    cout << r << endl;
  }
  else {
    r = "No";
    cout << r << endl;
  }
}


Measured memory_bytes: 3628
using System;

namespace OJcsharp
{
    class Program
    {
        static double mennseki(double x, double h)
        {
            double syahen = Math.Sqrt(x * x/4 + h * h);
            return x * x + syahen * x * 2;
        }
        static void Main(string[] args)
        {
            double[] ans = new double[10000];
            int count = 0;
            do
            {
                int x = int.Parse(Console.ReadLine());
                int h = int.Parse(Console.ReadLine());
                if (x == 0 && h == 0)
                    break;
                ans[count] = mennseki(x, h); 
                count++;
            } while (true);
            for (int n = 0; n < count; n++)
            {
                Console.WriteLine(ans[n]);
            }
        }
    }
}

Measured memory_bytes: 5700
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		long t1 = (n / (a + b)) * a;
		long t2 = n % (a + b) > a ? a : n % (a + b);

		sc.close();
			System.out.println(t1 + t2);


	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename V>
V compress(V v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}
template<typename T>
map<T, int> dict(const vector<T> &v){
  map<T, int> res;
  for(int i=0;i<(int)v.size();i++)
    res[v[i]]=i;
  return res;
}
map<char, int> dict(const string &v){
  return dict(vector<char>(v.begin(),v.end()));
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  priority_queue<Int, vector<Int>, greater<Int>> pq;
  for(Int i=1;i<10;i++) pq.emplace(i);

  vector<Int> vs;
  while(pq.top()<=3234566667){
    Int v=pq.top();pq.pop();
    vs.emplace_back(v);

    pq.emplace(v*10+(v%10));
    if(v%10>0) pq.emplace(v*10+(v%10)-1);
    if(v%10<9) pq.emplace(v*10+(v%10)+1);
  }

  vs=compress(vs);

  Int k;
  cin>>k;

  k--;
  cout<<vs[k]<<newl;
  return 0;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int A[100010], B[100010];
ll sum, tmp, cnt;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  tmp = (ll)N * (N + 1) / 2;
  if (sum % tmp != 0) {
    cout << "NO" << endl;
    return 0;
  }
  cnt = sum / tmp;
  for (int i = 0; i < N; i++) {
    B[i] = A[i] - A[(i - 1 + N) % N];
    B[i] = B[i] - cnt;
    if (B[i] > 0 || B[i] % N != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

vector<int> make753() {

	vector<int> vec753;
	int bit_used = 0, range = 9;
	int tmp, ternary, n753;

	for (int digit = 3; digit <= 9; digit++) {

		range *= 3;

		for (int i = 0; i <= range; i++) {

			bit_used = 0;
			ternary = i;
			n753 = 0;

			for (int j = 0; j < digit; j++) {

				tmp = ternary % 3;
				ternary /= 3;
				n753 *= 10;
				
				if (tmp == 0) {
					n753 += 3;
					bit_used |= 1;
				}				
				if (tmp == 1) {
					n753 += 5;
					bit_used |= 2;
				}
				if (tmp == 2) {
					n753 += 7;
					bit_used |= 4;
				}

			}

			if (!(bit_used ^ 7)) vec753.push_back(n753);

		}

	}

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

	return vec753;

}

int main() {

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

	int N;
	cin >> N;

	vector<int> vec = make753();
	int ans = upper_bound(vec.begin(), vec.end(), N) - vec.begin();

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxn =1e5+10;
typedef long long ll;
int main()
{

    ll le,ri;
    cin>>le>>ri;
    ll ans1=0,ans2=0;
    ll po,qo;
    if((le-1)%4==0)
    {
        po=1;
    }
    else if((le-1)%4==1)
    {
       po=2;
    }
    else if((le-1)%4==2)
    {
       po=3;
    }
    else
    {
        po=0;
    }
     if((ri)%4==0)
    {
        qo=1;
    }
    else if((ri)%4==1)
    {
       qo=2;
    }
    else if((ri)%4==2)
    {
       qo=3;
    }
    else
    {
        qo=0;
    }
    for(int i=0;i<po;i++)
    {
        if(le-1-i<=0)
        {
            break;
        }
       ans1=ans1^(le-1-i);
    }
     for(int i=0;i<qo;i++)
     {
         if(ri-i<=0)
         {
             break;
         }
         ans2=ans2^(ri-i);
     }
     ll ans=ans1^ans2;
     cout<<ans<<endl;
    return 0;
}


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

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

    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll mod = 1e9 + 7, ans = 1;
    a.push_back(1e10);
    b.push_back(1e10);

    int ai = 0, bi = 0;
    ll c = 0, r = 1;
    bool is_a = (a[0] < b[0]);

    while (ai < n || bi < n)
    {

        if (a[ai] < b[bi])
        {
            if (!is_a)
            {
                r = (r * c) % mod;
                c--;
                if (!c)
                {
                    is_a = true;
                    ans = (ans * r) % mod;
                    r = 1;
                }
            }
            else
                c++;
            ai++;
        }
        else
        {
            if (is_a)
            {
                r = (r * c) % mod;
                c--;
                if (!c)
                {
                    is_a = false;
                    ans = (ans * r) % mod;
                    r = 1;
                }
            }
            else
                c++;
            bi++;
        }
        if (!c)
            is_a = (a[ai] < b[bi]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2672
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int tmp[200001], tmp2[200001];
void pakuripair_sort(int N, int A[], int B[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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


	int N = getint(), K = getint();
	int A[200001];
	rep(i, N) {
		A[i] = (getint() + K - 1) % K;
	}

	int B[200001];
	B[0] = 0;
	rep(i, N) {
		B[i + 1] = B[i] + A[i];
		if (B[i + 1] >= K) B[i + 1] -= K;
	}
	rep(i, N + 1) A[i] = i;

	pakuripair_sort(N + 1, B, A);
	int kazu = 0;
	int mae = B[0];
	memset(tmp, 0, sizeof(tmp));
	rep(i, N + 1) {
		if (mae != B[i]) {
			kazu++;
			mae = B[i];
		}
		tmp[A[i]] = kazu;
	}
	memset(A, 0, sizeof(A));

	ll kotae = 0;
	rep(i, N + 1) {
		kotae += A[tmp[i]];
		A[tmp[i]]++;
		if (i - K + 1 >= 0) A[tmp[i - K + 1]]--;
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n, k;
  cin >>n >> k;
  int ans;
  if(n % k == 0) {
    ans = 0;
  } else {
    ans = 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
"""
問題文

1 以上 N 以下の異なる整数を、差が 1 の整数をともに選ばないように K 個選ぶことができるか判定してください。
制約

    1≤N,K≤100
    N,K は整数である
"""

def func(N , K) : 
    #K = 1 OK
    #K = 2 N > 2であればOK
    #K = 3 N > 5であればOK
    #K = 4 N > 7であればOK
    #K = k N > 2*k + 1
    if N >= 2*(K-1) + 1 : 
        return "YES"
    else : 
        return "NO"

if not func(3 , 2) == "YES" : 
    raise Exception("test 1 fail")

if not func(5, 5) == "NO" : 
    raise Exception("test 2 fail")

if not func(31 , 10) == "YES" : 
    raise Exception("test 3 fail")

if not func(10 , 90) == "NO" : 
    raise Exception("test 4 fail")

s = input().split(" ")
print(func(int(s[0]) , int(s[1])))

Measured memory_bytes: 3064
#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);

	int n;
	cin >> n;

	vector<int> a(n);
	int minus = 0;
	int min_value = INT_MAX;
	long long total = 0;
	bool z = false;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] < 0) {
			++minus;
		}

		min_value = min(min_value, abs(a[i]));
		total += abs(a[i]);
		z = (a[i] == 0);
	}

	if (z || minus % 2 == 0) {
		cout << total << "\n";
	} else {
		cout << total - 2 * min_value << "\n";
	}

	return 0;

}

Measured memory_bytes: 640
import bisect
N=int(input())
A=sorted(list(map(int, input().split())))
B=sorted(list(map(int, input().split())))
C=sorted(list(map(int, input().split())))
ans=0
for i in range(N):
    ans+=(bisect.bisect_left(A,B[i]))*(N-bisect.bisect_right(C,B[i]))
print(ans)

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

int main() {
int D,N=0;
  string S="";
  cin>>D>>N;
	if(N<100) cout<<N*pow(100,D)<<endl;
  else{
    long a=101*pow(100,D);
    cout<<a<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    int count=0;
    
    for (int i=0;i<4;i++) {
        if (S[i]==S[i+1]) count++;
        
    }
    
    
    if (count>0) cout << "Bad" <<endl;
    else cout << "Good" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ii      pair<int,int>
#define pb      push_back
using namespace std;

set<int> check;
vector<vector<int>> gn;

void dfs(map<int,vector<int>> & g, int cur){
    check.insert(cur);
    gn[cur].pb(gn.size() - 1);
    gn.back().pb(cur);
    for(auto &nei:g[cur]) if(check.find(nei) == check.end()) dfs(g, nei);
}
int main() {
	int n,m; cin >> n >> m;
	vector<vector<ii>> comp(1e6);
	for(int i=0,a,b,c;i<m;i++){
	    cin >> a >> b >> c; --a,--b,--c;
	    comp[c].pb({a,b});
	}
	gn.resize(n);
	for(int i=0;i<1e6;i++){
	    map<int,vector<int>> g;
	    for(auto &e : comp[i]){
	        g[e.first].pb(e.second);
	        g[e.second].pb(e.first);
	    }
	    check.clear();
	    for(auto &v:g){
	        if(check.find(v.first) != check.end()) continue;
	        gn.resize(gn.size()+1);
	        dfs(g,v.first);
	    }
	}
	vector<int> dis(gn.size(), 1e9);
	std::queue<int> q;
	q.push(0); dis[0] = 0;
	for(int cur;q.size();q.pop()){
	    cur = q.front();
	    for(auto &nei:gn[cur]){
	        if(dis[nei] == 1e9) q.push(nei), dis[nei] = dis[cur] + 1;
	    }
	}
	cout << (dis[n-1] != 1e9 ? dis[n-1]/2 : -1) << endl;
	return 0;
}


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

#define repr(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define irepr(i,a,b) for(int i=a, i##_len=(b); i>=i##_len; --i)
#define irep(i,n) for(int i=n, i>=0; --i)

#define printline(str) cout << str << "\n"

#define inputInt(x) int x;cin>>x;

#define lint long long

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  inputInt(N);
  vector<int> A(N+1);
  rep(i,N+1){
    cin >> A[i];
  }
  vector<int> B(N);
  rep(i,N){
    cin >> B[i];
  }

  lint sumCombat = 0;
  int ex = 0;
  rep(i,N){
    int lst = max(0, A[i] - ex);
    ex = 0;
    ex = max(0, B[i]-lst);
    lst = max(0, lst-B[i]);
    sumCombat += A[i]-lst;
  }
  int lst = max(0, A[N] - ex);
  sumCombat += A[N]-lst;
  printline(sumCombat);
}

Measured memory_bytes: 1024
// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
78786    print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}
#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(dead_code)]
fn vector_accumulation(vec: &Vec<i64>) -> Vec<i64> {
    let mut res = Vec::new();
    let size = vec.len();
    res.push(0);
    for i in 0..size {
        res.push(vec[i]);
    }
    for i in 0..size {
        res[i + 1] += res[i];
    }
    res
}

fn solve() {
    let (n, h) = readuu();
    let mut vec = vec![0 as i64; 0];
    let mut d = 0 as i64;
    for i in 0..n {
        let (mut b, mut a) = readii();
        d = max(d, b);
        vec.push(a);
    }
    vec.sort();
    vec.reverse();
    let mut avec = vector_accumulation(&vec);
    let mut res = INF;
    for i in 0..n + 1 {
        let mut cnt = 0 as i64;
        let mut hh = h as i64;
        cnt = i as i64;
        hh -= avec[i];
        if (hh > 0) {
            cnt += (hh + d - 1) / d;
        }
        res = min(res, cnt);
        // println! {"{} {} {}",avec[i],d,cnt};
    }
    println!("{}", res);

    return;
}
fn main() {
    solve()
}


Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int n[100000],s[100000],m;

int main(){
	int c=0;
	while(scanf("%d,%d",&n[c],&s[c])){
		if(n[c]+s[c]==0)break;
		c++;
	}
	int p=1;
	for(int i=30;i>=0;i--){
		int flag=0;
		for(int j=0;j<c;j++){
			if(s[j]==i){s[j]=p+100;flag=1;}
		}
		if(flag==1)p++;
	}
	while(scanf("%d",&m)!=EOF){
		for(int i=0;i<c;i++)if(n[i]==m){
			cout<<s[i]-100<<endl;
			break;
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define Mk make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
int a[200005],pos[200005],ans = 0,n;
int f[200005];
int main(){
	n = rd();
	Rep(i,1,n) a[i] = rd(),pos[a[i]]=i;
	int x = n-1;
	f[1] = 1;
	Rep(i,2,n){
		if(pos[i] > pos[i-1]) f[i] = f[i-1] + 1; else f[i] = 1;
		x = min(x,n-f[i]);
	}
	writeln(x);
	return 0;
}


/*

n-2 XXXX n-1 X X n-2 X n

8
6 3 1 2 7 4 8 5



*/ 

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

int main(){
	int n, m;
	cin >> n >> m;
	int a[n];
	for(int i = 0; i < n; i++){
		a[i] = i+1;
	}
	for(int i = 0; i < m; i++){
		int p, q;
		char trash;
		cin >> p >> trash >> q;
		swap(a[p-1],a[q-1]);
	}
	for(int i = 0; i < n; i++){
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

bool isDistinctTriangle(int a, int b, int c)
{
    if(a==b || b==c || a==c)
        return false;
    else
    {
        if(a+b>c && a+c>b && b+c>a)
            return true;
        else
            return false;
    }
}

int main()
{
    int n, count=0;;
    cin>>n;
    if(n<3)
        cout<<"0";
    else
    {
        int a[n]; 
        int i,j,k;
        for(i=0; i<n; ++i)
            cin>>a[i];
        for(i=0; i<n-2; ++i)
            for(j=i+1; j<n-1; ++j)
                for(k=j+1; k<n; ++k)
                    if(isDistinctTriangle(a[i],a[j],a[k]))
                        ++count;
        cout<<count;
    }
    
   
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int n,m;
int a[310][310];
int itr[310],cnt[310],act[310];

int check(){
	int cmax = 0;
	rep(i,m) chmax(cmax,cnt[i]);
	return cmax;
}


int main(void){
	cin >> n >> m;
	rep(i,n)rep(j,m) cin >> a[i][j],a[i][j]--;

	rep(i,n) cnt[a[i][0]]++;
	rep(i,m) act[i]=1;

	int ans = check();

	rep(loop,m-1){
		int idx = 0;
		//rep(i,m) cerr << cnt[i] << " ";
		//cerr << endl;
		rep(i,m) if(cnt[idx]<cnt[i]) idx = i;

		act[idx]=0;
		rep(i,n){
			while(act[a[i][itr[i]]]==0){
				cnt[a[i][itr[i]]]--;
				itr[i]++;
				cnt[a[i][itr[i]]]++;
			}
		}

		chmin(ans,check());
	}	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	ll a, b, n;
	cin >> a >> b >> n;

	cout << (a * min(n, b - 1)) / b << "\n";

	return 0;
}



Measured memory_bytes: 3648
import java.util.*;
 
public class Main{
  static final double EPS = 0.00001;
 
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
 
    while(true){
      double q = sc.nextInt();
      if(q < 0) break;
 
      double x = q / 2.0;
 
      while(Math.abs(x * x * x - q) >= EPS * q){
        x = x - (x * x * x - q) / (3 * x * x);
      }
 
      System.out.printf("%.6f\n", x);
    }
  }
}


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

//l-child, r-sibling representation

int n;
int p[100010], l[100010], r[100010];

void dfs(int depth, int n){
  if(p[n] == -1){
    cout << "depth = " << depth << ", ";
    return ;
  }

  dfs(depth + 1, p[n]);
  return ;
}

void searchsibling(int c){
  cout << '[';
  for(int i = 0;;i++){
    if(c == -1) break;
    cout << (i?", ":"");
    cout << c;
    c = r[c];
  }
  cout << ']' << endl;
}

void solve(){
  for(int i = 0;i < n;i++){
    cout << "node " << i << ": ";
    cout << "parent = " << p[i] << ", ";
    dfs(0, i);
    if(p[i] == -1) cout << "root, ";
    else if(l[i] != -1) cout << "internal node, ";
    else cout << "leaf, ";
    searchsibling(l[i]);
  }
}

int main(){
  cin >> n;
  for(int i = 0;i < n;i++) p[i] = l[i] = r[i] = -1;
  for(int i = 0;i < n;i++){
    int id, k, c, s;

    cin >> id >> k;
    for(int j = 0;j < k;j++){
      cin >> c;
      if(j == 0) l[id] = c;
      else r[s] = c;
      p[c] = id;
      s = c;
    }
  }

  solve();

  return 0;
}



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

int digit[10];
int unite(int a, int b) {
    int i;
    for(i = 0; a > 0 || b > 0; ++i) {
        if(b > 0) {
            digit[i] = b%10;
            b /= 10;
        } else {
            digit[i] = a%10;
            a /= 10;
        }
    }
    int res = 0;
    while(i > 0) {
        res *= 10;
        res += digit[i-1];
        --i;
    }
    return res;
}

int main()
{
    int a, b;
    cin >> a >> b;
    int c = unite(a, b);
    for(int i = 0; i < 320; ++i) {
        if(i*i == c) { cout << "Yes" << endl; return 0; }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
public class Hello{
    public static void Main(){
        
        int N = int.Parse(System.Console.ReadLine());
        string[] str = System.Console.ReadLine().Split(' ');

        bool state = true;
        for(int i = 0; i < N; i++){
            if(str[i].Equals("Y")) state = false;
        }
        System.Console.WriteLine(state ? "Three" : "Four");
    }
}


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

using namespace std;

int main() {
    string S;
    cin >> S;
    int num0 = 0;
    int num1 = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == '0') ++num0;
        else ++num1;
    }

    cout << 2 * min(num0,num1);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = a.back() - a.front();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

ll dst(ll a, ll b, ll x, ll y){
    ll ans = abs(a-b);
    ans = min(ans,abs(a-x)+abs(b-y)+1);
    ans = min(ans,abs(a-y)+abs(b-x)+1);
    return ans;
}

int main(){
    ll n,x,y; cin >> n >> x >> y;
    vector<ll> ans(n+1,0);
    rep2(i,n){
        for(ll j=i+1; j<=n; j++){
            ans[dst(i,j,x,y)]++;
        }
    }
    rep2(i,n){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int N;
lint A,B;
lint h[100010]={};

bool check(lint n)
{
	lint cnt=0;
	for(int i=0;i<N;i++)
	{
		lint th=h[i];
		th-=B*n;
		if(th>0)
			cnt+=(th+A-B-1)/(A-B);
	}
	
	return cnt<=n;
}

int main()
{
	cin >> N >> A >> B;
	for(int i=0;i<N;i++)
		cin >> h[i];

	lint l=-1;
	lint r=0;
	lint tmp=0;
	for(int i=0;i<N;i++)
		tmp=max(tmp,h[i]);
	r=(tmp+B-1)/B;

	for(;r-l>1;)
	{
		lint mid=(l+r)/2;
		if(check(mid))r=mid;
		else l=mid;
	}

	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1024
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else 10**9
  ret0 = dfs(cur+1, a, b, c)
  ret1 = dfs(cur+1, a+l[cur], b, c) + 10
  ret2 = dfs(cur+1, a, b+l[cur], c) + 10
  ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

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




int main() {
	string a, b;
	cin >> a >> b;
	int x = stoi(a + b);
	for (int i = 1; i <= 350; i++)
	{
		if (i*i==x)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3604
object Main {
  class Solver(n: Int, s: String) {
    def nChar: (String, String) => Int = {
      def sub: (Array[Char], Array[Char], Char) => Int  = {
        (x, y, c) => c match {
          case 'z' => {
            if (x.contains(c) && y.contains(c)) 1
            else 0
          }
          case _ => {
            if (x.contains(c) && y.contains(c)) sub(x, y, (c+1).toChar) + 1
            else sub(x, y, (c+1).toChar)
          }
        }
      }
      (x, y) => sub(x.toCharArray, y.toCharArray, 'a')
    }

    def solve: Int = {
      val li = for (i <- 1 to n-1) yield nChar(s.slice(0, i), s.slice(i, n))
      li.max
    }
  }
  
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readLine().toInt
    val s = io.StdIn.readLine()
    val solver = new Solver(n, s)
    println(solver.solve)
  }
}



Measured memory_bytes: 25748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_153
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            int n = nk[0];
            int k = nk[1];
            int[] hs = ReadInts();
            long res = 0;
            Array.Sort(hs);
            for(int i = 0; i < n-k; i++)
            {
                res += hs[i];
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 35152
#include<stdio.h>
int cnt=100;

int main()
{
  int M[cnt][cnt];
  int i,j,k,l,num,value;

  scanf("%d",&num);
  for(i=0;i<num;i++)
    {
      for(j=0;j<num;j++) M[i][j]=0;
    }

  for(i=0;i<num;i++)
    {
      scanf("%d %d",&k,&l);
      k--;
      for(j=0;j<l;j++)
	{
	  scanf("%d",&value);
	  value--;
	  M[k][value]=1;
	}
    }
  
   for(i=0;i<num;i++)
    {
      for(j=0;j<num;j++)
	{
	  if(j)printf(" ");
	  printf("%d",M[i][j]);
	}
      printf("\n");
    }
   return 0;
}

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

typedef long long ll;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int a[n], b[n], c[n-1];
	for (int i = 0; i<n; i++) {
		cin >> a[i];
		a[i]--;
	}
	for (int i = 0; i<n; i++) cin >> b[i];
	for (int i = 0; i<n-1; i++) cin >> c[i];
	
	int ret = b[a[0]];
	for (int i = 1; i<n; i++) {
		ret += b[a[i]];
		if (a[i] - a[i-1] == 1) ret += c[a[i-1]];
	}
	cout << ret << '\n';
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int c[10][1005];

int main() {
  int h,w,k; cin >> h >> w >> k;
  vector<string> s(h);
  REP(i,h) cin >> s[i];
  int ans = INF;

  REP(div,1<<(h-1)) {
    int g = 0;
    vector<int> id(h);
    REP(i,h) {
      id[i] = g;
      if (div>>i&1) g++;
    }
    g++;

    // 初期化
    REP(i,g) REP(j,w) c[i][j] = 0;
    REP(i,h) REP(j,w) c[id[i]][j] += (s[i][j]-'0');
    bool ok = true;
    REP(i,g) REP(j,w) if (c[i][j] > k) ok = false;
    if (!ok) continue;

    int num = g-1;
    vector<int> now(g);
    auto add = [&](int j) {
      REP(i,g) now[i] += c[i][j];
      REP(i,g) if (now[i] > k) return false;
      return true;
    };
    REP(j,w) {
      if (!add(j)) {
        num++;
        now = vector<int>(g);
        add(j);
      }
    }
    ans = min(ans,num);
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;


 	
 	
int main() {
	
int N;
map<string,int> W;
vector<string> WW;
bool check=true;
cin>>N;
fx(N){
	string w;
	cin>>w;
	WW.push_back(w);
	W[w]++;
	if(W[w]>1){
		check=false;
	}
}

if(check){
	fx(N-1){
		if(WW.at(x).at(WW.at(x).size()-1)!=WW.at(x+1).at(0)){
			check=false;
			break;
		}
	}
	
	if(check){
		ce("Yes")
	}else{
		ce("No")
	}
}else{
ce("No")
}


}

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

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    for(int i = 0; i < n - 1; i++){
        sum += p[i];
    }
    cout << sum + p[n-1]/2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int N, A, ans = 10000000000, i, j;

	scanf("%d", &N);
	for(i = 0; i < N; i++) {
		j = 0;
		scanf("%d", &A);
		while(A%2 == 0) {
			A/=2;
			j++;
		}
		if(j < ans) ans = j;
	}

	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
    if(a<b){
         System.out.println("a < b");
    }else if(a>b){
          System.out.println("a > b");
    }else{
        System.out.println("a == b");
    }
   }
}   


Measured memory_bytes: 26120
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct Node
{
    int x,y;
    bool operator <(Node t)const
    {
        return y<t.y;
    }
};
Node a[N];

int main()
{
    int n;cin>>n;
    for(int i=0;i<n;++i)
    {
        int x,l;
        scanf("%d%d",&x,&l);
        a[i].x=x-l;
        a[i].y=x+l;
    }
    sort(a,a+n);
    int ans=0;
    int l=-2e9;
    int i=0;
    while(i<n)
    {
        if(a[i].x>=l)
        {
            ++ans;
            l=a[i].y;
        }
        ++i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,X,T,i,j,temp,size,num,ishan,count=0,ans=0;
	cin >> N >> X >> T;
	while(count < N)
	{
		count += X;
		++ans;
	}
	cout << ans*T << endl;
	return 0;
}

Measured memory_bytes: 3624