akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

const long M = 1046527;
const long NIL = -1;
const long L = 14;

string H[M];

long getChar(char ch){
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long long getKey(string str){
	long long sum = 0, p = 1, i;
	for (long i = 0; i < str.size(); i++){
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

long h1(long key){return key % M;}
long h2(long key){return 1 + (key % (M - 1));}

long find(string str){
	long long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0) return 0;
	}
	return 0;
}

long insert(string str){
	long long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0){
			H[h] = str;
			return 0;
		}
	}
	return 0;
}

int main(){
	long n, h;
	string str, com(9, 'a');
	cin >> n;
	for (long i = 0; i < n; i++){
		cin >> com >> str;
		if (com[0] == 'i') insert(str);
		else {
			if (find(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25880
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  char c; cin >> c;
  cout << (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ? "vowel" : "consonant") << '\n';
  return 0;
}


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

//#define DEBUG

using namespace std;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    int N;
    cin >> N;
    int count = 0;
    int a;
    for(int i = 0 ; i < N ; i++){
        cin >> a;
        if( i % 2 == 0 && a % 2 == 1){
            count++;
        }
    }
    cout << count << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
long long pows(int x,int y){
  long long ans=1;
  while(y>=1){
    y--;
ans*=x;
  }
  return ans;
}
int calc(long long x){
  int c=0;
while(x>=1){
x/=10;
  c++;
}
  return c;
}
int main(void){
int n;
  scanf("%d",&n);
  long long a[n],ans[n];
  int keta[n];
  for(int i=0;i<n;i++){
	 scanf("%lld",&a[i]);
    keta[i]=calc(a[i]);
    //printf("%d\n",keta[i]);
    if(a[i]==0){
	printf("0");
      return 0;
    }
  // printf("%lld\n",ans);
  }
  ans[0]=a[0];
  int kc=keta[0];
 // printf("%lld\n",pows(10,keta[0]-1));
  for(int i=1;i<n;i++){
  //printf("%lld %lld\n",a[i-1]/(pows(10,keta[i-1]-1)),a[i]/(pows(10,keta[i]-1)));
    if(a[i-1]/pows(10,keta[i-1]-1)*a[i]/pows(10,keta[i]-1)>=10){
      kc+=keta[i];
    }
    else kc+=keta[i]-1;
   // printf("%d\n",kc);
    if(kc>19){
      printf("-1");
      return 0;
    }
	ans[i]=ans[i-1]*a[i];
   // printf("%lld\n",ans[i]); 	
    if(ans[i]>1000000000000000000){
      printf("-1");
      return 0;
    }
    
    
  }
  printf("%lld",ans[n-1]);
  return 0;
}

Measured memory_bytes: 3684
N, M = list(map(int,input().split()))
H = list(map(int,input().split()))
pairs=[]
score = [1]*(N+1)
for _ in range(M):
  A,B = list(map(int,input().split()))
  A-=1
  B-=1
  if H[A]>H[B]:
    score[B] = 0
  elif H[A]<H[B]:
    score[A] = 0
  else:
    score[A] = 0
    score[B] = 0
    
print(sum(score)-1)
  

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

int main()
{
	int X,A,B;
	cin >> X >> A >> B;
	if(B<=A){
		cout << "delicious" << endl;
	}else if(X+A >= B){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,ans=0;
    cin>>n;
    int a[n],b[n+1],c[n+1];
    for( i=0;i<n;i++)
    {
        cin>>a[i];
    }
    b[0]=0;
    for(i=0;i<n;i++)
    {
        b[i+1]=__gcd(b[i],a[i]);
    }
    c[n]=0;
    for(i=n-1;i>=0;i--)
    {
        c[i]=__gcd(c[i+1],a[i]);
    }
    for(i=n-1;i>=0;i--)
    {
    ans=max(ans,__gcd(b[i],c[i+1]));
    }
    cout<<ans;
}


Measured memory_bytes: 4684
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
#include <algorithm>

namespace Mylib{
    using namespace std;
    int RangeCalc(int a,int b){
        int tempInt;
        tempInt=(a-b)*(a-b);
        return tempInt;
    }
}

int main(void){
    using namespace std;
    int N;
    cin >> N;
    int X[N];
    int MaxR=-1;
    for(int i=0;i<N;i++){
        cin >> X[i];
        if(X[i]>MaxR)MaxR=X[i];
    }
    int tempInt;
    int calc[MaxR+1];//左から最右までの座標
    for(int i=0;i<=MaxR;i++){
        tempInt=0;//初期化
        for(int A:X){
            tempInt+=Mylib::RangeCalc(A,i);
        }
        //集会座標がiのときの記録
        calc[i]=tempInt;
    }
    int Minfatigue=calc[0];//仮の初期値
    for(int x:calc)if(Minfatigue>x)Minfatigue=x;//最小体力消費を記録
    
//for(int x:calc)cout << x << endl;
    
    cout << Minfatigue << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char S[] = new char[4], tmp;
		S = sc.next().toCharArray();
		sc.close();
		if (S.length == 3) {
			tmp = S[0];
			S[0] = S[2];
			S[2] = tmp;
		}
		System.out.print(S);
	}
}

Measured memory_bytes: 21844
function Main( input ){
 
    input = input.split( ' ' )
 
    var a = Number( input[0] )
    var b = Number( input[1] )
    var c = Number( input[2] )
 
    if( b - a === c - b ){
        console.log( 'YES' )
    } else {
        console.log( 'NO' )
    }
 
}
 
Main( require( 'fs' ).readFileSync( '/dev/stdin', 'utf8' ) )


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

/* a と b の最小公倍数を求める */
long long LCM(long long a, long long b)
{
    long long g = GCD(a, b);
    return a / g * b;
}

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

signed main()
{
    string S;
    cin >> S;
    if (S[2] == S[3])
    {
        if (S[4] == S[5])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict'

function main(input){
  const lines = input.split('\n');
  const ABCDEF = lines.shift().split(' ').map(x => parseInt(x));
  const A = ABCDEF[0];
  const B = ABCDEF[1];

  const C = ABCDEF[2];
  const D = ABCDEF[3];

  const E = ABCDEF[4];
  const F = ABCDEF[5];

  let water = [];
  let sugers = [];
  for(var i=0;i<=F;i++){
    for(var j=0;j<=F;j++){
      let c_water = 100*(A*i+B*j);
      if(c_water<=F){ water.push(c_water); }

      let suger = C*i + D*j;
      if(suger<=F){ sugers.push(suger); }
    }
  }


//--------------
  var sugerWater = []; // とりうる砂糖水の量
  var sugerWeight = []; // とりうる砂糖の量

  // とりうる砂糖水と砂糖の量を列挙
  for(var i = 0; i <= water.length; i++){
    for(var j = 0; j <= sugers.length; j++){
      var sw = water[i] + sugers[j]; // 砂糖水の量
      var meltSuger = 100 * sugers[j] / water[i]; // 水に溶ける砂糖の量
      if( sw <= F && meltSuger <= E){
        sugerWater.push(sw);
        sugerWeight.push(sugers[j]);
      }
    }
  }  

  let results = [];
  for(let i=0;i<water.length;i++){
    for(let j=0;j<sugers.length;j++){      let total = water[i] + sugers[j];
      let melt_suger = 100*sugers[j]/water[i];

      if( (total <= F) && (melt_suger <= E) ){
        results.push([water[i], sugers[j]]);
      }
    }
  }





  // 各砂糖水と砂糖の量から、濃度を求める
  var noudo = 0;
  var noudoIndex = 0;
  for(var i = 0; i < sugerWater.length; i++){
    var noudoTmp = (100 * sugerWeight[i]) / sugerWater[i]; // 砂糖水の濃度
    if(noudoTmp > noudo){
      noudo = noudoTmp;
      noudoIndex = i;
    }
  }
  
  console.log(sugerWater[noudoIndex] + ' ' + sugerWeight[noudoIndex]);

return;
//--------------


  let tmp_density = 0.0;
  let result = [];
  for(var i=0;i<results.length;i++){
      let current_density = (100*results[i][1])/(results[i][0]+results[i][1]);
      if(current_density > tmp_density){ 
        tmp_density = current_density;
        result = results[i];
      }
  }

//console.log(result);
  console.log((result[0] + result[1])+' '+result[1]);
}
main( require('fs').readFileSync( '/dev/stdin', 'utf8') );


Measured memory_bytes: 115304
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
    int N;
    double T, A;
    double H[1010];
    double abst[1010];
    double minabst=1000;
    int point=0;
    cin >> N;
    cin >> T >> A;
    for(int i=0;i<N;i++){
        cin >> H[i];
        abst[i]=fabs(T-H[i]*0.006-A);
        if(abst[i]<minabst){
            minabst=abst[i];
            point=i+1;
        }
    }
    cout << point << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%MOD


ll dp[3001];

int main(){
    ll N,S; cin>>N>>S;
    vec d(N);
    rep(i,N) cin>>d[i];
    ll ans=0;
    rep(i,N) {
        if(d[i]==S) ADD(ans,(i+1)*(N-i));
        if(d[i]<S) {
            ADD(ans,dp[S-d[i]]*(N-i)%MOD);
            for(int j=S-d[i]-1; j>0; j--){
                ADD(dp[j+d[i]],dp[j]);
            }
            ADD(dp[d[i]],i+1);
        }
    }
    cout<<ans<<endl;
}

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

int main(){
    int A, B, M;
    std::cin >> A >> B >> M;
    std::vector< int > priceA(A);
    std::vector< int > priceB(B);
    for(int i=0; i<A; i++){
        std::cin >> priceA[i];
    }
    for(int i=0; i<B; i++){
        std::cin >> priceB[i];
    }
    std::vector< std::vector< int > > pricedown(M, std::vector< int >(3));
    for(int i=0; i<M; i++){
        std::cin >> pricedown[i][0] >> pricedown[i][1] >> pricedown[i][2];
    }
    
    int priceminA = *std::min_element(priceA.begin(), priceA.end());
    int priceminB = *std::min_element(priceB.begin(), priceB.end());
    int pricemin = priceminA + priceminB;
    
    for(int i=0; i<M; i++){
        int currentprice = priceA[pricedown[i][0] - 1] + priceB[pricedown[i][1] - 1] - pricedown[i][2];
        if(currentprice < pricemin){
            pricemin = currentprice;
        }
    }
    std::cout << pricemin << std::endl;
    
}


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

int main() {

    int m1, m2;
    int d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;


    if(m1 == m2) {
        cout << 0 << endl;
        return 0;
    }


    if(d2 == 1) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }




	return 0;
}

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

int main() {
	int n;
	cin>>n;
	if(n==1)
	{
	    cout<<"0";
	    return 0;
	}
	int h[n];
	for(int i=0;i<n;i++) cin>>h[i];
	int dp[n]={0};
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++) {
	    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]));
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

//prototype
int main(void);

//main
int main(void){

  long n, i;
  char str_n[10000];

  scanf("%ld", &n);

  for (i = 3; i <= n; i++) {

    sprintf(str_n, "%d", i);  //convert to string

    if(i % 3 == 0 || strstr(str_n, "3") != NULL){
      printf(" %ld", i);
    }

  }

  printf("\n");
  
  return 0;
  
}




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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



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

	int a[2][100];
	REP(i, 2) {
		REP(j, n) {
			cin >> a[i][j];
		}
	}

	int sum = a[0][0];
	REP(i, n) {
		sum += a[1][i];
	}

	int max = sum;

	FOR(i,1, n) {
		sum = sum + a[0][i] - a[1][i - 1];
		if (sum > max) {
			max = sum;
		}
	}

	ANS(max);
	



	return 0;
}



Measured memory_bytes: 256
program hi;
type ars = array[1..200000] of string[10];
var 
    n, i, cnt: longint;
    s, tmp: ars;
 
procedure mSort(var a, tmp: ars; l, r: longint);
var m, i, i1, i2: longint;
begin
    if l < r then begin
        m := (l + r) div 2;
        mSort(a, tmp, l, m);
        mSort(a, tmp, m + 1, r);
        i := l; i1 := l; i2 := m + 1;
        while (i1 <= m) and (i2 <= r) do begin
            if a[i1] <= a[i2] then begin
                tmp[i] := a[i1];
                inc(i1);
            end else begin
                tmp[i] := a[i2];
                inc(i2);
            end;
            inc(i);
        end;
        while i1 <= m do begin
            tmp[i] := a[i1];
            inc(i1); inc(i);
        end;
        while i2 <= r do begin
            tmp[i] := a[i2];
            inc(i2); inc(i);
        end;
        for i := l to r do 
            a[i] := tmp[i];
    end;
end;
 
begin
    readln(n);
    for i := 1 to n do 
        readln(s[i]);
    mSort(s, tmp, 1, n);
    cnt := 1;
    for i := 1 to n - 1 do 
        if s[i] <> s[i + 1] then
            inc(cnt);
    writeln(cnt);
end.

Measured memory_bytes: 4508
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  string s;
  cin >> s;
  int res = 0;
  rep(i, s.size()) res += s[i] != "CODEFESTIVAL2016"[i];
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int x;
  cin>>x;
  ll sum = 0;
  int j = 1;
  while(sum<x){
    sum+=j;
    j++;
  }
  cout<<j-1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){
    return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}

int main(void){
    ll n,r;
    scanf("%lld%lld",&n,&r);
    // ll [n];
    // for(i=0;i<n;i++){
    //     scanf("%lld",&[i]);
    // }
    if(n>=10){
        printf("%lld\n",r);
    }else{
        printf("%lld\n",r+100*(10-n));
    }
    // printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin>>s){
        int len=s.length()-8;
        for(int i=0;i<len;++i) cout<<s[i];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M; cin >> N >> M;
    vector<int> A(M); for (auto& a : A) cin >> a;
    vector<int> B = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<string> S(N+1);
    for (int i = 1; i < N + 1; i++) {
        for (int a : A) {
            string newstr;
            if (i - B[a] == 0) {
                newstr = (char)('0' + a);
            } else if (i - B[a] > 0 && !S[i - B[a]].empty()) {
                string s {(char)('0' + a)};
                merge(begin(S[i - B[a]]), end(S[i - B[a]]), begin(s), end(s),
                      back_inserter(newstr), std::greater<char>());
            }
            if (newstr.size() > S[i].size()
                || (newstr.size() == S[i].size() && newstr > S[i])) {
                S[i] = newstr;
            }
        }
    }
    cout << S[N] << endl;
    return 0;
}


Measured memory_bytes: 49280
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

int masu[1050][1050] = {0};

int main()
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    rep(i, h){
        rep(j, w){
            if (j < a && i < b){
                masu[i][j] = 1;
            } else if (j >= a && i >= b){
                masu[i][j] = 1;
            }
        }
    }


    rep(i, h){
        rep(j, w){
            cout << masu[i][j];
        }
        cout << endl;
    }    

}



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

