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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int x, a;
  cin >> x >> a;
  cout << (x < a ? "0" : "10") << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    if (B - A <= 0) { cout << "delicious" << endl; }
    else {
        if (B - A <= X) { cout << "safe" << endl; }
        else { cout << "dangerous" << endl; }
    }

}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll ans = 1e16;
    int N,M;
    ll X;
    cin >> N >> M >> X;
    static ll A[15][15] = {};
    vector<ll> C(15);
    REP(i,N){
        cin >> C[i];
        REP(j,M){
            cin >> A[i][j];
        }
    }
    
    for (int b = 0; b < (1<<N); b++){
        vector<ll> x(M);
        ll nans = 0;
		REP(i,N){ //bit loop
			if (b & (1<<i)){ //i-th digit(bitにi-thのフラグが立っているかどうか)
                REP(k,M){
                    x[k] += A[i][k];
                }
                nans += C[i];
			}
		}

        bool ok = true;
        REP(k,M){
            if (x[k] < X) ok = false;
        }

        if (ok) chmin(ans,nans);
	}

    if (ans == 1e16){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int N, K;
	string S;
	cin >> N >> K >> S;

	vector<int> vec;
	vec.push_back(0);
	for(int i = 1; i < N; i++){
		if(S[i] != S[i-1]) vec.push_back(i);
	}

	int res;
	for(int i = 0; i < (int)vec.size(); i++){
		int l = vec[i];
		int r;
		
		if(S[l] == '0'){
			r = (i+2*K < vec.size() ? vec[i+2*K] : N);
		}else{
			r = (i+2*K+1 < vec.size() ? vec[i+2*K+1] : N);
		}
		res = max(res, r - l);
	}

	cout << res << '\n';
		
	return 0;
}

Measured memory_bytes: 1020
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2
3 5 2
4 5
---+/
/+---test
3
5 6 3 8
5 100 8
---+/
/+---test
2
100 1 1
1 100
---+/

void main(string[] args) {
  readln;

  auto A = readln.split.map!(to!long).array;
  auto B = readln.split.map!(to!long).array;

  size_t ans;
  foreach (i, b; B) {
    auto n1 = min(b, A[i]);
    b -= n1;

    auto n2 = min(b, A[i+1]);
    A[i+1] -= n2;

    ans += n1 + n2;
  }
  ans.writeln;
}


Measured memory_bytes: 10056
#include<stdio.h>