int main(){
  int a, b;
  cin >> a >> b;
  if(a <= b){
    for(int i=0; i<b; i++){
    	cout << a;	
    }
  }
  else if (b < a){
  	for(int i=0; i<a; i++){
    	cout << b;	
    }
  	}
}


Measured memory_bytes: 3596
while True:
	h,w=map(int,input().split())
	if h==w==0:break
	for hh in range(h):
		ol=''
		for ww in range(w):
			if hh == h - 1 and ww == w - 1:
				ol+='#\n'
			elif hh == 0 or ww == 0 or hh == h - 1 or ww == w - 1:
				ol+='#'
			else:
				ol+='.'
		print(ol)

Measured memory_bytes: 7668
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> counts(100001, 0);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    for (int ai = a - 1; ai <= a + 1; ++ai) if (ai > 0) ++counts[ai];
  }
  int max_count = 0;
  for (int i = 0; i < counts.size(); ++i) {
    if (max_count < counts[i]) max_count = counts[i];
  }
  cout << max_count << endl;
  return 0;
}

Measured memory_bytes: 640
// {{{ Headers
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

using namespace std;
// }}}

typedef long long int64;
const int INF = 0x3f3f3f3f;
const int64 LINF = (int64) 1e15;
template <class T> inline int len (const T &a) { return a.size (); }
#define ALL(x) (x).begin(), (x).end()

int64 dp [105][100 * 1000 + 5];
int v [100 * 1000 + 5];
int w [100 * 1000 + 5];
int N, W;

int
main () {
    scanf ("%d %d", &N, &W);
    for (int i = 0; i < N; i++) scanf ("%d %d", w + i, v + i);
    for (int i = 0; i <= N; i++)
        for (int j = 0; j <= 100000; j++)
            dp [i][j] = LINF;

    dp [0][0] = 0;
    for (int i = 1; i <= N; i++)
        for (int j = 0; j <= 100000; j++) {
            dp [i][j] = dp [i - 1][j];
            if (j >= v [i - 1])
                dp [i][j] = min (dp [i][j], dp [i - 1][j - v [i - 1]] + w [i - 1]);
        }

    int ret = 0;
    for (int j = 0; j <= 100000; j++)
        if (dp [N][j] <= W)
            ret = max (ret, j);

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


#ifdef LOCALHOST
	cerr << "time: " << (int64) clock () * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
    return 0;
}



Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin>>n;
  ll a[n+1];
  for(int i=0;i<n;i++){
    cin>>a[i];
      
  }
  ll f=0;
   for(int i=0;i<n;i++){
     if(a[i]%2==0){
       if(a[i]%3==0||a[i]%5==0)
         f=0;
       else{
         f=1;
       break;}
     }
     if(f==1){
       break;}
   }
  if(f==0)
 cout<<"APPROVED"<<endl;
     else
     cout<<"DENIED"<<endl;
     }
       

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf 9e18
#define mod 1000000007
#define mod1 998244353
long long int power(long long int a,long long int n,long long int m) ;
 long long int power(long long int a,long long int n,long long int m)
{  if(n==0)
   return 1 ;
   long long int x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}