void trace(int A[], int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertSort(int A[], int N){
  int j, i ,v;
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}
    
int main(){
  int N,i,j;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  trace(A,N);
  insertSort(A,N);
  return 0;
}



Measured memory_bytes: 2040
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

bool** table;
int** dp;
int N;

int recursive(int left,int right){

	if(dp[left][right] != -1)return dp[left][right]; //?????¢???????????´???
	if((right-left+1)%2 == 1){ //??????????\???°?????´???
		return dp[left][right] = max(recursive(left,right-1),recursive(left+1,right));
	}
	if(table[left][(right-left+1)/2] == true)return dp[left][right] = right-left+1; //left???right?????¨????¶?????????´???
	if(right == left+1 && table[left][1] == false)return dp[left][right] = 0;

	for(int i = left+1; i <= right-2; i++){
		dp[left][right] = max(dp[left][right],recursive(left,i)+recursive(i+1,right));
	}
	return dp[left][right];
}

int main(){

	int data[301];
	table = new bool*[301]; //table[left][right] = left???????§?????????????2*right??????????????¨?¶??????§??????????????????
	dp = new int*[301]; //?????????????????????????????§?¶????????????°
	for(int i = 0; i <= 300; i++){
		table[i] = new bool[151];
		dp[i] = new int[301];
	}

	bool FLG;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		if(N <= 1){
			printf("0\n");
			continue;
		}

		//?¶??????????????????????????????????
		for(int i = 0; i <= N; i++){
			for(int k = 0; k <= N/2; k++)table[i][k] = false;
			for(int k = 0; k <= N; k++){
				if(i == k)dp[i][k] = 0;
				else{
					dp[i][k] = -1;
				}
			}
		}

		for(int i = 1; i <= N; i++)scanf("%d",&data[i]);

		//????????????2???????¨?
		for(int i = 1; i <= N-1; i++){
			if(abs(data[i+1]-data[i]) <= 1)table[i][1] = true;

		}

		//?¶??????????????????????????¨????
		for(int length = 4; length <= N; length += 2){ //??????????????????
			for(int left = 1; left+length -1 <= N; left++){ //??????????????????
				FLG = false;

				if(table[left+1][(length-2)/2] == true && abs(data[left] - data[left+length-1]) <= 1)FLG = true;//??????????????£?????????length-2??????????¶????????????????????????¨??????+length-1?????´???????????????????¶?????????´???

				if(!FLG){
					for(int i = 2; i <= length-2; i += 2){
						if(table[left][i/2] == true && table[left+i][(length-i)/2] == true){
							FLG = true;
							break;
						}
					}
				}
				if(FLG){
					table[left][length/2] = true;
				}
			}
		}

		printf("%d\n",recursive(1,N));
	}

	return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
string s,t;
vector<pair<string,int> >v;
int main()
{
    cin>>s>>t;
    int l=t.length();
    for(int i=0;i<s.length()-l+1;i++)
    {
        string tmp=s.substr(i,l);
        v.pb(mp(tmp,i));
    }
    for(int i=v.size()-1;i>=0;i--)
    {
        string tmp=v[i].first;
        int beg=v[i].second;
        bool same=1;
        int k=0;
        for(int j=beg;j<beg+l;j++)
        {
            if(s[j]!='?'&&s[j]!=t[k])
            {
                same=0;
                break;
            }
            k++;
        }
        if(!same)
            continue;
        k=0;
        for(int j=beg;j<beg+l;j++)
            s[j]=t[k],k++;
        for(int j=0;j<s.size();j++)
            if(s[j]=='?')
                s[j]='a';
        cout<<s;
        return 0;
    }
    puts("UNRESTORABLE");
    return 0;
}

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

int main(int argc, char** argv)
{
    int N;
    std::cin >> N;
    std::vector<int> vW;
    int sum1=0;
    for(int i=0;i<N;i++)
    {
        int W;
        std::cin >> W;
        vW.push_back(W);
        sum1+=W;
    }
    int min=sum1;
    int sum2=0;
    for(int i=0;i<N;i++)
    {
        sum1 -= vW[N-1-i];
        sum2 += vW[N-1-i];
        if(min > abs(sum1-sum2)){min = abs(sum1-sum2);}
        else{break;}
    }

    std::cout << min;
    
    return 0;
}

Measured memory_bytes: 256
K = int(input())

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


if A[-1] != 2:
    print(-1)
    exit()

big = 2
small = 2
for i in reversed(range(K)):
    """
    smallのときにai人組つくると脱落者なし
    bigのときにai人組作るとai-1人脱落

    """


    # smallは元のsmall以上かつ、脱落者なし
    """
    ・smallはaiで割り切れる（脱落者なし）
    ・元のsmall以上の値
    """

    if small // A[i] > 0 and small % A[i] > 0:
        small = (small // A[i] + 1) * A[i]
    elif small // A[i] > 0 and small % A[i] == 0:
        pass
        #small = small
    elif small // A[i] == 0:
        small = A[i] 
        
    # bigは元のbig以上かつ、脱落者がai-1
    big = (big // A[i]) * A[i] + A[i] - 1

    if big < small:
        print(-1)
        exit()


print(small, big)


Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

int gcd(ll x, ll y) {
  ll M = max(x, y);
  ll m = min(x, y);
  while (M%m!=0) {
    ll p = M % m;
    M = m;
    m = p;
  }
  return m;
}

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> list(k+1);
  ll sum = 0;
  ll t = 1;
  ll cc = 1;
  ll c = 1;
  for (int i = k; i >0; i--) {
    if (t != k / i) {
      t = k / i;
      cc = r(t, n) % mod;
      c = cc;
    }
    else {
      c = cc;
    }
    ll ii = 2 * i;
    while (ii <= k) {
      c -= list[ii];
      c %= mod;
      ii += i;
    }
    list[i] = c;
    c *= i % mod;
    sum += c;
    sum %= mod;
  }
  if (sum < 0) {
    sum += mod;
  }
  printf("%lld\n", sum);
} 

Measured memory_bytes: 4060
package main

import (
	"fmt"
)

func main() {
	var _S string
	fmt.Scanf("%s", &_S)
	S := []rune(_S)
	a := 0
	for i := 0; i < 3; i++ {
		switch S[i] {
			case 'a': a += 1
			case 'b': a += 2
			case 'c': a += 3
		}
	}
	if a == 6 {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
	return
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        for (int i = 1; i < 3; i ++){
            if (str.charAt(0) != str.charAt(i)){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21844
s=input()
n=len(s)
def dfs(i,f):
    if i==n-1:
        return sum(list(map(int,f.split("+"))))

    return dfs(i+1,f+s[i+1])+dfs(i+1,f+"+"+s[i+1])
print(dfs(0,s[0]))

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

int main() {
int n,l;
cin >> n >> l;
int defaul=(l-1)*n+n*(n+1)/2;
int res=500;
int ans;
for(int i=1;i<n+1;i++){
    if(abs(l+i-1)<res){
    res=abs(l+i-1);
    ans=l+i-1;}
}
cout << defaul - ans << endl;
}


Measured memory_bytes: 256
#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;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
 
 
 
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> L(m);
  vector<int> R(m);
  REP(i,m){
    int l, r;
    cin >> l >> r;
    L[i] = l;
    R[i] = r;
  }
 
  int lmax = 0;
  int rmin = 100005;
  REP(i,m){
    lmax = max(lmax, L[i]);
    rmin = min(rmin, R[i]);
  }
 
  int ans;
  if(rmin - lmax < 0) ans = 0;
  else ans = rmin - lmax + 1;
  cout  << ans << endl;
  return 0;
}

Measured memory_bytes: 4032
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  


for(i=1;i<=n;i++){
v=A[i];
j=i-1;
while(j >= 0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      }
     A[j+1]=v;
 
 trace(A,n);
}
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

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

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

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

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

void solve()
{
    COMinit();
    int n, k;
    cin >> n >> k;
    rep(i, k)
    {
        int r = i + 1;
        ll ans = 0;
        if (n - k + 1 >= r)
        {
            ans = COM(n - k + 1, r) % M;
            ans %= M;
            if (k-r+r-1>=r-1)
            {
                ans *= COM(k-r+r-1,r-1) % M;
            }
            ans %= M;
        }
        cout << ans << endl;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

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

int main(){
  string S;
  cin >> S;
  vector<int> N(4);
  
  for(int i=0;i<N.size();i++) N[i] = atoi(S.substr(i,1).c_str());
  
  int num = 0;
  for(int t=0;t<(1<<3);t++){
    bitset<3> b(t);
    //cout << b << endl;
    int sum=N[0];
    for(int i=N.size()-2;i>=0;i--){
      if(b.test(i)) sum += N[3-i];
      else sum -= N[3-i];
    }
    if(sum == 7) break;
    num++;
  }
  
  bitset<3> c(num);
  
  //cout << num << ' ' << c << endl;
  
  cout << N[0];
  int n = 1;
  
  for(int i=2;i>=0;i--){
    if(c.test(i)) cout << '+' << N[n];
    else cout << '-' << N[n];
    n++;
  }
  cout << "=7" << endl;
}
  

Measured memory_bytes: 256
if ARGV[0]=="LOCAL_DEV"
  define_method("debug") do |var|
    p var
  end
else
  define_method("debug") do |var|
  end
end


N=STDIN.gets.strip.to_i
ans=[]
N.times do
  a,b=STDIN.gets.strip.split.map(&:to_i)
  a,b=b,a if a>b
  s=Math.sqrt(a*b).to_i
  s-=1 if s*s==a*b
  if a==b
    ans<<2*a-2
  elsif a+1==b
    ans<<2*a-2
  elsif s*(s+1)>=a*b
    ans<<2*s-2
  elsif s*s<a*b
    ans<<2*s-1
  end
end
ans.each do |i|
  puts i
end

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

int main(){
  int a[2]={};
  rep (i,3){
    int temp;
    cin>>temp;
    if (temp==7) a[0]++;
    else if(temp==5) a[1]++;
  }
  if (a[0]==1 && a[1]==2) YES;
  else NO;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <ctype.h>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
//整形Shift + alt + f 
int n;
int a[3];

int main(){
    cin >> n;
    int b = n;    
    a[0] = b % 10;
    b = b /10;
    a[1] = b % 10;
    b = b / 10;
    a[2] = b % 10;

    for(int i=0;i<=2;i++){
        if(a[i] == 1){
            a[i] = 9;
        }else{
            a[i] = 1;
        }
    }    

    cout << 100 * a[2] + 10*a[1] + a[0];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) -= (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int x, a;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("1.in", "r", stdin);
    cin >> x >> a;
    if (x < a) cout << 0;
    else cout << 10;

}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    auto s = sread();
    long result;
    foreach (i; 0 .. N)
    {
        uint a, b;
        foreach (c; s[0 .. i])
            a |= 1 << (c - 'a');
        foreach (c; s[i .. $])
            b |= 1 << (c - 'a');

        result.maxAssign((a & b).popcnt);
    }
    writeln(result);
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  string s; cin >> s ;
  int w ; cin >> w ;
  
  rep(i,(s.size()+w-1)/w){
    cout<<s[i*w];
  }
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
//O(n)?
signed main(){
  cioacc();
  ll n;
  cin >> n;
  multiset<ll> st;
  set<ll> sum;
  //累積和を全パターン調べるのに必要
  st.insert(0);
  ll ans = 0;
  //lastに1つ前の累積和をとる
  ll last = 0;
  //nowに現在の累積和をとる。
  ll now;
  REP(i,n){ 
    //nowを求める
    cin >> now;
    now += last;
    //これを繰り返すと、全ての組み合わせを回収可
    //本質的にそれぞれの_xC_2を求めているので
    st.insert(now);
    sum.insert(now);
    //lastを更新
    last = now;
  }
  for(auto i:sum){
    ll tmp = st.count(i);
    ans += tmp*(tmp-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 19072
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
	int r,c,i,j,d[101][101];
	
	cin >> r >> c;

	for(i=0;i<=r;i++){
		for(j=0;j<=c;j++){
			d[i][j]=0;
		}
	}
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			cin >> d[i][j];
			d[i][c]=d[i][c]+d[i][j];
			d[r][j]=d[r][j]+d[i][j];
		}
	}
	
	for(i=0;i<r;i++){
		d[r][c]=d[r][c]+d[i][c];
	}
	
	for(i=0;i<=r;i++){
		for(j=0;j<c;j++){
			cout << d[i][j] << " ";
		}
		cout << d[i][c] << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;


string s[200010];
//LL a[200010];
int main(){
	int n;
	int ans=0;
	
	cin>>n;	
	for(int i=0;i<n;i++)cin>>s[i];
	
        
	sort(s,s+n);
	for(int i=0;i<n;i++)
	{
		if(i==0)ans++;
		else if(s[i-1]!=s[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9896
N = int(input())
A = list(map(int, input().split()))
res = 1
amari = 1000000007
rgb = [0, 0, 0]

for a in A:
    cnt = 0
    j = 0
    for i in range(3):
        if rgb[i] == a:
            cnt += 1
            j = i
    rgb[j] += 1
    res *= cnt
    res %= amari

print(res)

Measured memory_bytes: 53356
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// EPSITON
	constexpr double epsilon = std::numeric_limits<double>::epsilon();
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// Digit
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
	
	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

int main(int argc,char *argv[])
{
	ll k,s;
	std::cin >> k >> s;

	auto expr = [&](const ll &x, const ll &y){ return s-(x+y); };
	
	ll ans = 0;
	for(ll x = 0;x <= k;++x)
		for(ll y = 0;y <= k;++y)
		{
			auto tmp = expr(x,y);
			if(tmp >= 0 && tmp <= k) ++ans;
		}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
string s;
bool ok[100000];//ここを終わりにできるか
int main()
{
	cin>>s;
	string a="dream";
	string b="dreamer";
	string c="erase";
	string d="eraser";
	for(ll i=0;i<s.size();i++){
		if(i==0||ok[i-1]){
			if(s.substr(i,5)==a||s.substr(i,5)==c) ok[i+4]=1;
			if(s.substr(i,7)==b) ok[i+6]=1;
			if(s.substr(i,6)==d) ok[i+5]=1;
		}
	}
	if(ok[s.size()-1]) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
using namespace std;



int main() {

	int a, b, c; cin >> a >> b >> c;
	int ans = b;
	int tasty = a + b;
	if (a + b >= c) {//cについて
		ans += c;
	}
	else {
		ans += a + b+1;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
try:
    for _ in range(1):
        a,b,c,d=map(int,input().split())
        if a>0 and c>0:
            print(b*d)
        else:
            print(max([a*c,a*d,b*c,b*d]))





    
except EOFError as e:
    print(e)


Measured memory_bytes: 76700
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b=2,c=0,d=0,e,n,m=0;
  string s;
  c(s);
  bool aa=false,ab=false,ac=false;
  if(s[0]=='A') aa=true;
  rep(i,2,s.size()-1){
    if(s[i]=='C') c++;
  }
  if(c==1) ab=true;
  rep(i,0,s.size()){
    a=s[i];
    if(97<=a && a<=122) d++;
  }
  if(d==s.size()-2) ac=true;
  if(aa==true && ab==true && ac==true) co("AC");
  else co("WA");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200005],s[200005],x[200005],tot;
int main()
{	
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x[i];
		a[x[i]]++;
	}
	for(i=1;i<=n;i++)
	{
		s[i]=(long long)a[i]*(a[i]-1)/2;
		tot+=s[i];
	}
	for(i=1;i<=n;i++)
		if(a[x[i]]-2>=0)
			cout<<tot-s[x[i]]+(a[x[i]]-1)*(a[x[i]]-2)/2<<endl;
		else
			cout<<tot-s[x[i]]<<endl;
			//cout<<tot<<endl;
	return 0;
}






Measured memory_bytes: 6784
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, m, ans;
Pair br[N];
std::vector< Pair > v[N];
std::stack<int> s;
bool vis[N], ins[N];

int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &br[i].fi, &br[i].se);
        v[br[i].fi].push_back(mp(br[i].fi, -1));
        v[br[i].se].push_back(mp(br[i].se, i));
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < v[i].size(); j++) {
            if (v[i][j].se == -1) continue;
            if (vis[br[v[i][j].se].fi]) continue;
            else {
                ans++;
                while (!s.empty()) {
                    vis[s.top()] = true;
                    s.pop();
                }
            }
        }

        for (int j = 0; j < v[i].size(); j++) {
            if (v[i][j].se == -1) {
                if (!ins[i]) s.push(i), ins[i] = true;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    bool ans = true;
    ll max_h = 0;
    rep(i, n) {
        ll h;
        cin >> h;
        if (max_h > h) ans = false;
        max_h = max(h-1, max_h);
    }
    if (ans==true) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] a;
    int i, j;
    int p, no;

    n = sc.nextInt();
    a = new int[n];
    for(i = 0;i < n;++i){
      a[i] = sc.nextInt();
      if(a[i] % 2 == 0 && a[i] != 2)a[i] = 0;
    }

    p = 0;
    no = 0;
    for(i = 0;i < n;i++){
      if(a[i] > 9){
        for(j = 3;;j+=2){
          if(a[i] % j == 0){
            no = 0;
            break;
          }
          if(j * j > a[i]){
            no = 1;
            break;
          }
        }
        if(no == 1){
          ++p;
        }
      }else{
        if(a[i] == 2 || a[i] == 3 || a[i] == 5 || a[i] == 7){
          ++p;
        }
      }
    }

    System.out.println(p);
/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 36696
a, b = (int(i) for i in input().split())
cnt = 0
for i in range(a, b+1):
    s = str(i)
    bool = True
    for j in range(len(s)//2+1):
        if not s[j] == s[len(s)-1-j]:
            bool = False
            break
    if bool:
        cnt += 1
print(cnt)

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

int main(){
    int K;
    cin >> K;
    int x = 7%K;
    set<int> s;
    int i = 1;
    while (s.count(x) == 0)
    {
        if(x == 0){
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x*10 + 7)%K;
        ++i;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 50368
#include<iostream>
using namespace std;
static const int INF=(1<<21);
int M[100][100];
void dij(int n, int d[], int color[]){
	d[0]=0;
	color[0]=1;
	int minv;
	while(1){
		minv=INF;
		int u=-1;
		for(int i=0; i<n; i++){
			if(minv>d[i] && color[i]!=2){
				u=i;
				minv=d[i];
			}
		}
		if(u==-1)
			break;
		color[u]=2;
		for(int v=0; v<n; v++){
			if(color[v] !=2 & M[u][v]!=INF){
				if(d[v]>d[u]+M[u][v]){
					d[v]=d[u]+M[u][v];
					color[v]=1;
				}
			}
		}
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			M[i][j]=INF;
		}
	}
	int k, c, u, v;
	for(int i=0; i<n; i++){
		cin>>u>>k;
		for(int j=0; j<k; j++){
			cin>>v>>c;
			M[u][v]=c;
		}
	}
	int d[n], color[n];
	for(int i=0; i<n; i++){
		d[i]=INF;
		color[i]=0;
	}
	dij(n, d, color);
	for(int i=0; i<n; i++){
		cout<<i<<" ";
		if(d[i]==INF)
			cout<<-1<<endl;
		else
			cout<<d[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long N, A; cin >> N >> A;
	string res;

	res = (N % 500 <= A) ? "Yes" : "No";

	cout << res << endl;

}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

pair<double, double> cramer(double a1, double a2, double b1, double b2, double c1, double c2) {
  double d   = a1 * b2 - b1 * a2;
  double nx1 = c1 * b2 - b1 * c2;
  double nx2 = a1 * c2 - c1 * a2;
  return mp(nx1 / d, nx2 / d);
}

double g(double x) {
  return double((int) (x * 1000)) / 1000;
}

void solve() {
  int a, b, c, d, e, f;
  while (cin >> a >> b >> c >> d >> e >> f) {
    pair<double, double> p = cramer(a, d, b, e, c, f);
    cout << prec(3) << g(p.first) << ' ' << g(p.second) << endl;
  }
}

Measured memory_bytes: 3152
from Queue import Queue
n, q = map(int, raw_input().split())
P = []
for i in xrange(n):
    x = raw_input().split()
    P.append((x[0], int(x[1])))

Q = Queue()
for x in P:
    Q.put(x)
total = 0
while not Q.empty():
    x = Q.get()
    if x[1] <= q:
        total += x[1]
        print x[0], total
    else:
        total += q
        Q.put((x[0], x[1]-q))

Measured memory_bytes: 13836
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int m,n;
int isp[1000010];
int a[2010][2010];
int dy[]={0,-1,0,1};
int dx[]={1,0,-1,0};
int dp[2010][2010];

void main2(){
	rep(i,2010)rep(j,2010){
		dp[i][j]=a[i][j]==n?isp[n]:-INF;
	}
	rep(i,2009)rep2(j,1,2009){
		rep2(k,-1,2){
			dp[i+1][j+k]=max(dp[i+1][j+k],dp[i][j]+(a[i+1][j+k]<=m && isp[a[i+1][j+k]]));
		}
	}
	int ans1=0,ans2=0;
	rep(i,2010)rep(j,2010)if(a[i][j]<=m && isp[a[i][j]]){
		if(dp[i][j]>ans1 || dp[i][j]==ans1 && a[i][j]>ans2){
			ans1=dp[i][j],ans2=a[i][j];
		}
	}
	cout<<ans1<<" "<<(ans1==0?0:ans2)<<endl;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	fill(isp,isp+1000001,1);
	isp[0]=isp[1]=0;
	rep2(i,2,1000001)if(isp[i]){
		for(int j=i*2;j<=1000000;j+=i){
			isp[j]=0;
		}
	}
	int y=1000,x=1000,d=0,cur=1;
	a[y][x]=cur;
	rep(i,INF){
		rep(j,i/2+1){
			y+=dy[d];
			x+=dx[d];
			a[y][x]=++cur;
		}
		d=(d+1)%4;
		if(cur>=1000000)break;
	}
	while(cin>>m>>n && m){
		main2();
	}
}

Measured memory_bytes: 36656
#include<iostream>
using namespace std;
int main(){
  int n,m,hana[100],taro[100],hana_sum=0,taro_sum=0,num,min,flag,set0,set1;
  cin >> n >> m;
  while(1){
    min=1000000;
    flag=0;
    hana_sum=0;
    taro_sum=0;
    if(n==0&&m==0) break;
    for(int i=0;i<n;i++){
      cin >> taro[i];
      taro_sum+=taro[i];
    }
    for(int i=0;i<m;i++){
      cin >> hana[i];
      hana_sum+=hana[i];
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        num=hana[j]-taro[i];
        if(taro_sum+num==hana_sum-num){
          flag=1;
          if(min>hana[j]+taro[i]){
            min=hana[j]+taro[i];
            set0=taro[i];
            set1=hana[j];
          }
        }
      }
    }
    if(flag==0) cout <<-1<<endl;
    else cout << set0 <<" "<<set1<<endl;
    cin >> n >> m;
  }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100005;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    bool zero=false;
    for(auto it:a)if(it==0)zero=true;
    if(zero)cout<<0<<endl;
    else{
        int res=1;
        for(auto it:a){
            res*=it;
            if(res>1000000000000000000)res=0;
        }
        cout<<(res==0?-1:res)<<endl;
    }
}

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

using ll = long long;

int main() {
  ll n, x;
  cin >> n >> x;
  
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  ll ans;
  if(a.at(0) > x){
    ans += a.at(0) - x;
    a.at(0) = x;
  }
  for(int i = 1; i < n; i++){
    if(a.at(i - 1) + a.at(i) > x){
      ans += a.at(i - 1) + a.at(i) - x;
      a.at(i) = x - a.at(i - 1);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll ans=inf;
    ll b=0;
    for(ll i=0;i<n-m+1;i++)
    {
        b=0;
        for(ll j=0;j<m;j++)
        {
            if(t[j]!=s[i+j])
                b++;
        }
        ans=min(b,ans);
    }
    cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

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

int main()
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 3620
from collections import defaultdict
N,p = map(int,input().split())
S = input()
S = S[::-1]
d = defaultdict(lambda:0)
r = 0
for i in range(N):
    r += int(S[i])*pow(10,i,p)
    r %= p
    d[r] += 1

ans = 0
for r in d:
    ans += d[r]*(d[r]-1)//2
ans += d[0]

if p==2 or p==5:
    S = S[::-1]
    ans = 0
    for i in range(N):
        if int(S[i])%p==0:
            ans += i+1

print(ans)

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

using namespace std;

int main(){
    long long N,H;
    cin>>N>>H;
    vector <long long>a(N);
    vector <long long>b(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
    	cin>>b[i];
    }
	bool t=true;
	long long a_max=0;
	long long a_m=0;
	long long b_m=0;
	long long ans=0;
	for(long long i=0 ; i<N ; i++){
		if(a[a_max]<a[i]){
			a_max=i;
		}
	}
	a_m=a[a_max];
	b_m=b[a_max];
	//a[a_max]=0;
	b[a_max]=0;
	if(b_m>=H)t=false;
	//sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	for(long long i=N-1 ; i>0 ; i--){
		if(a_m<b[i]){
			H-=b[i];
			ans+=1;
		}
		if(H<=0){
			break;
		}
		if(H<=b_m){
			ans+=1;
			H=0;
			break;
		}
	}
	if(H>0){
		while(1){
			if(H<=b_m){
				ans+=1;
				break;
			}
			ans+=1;
			H-=a_m;
			if(H<=0)break;
		}
	}
	if(t)cout<<ans<<endl;
	else cout<<1<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

typedef uint64_t ull;
typedef  int64_t sll;

static const ull MOD = 1000000007LL;

int n;
int k;
int q;

ull a[200019];

ull umin (ull a, ull b) {
	return (a < b) ? a : b;
}
ull umax (ull a, ull b) {
	return (a > b) ? a : b;
}

ull solve () {
	sll i, j, ki;
	ull res = 0;

	ull allxor = 0;
	for (i = 0; i < n; i++) {
		allxor ^= a[i];
	}
	for (i = 0; i < n; i++) {
		a[i] &= ~allxor;
	}

	ull rank = 0;
	for (i = 59; i >= 0; i--) {
		for (j = rank; j < n; j++) {
			if (a[j] & (1LL << i)) break;
		}
		if (j == n) {
			continue;
		}

		if (j > rank) a[rank] ^= a[j];
		for (j = rank + 1; j < n; j++) {
			a[j] = umin(a[j], a[j] ^ a[rank]);
		}

		rank++;
	}
	ull x = 0;
	for (i = 0; i < rank; i++) {
		x = umax(x, x ^ a[i]);
	}

	res = (x * 2) + allxor;

	return res;
}

int main(void){

	scanf("%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}

	printf("%lld\n", solve());

	return 0;
}


Measured memory_bytes: 2516
from math import log

N=int(input())

dp = [0]*(N+1)

e6 = 0
e9 = 0
for i in range(1,N+1):
  for j in range(e6,12):
    if 6**j>i:
      e6 = j-1
      break
  for j in range(e9,12):
    if 9**j>i:
      e9 = j-1
      break
  dp[i] = min(dp[i-1],dp[i-int(6**e6)],dp[i-int(9**e9)])+1
  
print(dp[-1])

Measured memory_bytes: 9528
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Apr 26 21:01:08 JST 2020
 **/

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

const Int K = 2019;
signed main() {
    std::string s;
    std::cin >> s;
    Int n = s.size();
    auto dp = make_vec<Int>(2, K, 0);
    Int ans = 0;
    REP(i, n) {
        REP(j, K) {
            Int k = (10 * j + s[i] - '0') % K;
            dp[1][k] += dp[0][j];
        }
        dp[1][s[i] - '0'] += 1;
        ans += dp[1][0];
        std::swap(dp[0], dp[1]);
        std::fill(dp[1].begin(), dp[1].end(), 0);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3772
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    S=list(input())
    T=list(input())
    SS=Counter(S).most_common()
    TT=Counter(T).most_common()

    def main():

        if len(SS)!=len(TT):
            return 'No'
        else:
            for i in range(len(SS)):
                if SS[i][1]!=TT[i][1]:
                    return 'No'
            return 'Yes'
    print(main())

resolve()

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


int main(){
	int N;
	cin>>N;
	bool color[8] ={};
	int high_rate=0;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		if(a<3200){
			color[a/400]=true;
		}
		else{
			high_rate++;
		}
	}
	int cnt = 0;
	for(int i=0;i<8;i++){
		if(color[i]==true){
			cnt++;
		}
	}
	
	cout<<max(cnt,1)<<" ";
	cout<<cnt+high_rate<<endl;
		
	
	return 0;
}

Measured memory_bytes: 256
def printAry(a)
    printf("#{a[0]}")
    for i in 1..a.length-1 do
        printf(" #{a[i]}")
    end
    printf("\n")
end


### main ###
n = STDIN.gets.to_s.to_i

a = STDIN.gets.to_s.split(" ")
a.map!(&:to_i)

flag = true
counter = 0

while flag do
    flag = false
    for i in 1..n - 1 do
        if a[i] < a[i-1] then
            buf = a[i-1]
            a[i-1] = a[i]
            a[i] = buf
            flag = true
            counter = counter + 1
        end
    end
end

printAry(a)
puts counter

Measured memory_bytes: 8716
#include <stdio.h>

#define MAX_N 2000
#define MAX_L 1000

int n;
int ls[MAX_N];
int ms[MAX_L+1];

void sort(int n) {
    for (int i = 0; i < n; i++) {
        ms[ls[i]]++;
    }

    int i = 1;
    int j = 0;
    while (i < MAX_L+1) {
        while (ms[i] > 0) {
            ls[j++] = i;
            ms[i]--;
        }
        i++;
    }
}

/*
 * Return the minimum index whose value is same or larger than the target value if exists, otherwise -1.
 *
 * l: lowest index
 * h: highest index
 * x: target value
 */
int search(int l, int h, int x) {
    if (ls[l] >= x) {
        return l;
    }

    while (h - l > 0) {
        // printf("h: %d, l: %d, mid: %d, v: %d\n", h, l, (l + h) / 2, ls[(l + h / 2)]);

        int mid = (l + h) / 2;
        if (ls[mid] < x) {
            l = mid + 1;
        } else if (ls[mid] > x) {
            h = mid;
        } else {
            h = mid;
        }
    }

    if (ls[l] < x) {
        return -1;
    }

    return l;
}

int solve(int n) {
    int count = 0;

    for (int i = n-1; i > 0; i--) {
        for (int j = i-1; j > 0; j--) {
            int a = ls[i];
            int b = ls[j];
            int min_c = a - b + 1;
            int lim_ind = search(0, j-1, min_c);
            // printf("%d %d %d\n", 0, j-1, lim_ind);
            if (lim_ind < 0) {
                break;
            }
            count += j - lim_ind;
        }
    }

    return count;
}

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

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        ls[i] = x;
    }

    sort(n);

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

    // printf("%d\n", search(0, n, 5));

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

    return 0;
}


Measured memory_bytes: 128