int main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,o;
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cin>>n ;
   x=100 ;
   a=0 ;
   while(x<n)
   {
       a++ ;
       x+=x/100 ;

   }
   cout<<a ;
   return 0; }


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }

  int ans = v[0] + k - v[n - 1];
  for (int i = 0; i < n - 1; i++) {
    ans = max(ans, v[i + 1] - v[i]);
  }

  cout << k - ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	string s,t;
	cin>>s>>t;
	ll res=0;
	for(ll i=0;i<ll(s.length());i++)
	res+=(s[i]!=t[i]);
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
    solve();		
}


Measured memory_bytes: 3812
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int h = Integer.parseInt(in.next());
            int w = Integer.parseInt(in.next());
            char[][] s = new char[h][w];
            for (int i = 0; i < h; i++) {
                s[i] = in.next().toCharArray();
            }
            boolean ans = true;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (s[i][j] == '#') {
                        if (s[Math.min(i + 1, h - 1)][j] == '.' && s[i][Math.min(j + 1, w - 1)] == '.' && s[Math.max(i - 1, 0)][j] == '.' && s[i][Math.max(j - 1, 0)] == '.') {
                            ans = false;
                            break;
                        }
                    }
                }
            }

            // 出力
            if (ans) {
                out.println("Yes");
                return;
            }
            out.println("No");

        }

    }
}



Measured memory_bytes: 21844
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;
 
/*
 
N:0
W:1
S:2
E:3
 
*/
 
void main()
{
    auto hwk = readln.split.to!(int[]);
    auto H = hwk[0];
    auto W = hwk[1];
    auto K = hwk[2];
    auto xy = readln.split.to!(int[]);
    auto sy = xy[0]-1;
    auto sx = xy[1]-1;
    auto gy = xy[2]-1;
    auto gx = xy[3]-1;
 
    auto MAP = new char[][H];
    foreach (i; 0..H) MAP[i] = readln.chomp.to!(char[]);
 
    auto G = new int[][][](H, W, 4);
    foreach (i; 0..H) {
        foreach (j; 0..W) {
            if (MAP[i][j] == '@') continue;
            if (i > 0 && MAP[i-1][j] != '@') {
                G[i][j][0] = G[i-1][j][0] + 1;
            }
            if (j > 0 && MAP[i][j-1] != '@') {
                G[i][j][1] = G[i][j-1][1] + 1;
            }
        }
    }
    foreach_reverse (i; 0..H) {
        foreach_reverse (j; 0..W) {
            if (MAP[i][j] == '@') continue;
            if (i < H-1 && MAP[i+1][j] != '@') {
                G[i][j][2] = G[i+1][j][2] + 1;
            }
            if (j < W-1 && MAP[i][j+1] != '@') {
                G[i][j][3] = G[i][j+1][3] + 1;
            }
        }
    }
 
    auto DP = new int[][](H, W);
    foreach (ref dp; DP) dp[] = int.max;
 
    auto ss = [[sx, sy, 0, -1]];
    while (!ss.empty) {
        auto h = ss[0];
        ss = ss[1..$];
        auto x = h[0];
        auto y = h[1];
        auto c = h[2];
        auto p = h[3];
 
        foreach (i, d; [[0, -1], [-1, 0], [0, 1], [1, 0]]) {
            if (G[y][x][i] == 0) continue;
            if ((i == 0 && p == 2) || (i == 1 && p == 3) || (i == 2 && p == 0) || (i == 3 && p == 1)) continue;
            foreach (n; 1..min(K+1, G[y][x][i]+1)) {
                auto dx = x + n * d[0];
                auto dy = y + n * d[1];
                if (DP[dy][dx] == c) continue;
                if (DP[dy][dx] < c) break;
                DP[dy][dx] = c;
 
                if (dx == gx && dy == gy) {
                    writeln(c+1);
                    return;
                }
 
                ss ~= [dx, dy, c+1, i.to!int];
            }
        }
    }
    writeln(-1);
}

Measured memory_bytes: 109628
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long n;
  cin>>n;
  long long a[n], b[n];
  REP(i, n) cin>>a[i]>>b[i];
  typedef pair<long long, long long> P;
  map<P, long long> cnt;
  for(long long i = 0; i < n; i++){
    if(a[i] == 0 && b[i] == 0){
      cnt[P(a[i], b[i])]++;
      continue;
    }
    if(a[i] == 0){
      cnt[P(0, 1)]++;
      continue;
    }
    if(b[i] == 0){
      cnt[P(1, 0)]++;
      continue;
    }
    long long g = gcd_(abs(a[i]), abs(b[i]));
    a[i] /= g; b[i] /= g;
    if(a[i] < 0){
      a[i] = -a[i];
      b[i] = -b[i];
    }
    cnt[P(a[i], b[i])]++;
  }
  
  long long ans = 1;
  long long extra = cnt[P(0, 0)];
  //long long c = 0;
  for(auto p: cnt){
    if(p.second < 0) continue;
    if(p.first.first == 0 && p.first.second == 0) continue;
    long long coA = p.first.second;
    long long coB = -p.first.first;
    if(coA < 0){
      coA = -coA;
      coB = -coB;
    }
    long long coeff = mod(po(2, p.second) + po(2, cnt[P(coA, coB)]) - 1);
    cnt[P(coA, coB)] = -1;
    ans *= coeff;
    ans = mod(ans);
  }
  
  ans -= 1;
  ans = mod(ans);
  ans += extra;
  ans = mod(ans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31540
#include <iostream>
#include <string>
#include <climits>
using namespace std;

int main()
{
	int N = 0;
	string S;
	cin >> N;
	cin >> S;

	int x = 0;
	int max_x = INT_MIN;
	for(int i = 0; i < N; i++){
		max_x = max(x, max_x);
		if(S[i] == 'I') x++;
		else x--;
	}
	max_x = max(x, max_x);
	cout << max_x << endl;

	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

ans = []

for h in range(H - 1):
    for w in range(W):
        if A[h][w] % 2 == 1:
            A[h][w] -= 1
            A[h + 1][w] += 1
            ans.append((h, w, h + 1, w))

for w in range(W - 1):
    if A[H - 1][w] % 2 == 1:
        A[H - 1][w] -= 1
        A[H - 1][w + 1] += 1
        ans.append((H - 1, w, H - 1, w + 1))

print(len(ans))
for h, w, x, y in ans:
    print(h + 1, w + 1, x + 1, y + 1)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    string s; cin >> s;
    if(s.back() == 's') s += "es";
    else s += "s";
    cout << s << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

#define ar array
#define ff first
#define ss second
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define f0(i, n) for(int i = 0; i < n; ++i)
#define fo(i, k, n) for(int i = k; i < n; ++i)
#define rf0(n, i) for(int i = n-1; ~i; --i)
#define rfo(n, k, i) for(int i = n-1; i >= k; --i)
#define Im_speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

//ifstream f("date.in");
//ofstream g("date.out");

const int nax = 1e9 + 7;
const int mod = 1e9 + 7;
const int inf = (1 << 30);
const ld PI = 3.1415926535897932384626433832795;


int main() {
    clock_t _clock = clock();
    Im_speed;

    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    int cnt = 0;
    while(b <= a) {
        b *= 2;
        ++cnt;
    }
    while(c <= b) {
        c *= 2;
        ++cnt;
    }
//    cout << cnt;
    cout << (cnt <= k ? "Yes" : "No");
}


Measured memory_bytes: 3632
def main():
    a, b = map(int, input().split())

    if 0 < a:
        print("Positive")
    elif 0 <= b:
        print("Zero")
    else:
        if (b-a+1) % 2 == 0:
            print("Positive")
        else:
            print("Negative")


if __name__ == '__main__':
    main()


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

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

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let n: i64 = read();
    let k: i64 = read();

    println!("{}", min(n % k, k - (n % k)));
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
int main(){
    long A,B;
    std::cin>>A>>B;
    long m = std::min(A,B);
    long n = std::max(A,B);
    for(int i = m; i < n; i++){
        if(abs(m-i)==abs(n-i)){
            std::cout << i << std::endl;
            return 0;
        }
    }
    std::cout << "IMPOSSIBLE" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
void input() {
  int x, y, z;
  cin >> N >> M;
  ;
}
void solve() {
  cout << (N + M) % 24 << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main() {
  int n; cin >> n;
  map<string, int> red;
  while (n--) {
    string key; cin >> key;
    red[key]++;
  }
  
  int m; cin >> m;
  map<string, int> blue;
  while (m--) {
    string key; cin >> key;
    blue[key]++;
  }
  
  int answer = 0;
  for (pair<string, int> word : red) {
    if (blue.count(word.first)) answer = max(answer, word.second - blue.at(word.first));
    else answer = max(answer, word.second);
  }
  
  cout << answer << endl;
}

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


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
    ll mx=1001001;
   vector<bool>isprime(mx,true);
   isprime[0]=false;isprime[1]=false;
   for(ll i=2;i<mx;i++) {
       if (isprime[i]) {
           for (ll j = i * 2; j < 1e6; j += i) {
               isprime[j] = false;
           }
       }
   }
   vector<int>a(mx,0);
    for (int i = 0; i < mx; ++i) {
        if(i%2==0)continue;
        if(isprime[i]&&isprime[(i+1)/2])a[i]++;
    }
    vector<ll>sum(mx+1,0);
    for (int i = 0; i < mx; ++i) {
        sum[i+1]=sum[i]+a[i];
    }
    ll q;cin >>q;
    for (int k = 0; k < q; ++k) {
        ll l,r;cin >>l>>r;
        cout <<sum[r+1]-sum[l]<<endl;
    }
}


Measured memory_bytes: 14956
#include<bits/stdc++.h>
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
string s;
getline(cin,s);int i=0;
while(s[i]!=' ')
{i++;}
cout<<"A"<<s[i+1]<<"C";


return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn=123;
int m,n,x,c[maxn],a[maxn][maxn],sum[maxn],mini=INT_MAX,cost;
void dfs(int cur){
	if(cur==n+1){
		bool bad=0;
		for(int i=0;i<m;i++)
			if(sum[i]<x)bad=1;
		if(bad==0){
			mini=min(mini,cost);
		}
		return;
	}
	for(int i=0;i<m;i++)sum[i]+=a[cur][i];
	cost+=c[cur];
	dfs(cur+1);//选 
	for(int i=0;i<m;i++)sum[i]-=a[cur][i];
	cost-=c[cur];
	dfs(cur+1);//不选 
}
int main(){
	scanf("%d%d%d",&n,&m,&x);
	for(int i=0;i<n;i++){
		scanf("%d",&c[i]);
		for(int j=0;j<m;j++)scanf("%d",&a[i][j]);
	}
	dfs(0);
	if(mini==INT_MAX)printf("%d",-1);
	else printf("%d",mini);
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++,puts(""))
		for(int j=i+1;j<n;j++){
			int t=1,x=i,y=j;
			while((x&1)==(y&1))x>>=1,y>>=1,++t;
			printf("%d ",t);
		}
	return 0;
}

Measured memory_bytes: 512
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


A = read_a_int()
B = read_a_int()

ls = [1, 2, 3]
ls.remove(A)
ls.remove(B)

print(ls[0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ld dp[311][311][311];
int cnt[3];

bool valid(int x, int y, int z)
{
	return (x>=0&&y>=0&&z>=0);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; x--; cnt[x]++;
	}
	dp[0][0][0]=0;
	for(int k=0;k<=cnt[2];k++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int i=0;i<=n;i++)
			{
				if(i==0&&j==0&&k==0) continue;
				dp[i][j][k]=1;
				if(i>0) dp[i][j][k]+=ld(i)/ld(n)*dp[i-1][j][k];
				if(j>0) dp[i][j][k]+=ld(j)/ld(n)*dp[i+1][j-1][k];
				if(k>0) dp[i][j][k]+=ld(k)/ld(n)*dp[i][j+1][k-1];
				dp[i][j][k]*=ld(n)/ld(i+j+k);
				//cerr<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
			}
		}
	}
	cout<<fixed<<setprecision(15)<<dp[cnt[0]][cnt[1]][cnt[2]]<<'\n';
}


Measured memory_bytes: 456960
#include <iostream>
#include <stdio.h>
using namespace std;

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

    int H, W;
    string s = "";
    while(1){
        cin >> H >> W;
        if(H == 0 and W == 0){
            break;
        }else{
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    s += "#";
                }
                cout << s << endl;
                s = "";
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3164
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	

	private static void solve(){
		//Implement solution here.
		double L = nd();
		double result = L*L*L/27D;
		System.out.println(BigDecimal.valueOf(result).toPlainString());
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = LINF;
  rep(i, 1<<n) {
    if (__builtin_popcount(i) != k)
      continue;
    ll sum = 0, prev = 0;
    rep(j, n) {
      if (i>>j & 1) {
        sum += max(prev+1-a[j], 0LL);
        prev++;
      }
      chmax(prev, a[j]);
    }
    chmin(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#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 a[3];
  rep(i, 3) cin >> a[i];
  if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0) cout << 0 << endl;
  else {
    sort(a, a + 3);
    cout << (ll)a[0] * a[1] << endl;
  }
  return 0;
}

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

#define endl '\n'
#define int long long

const int N = 1e5 + 9;
int n;
int memo[N], h[N];

int dp(int id) {
	if(id >= n) return 1e9;
	if(id == n - 1) return 0;
	int &ans = memo[id];
	if(ans != -1) return ans;
	ans = min(dp(id + 1) + abs(h[id + 1] - h[id]), dp(id + 2) + abs(h[id] - h[id + 2]));
	return ans;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	memset(memo, -1, sizeof memo);
	cin >> n;
	for(int i = 0; i < n; i ++) cin >> h[i];
	cout << dp(0) << endl;


	return 0;
}

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

const int N = 2e5 + 5;

int v[N];
bool f[N];

int n, k;

int main() {
#ifdef HOME
	freopen("agc6b.in", "r", stdin);
	freopen("agc6b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	if (k == 1 || k == 2 * n - 1)
		cout << "No\n";
	else {
		cout << "Yes\n";
		f[k - 1] = f[k] = f[k + 1] = true;
		v[n - 1] = k - 1, v[n] = k, v[n + 1] = k + 1;

		if (n + 2 <= 2 * n - 1 && k - 2 >= 1)
			v[n + 2] = k - 2, f[k - 2] = true;
		if (n - 2 >= 1 && k + 2 <= 2 * n - 1)
			v[n - 2] = k + 2, f[k + 2] = true;

		for (int i = 1, p = 1; i <= 2 * n - 1; ++i) if (!v[i]) {
			while (f[p]) ++p;
			f[p] = true;
			v[i] = p; }

		for (int i = 1; i <= 2 * n - 1; ++i)
			cout << v[i] << '\n'; }

	return 0; }


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


int main(){
  int n, m, a, b;
  string str;
  cin >> n ;
  int i, j, k;
  int ans;

  m = n;
  a = 0;
  for(i = 0; i < 9; i++){
    a += m % 10;
    m /= 10;
  }
  if(n % a == 0){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  // cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256