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

int main() {
  int k, s; cin >> k >> s;
  int ans = 0;
  for (int i = 0; i <= k; ++i) {
    if (i + k * 2 < s) continue;
    for (int j = i; j <= k; ++j) {
      if (i + j + k < s) continue;
      for (int l = j; l <= k; ++l) {
        // cout << i << " " << j << " " << l << endl;
        if (i + j + l == s) {
          if (i == j and j == l and l == i) ans++;
          else if (i == j or j == l or l == i) ans += 3;
          else ans += 6;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

int main(){
    int n;
    cin >>n;
    vector<vector<ll>> a(n,vector<ll>(n));
    rep(i,n)rep(j,n) cin >>a[i][j];

    vector<ll> val(1<<n);
    rep(mask,1<<n){
        rep(i,n)rep(j,i)if((mask>>i&1) && (mask>>j&1)) val[mask]+=a[i][j];
    }

    vector<ll> dp(1<<n,-INF);
    dp[(1<<n)-1] = 0;
    for(int mask=(1<<n)-1; mask>0; --mask){
        int nx = (mask-1)&mask;
        while(1){
            int g = mask&(~nx);
            dp[nx] = max(dp[nx], dp[mask]+val[g]);

            if(nx == 0) break;
            nx = (nx-1)&mask;
        }
    }
    cout << dp[0] << "\n";
    return 0;
}


Measured memory_bytes: 1280
#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>;
const double PI = acos(-1);

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


Measured memory_bytes: 3776
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int n = sc.nextInt();
        int m = sc.nextInt();

        int sum = 0;
        for (int i = 0; i < m; i++) {
            sum += sc.nextInt();
        }
        System.out.println(n-sum>=0 ? n-sum : -1);
    }
}


Measured memory_bytes: 46392
from collections import deque
n,m = map(int,input().split())

ab = [[] for i in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
#ab = [[int(i) for i in input().split()] for j in range(m)]
#print(ab)

ans_li = [-1]*n
ans_li[0] = 1

q = deque()

q.appendleft(0)

while len(q) > 0 :
    for i in range(len(q)):
        tmp = q.popleft()
        #print(tmp)
        for j in range(len(ab[tmp])):
            if ans_li[ab[tmp][j]] == -1:
                ans_li[ab[tmp][j]] = tmp+1
                q.append(ab[tmp][j])
                #print(q)

print('Yes')

for i in range(n-1):
    print(ans_li[i+1])

Measured memory_bytes: 37060
N, W = map(int, input().split())
values = []
weights = []
for i in range(N):
    item = list(map(int, input().split()))
    values.append(item[0])
    weights.append(item[1])
max_value = sum(values)

dp = [[float('inf') for value in range(max_value+ 1)] for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for value in range(max_value+1):
        if value >= values[i]:
            dp[i+1][value] = min(dp[i][value - values[i]] + weights[i], dp[i][value])
        else:
            dp[i+1][value] = dp[i][value]
for value in range(max_value, 0, -1):
    if dp[N][value] <= W:
        print(value)
        exit()
print(0)



Measured memory_bytes: 38140
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
 
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
 
int main(void){
    int x,a,b,c,d,i,j,k,p;
    char s[4]="+-";
    scanf("%d",&x);
    d=x%10;x/=10;
    c=x%10;x/=10;
    b=x%10;x/=10;
    a=x%10;
    if((a==b&&b==c) || (b==c&&c==d)){printf("Yes\n");}else{printf("No\n");}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define vp vector<pair<ll, ll>>
#define all(a) a.begin(), a.end()
#define pb push_back
#define pi pair<int, int>
#define pl pair<ll, ll>
#define mp make_pair
#define fi first
#define sc second
#define for0(i, n) for(ll i=0; i<n; i++) 
#define for1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ll mod = 1e9+7;

void solve(){
	int n; cin>>n;
	ll a[n], dp[n];
	for0(i, n)
		cin>>a[i];
	dp[0]=1000;
	for1(i, n-1){
		dp[i]=max(dp[i-1], dp[i-1]%a[i-1] + a[i]*(dp[i-1]/a[i-1]));
	}
	cout<<dp[n-1];
}

int main() {

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

	ll test = 1;
	//cin>>test;
	while(test--)
		solve();

	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int sum(int K){
  int a=0;
for(;K>0;K=K/10){
  a=a+K%10;
  }
  return a;
}
int main()
{
  int N,A,B,answer=0;
  scanf("%d %d %d",&N,&A,&B);
  for(;N>0;N=N-1){
    if(A<=sum(N)&&sum(N)<=B){
      answer=answer+N;
    }
  }
  printf("%d\n",answer);
  return 0;
}

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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 1e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int x; cin >> x;
    for (int i = 1; i <= 360; i++) {
        if (x * i % 360 == 0) {
            kill(i);
        }
    }
    return 0;
}


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

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

int main(void){
  int n,m;
  int a[1010], flg[1010];
  int dp[1<<12][1010];
  
  cin >> n >> m;
  for (int i=1; i<=m; i++){
    int b,f=0;
    cin >> a[i] >> b;
    flg[i]=0;
    for (int j=0; j<b; j++){
      int t; cin >> t;
      flg[i] |= 1<<(t-1);
    }
  }
  for (int i=0; i<(1<<n); i++){
    for (int j=0; j<=m; j++){
      dp[i][j] = (i==0? 0: INF);
    }
  }
  for (int i=1; i<(1<<n); i++){
    for (int j=1; j<=m; j++){
//      cout << "flg=" << flg[j] << ", ";
      dp[i][j] = MIN(dp[i][j-1], dp[i&~flg[j]][j-1]+a[j]);
//      cout << (i&~flg[j]) << "->" << i << " (" << j << ") :";
//      cout << dp[i][j] << endl;
    }
  }
  if (dp[(1<<n)-1][m]!=INF) cout << dp[(1<<n)-1][m] << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 16384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long[] A = new long[N];

        for (int i = 0 ; i < N ; i++) {
            A[i] = scanner.nextLong();
        }

        Arrays.sort(A);

        long score = A[N - 1];
        if (N == 2) {
            System.out.println(score);
            return;
        }

        for (int i = 0 ; i < N - 2 ; i++) {
//            System.out.printf("i:%d A[%d] %d%n", i, N - 2 - i / 2 , A[N - 2 - i / 2]);
            score += A[N - 2 - i / 2];
        }

        System.out.println(score);
    }
}


Measured memory_bytes: 60836
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        ArrayDeque<Proc> queue = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Proc(sc.next(), sc.nextInt()));
        }
        StringBuilder sb = new StringBuilder();
        int current = 0;
        while (queue.size() > 0) {
            Proc p = queue.poll();
            if (p.time > q) {
                p.time -= q;
                queue.add(p);
                current += q;
            } else {
                current += p.time;
                sb.append(p.name).append(" ").append(current).append("\n");
            }
        }
        System.out.print(sb);
    }
    
    static class Proc {
        String name;
        int time;
        
        public Proc(String name, int time) {
            this.name = name;
            this.time = time;
        }
    }
}


Measured memory_bytes: 71432
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);
	if((1 <= a) && (a <= 100))
		if((1 <= b) && (b <= 100))
		{
			printf("%d %d\n", a * b, 2 * a + 2 * b);
			return 0;
		}
	else return -1;
}

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

public class Main {
    static void printArray(int[] ans){
        for(int i=0; i<ans.length-1; i++) System.out.printf("%d ", ans[i]);
        System.out.printf("%d\n", ans[ans.length-1]);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = Math.max(A+B, A-B);
        ans = Math.max(ans, A*B);
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
   
    double x,y;
    cin>>x>>y;
    int ans=round((x+y)/2);
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int main(){
    string alpha;
    int n;
    string taro;
    string hanako;
    int ptaro = 0;
    int phanako = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> taro >> hanako;
        if(taro > hanako) {
            ptaro += 3;
        } else if(taro < hanako) {
            phanako += 3;
        } else {
            ptaro += 1;
            phanako += 1;
        }
        
    }
    
    cout << ptaro << " " << phanako << endl;
    
    
    return 0;
}

Measured memory_bytes: 1208
n=int(input())
A,B,C=[],[],[]
for _ in range(n):
    n = list(input().split())
    A.append([n[0], int(n[1])])
    B.append(n[0])
a=sorted(A)
C = sorted(set(B))
tmp=0
for i in C:
    count=B.count(i)
    for _ in range(B.count(i)):
        # print(A.index(A[]))
        print(A.index(a[tmp+count-1])+1)
        count-=1
    tmp+=B.count(i)

Measured memory_bytes: 3064
#include <stdio.h>
#define MAX 100

void load(int [MAX][MAX], int, int);

int main(void) {
    int i, j, k, n, m, l;
    int a[MAX][MAX], b[MAX][MAX];
    long long v;
    scanf("%d %d %d", &n, &m, &l);
    load(a, n, m), load(b, m, l);
    for(i = 0; i < n; i++) {
        for(j = 0; j < l; j++) {
            j && printf(" ");
            for(k = v = 0; k < m; k++) {
                v += a[i][k] * b[k][j];
            }
            printf("%lld", v);
        }
        printf("\n");
    }
    return 0;
}

void load(int tbl[MAX][MAX], int y, int x) {
    int i, j;
    for(i = 0; i < y; i++) {
        for(j = 0; j < x; j++) {
            scanf("%d", &tbl[i][j]);
        }
    }
}

Measured memory_bytes: 680
import bisect

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

YZ = Y*Z
BC = []
for b in B:
  for c in C:
    BC.append(b+c)

BC.sort()
def check(S):
  count = 0
  left = X*Y*Z
  for a in A:
    count += YZ - bisect.bisect_left(BC, S-a)
    left -= YZ
    if count >= K or count+left < K:
      break
  
  return count >= K



Sl = 0
Sr = A[0]+B[0]+C[0]+1

while Sr - Sl > 1:
  mid = (Sl + Sr) // 2
  if check(mid):
    Sl = mid
  else:
    Sr = mid

Ans = []
for a in A:
  for b in B:
    if a + b + C[0] < Sr:
      break
    for c in C:
      if a + b + c >= Sr:
        Ans.append(a+b+c)
      else:
        break

Ans.sort(reverse=True)
Ans = Ans + [Sl]*(K-len(Ans))
for ans in Ans:
  print(ans)

Measured memory_bytes: 54592
n = int(input())
a = list(map(int, input().split()))
ans = 1
s = list(set(a))
if s[0] == 0:
    print(0)
else:

    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            ans = -1
            break
    print(ans)


Measured memory_bytes: 21692
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    i64 n;
    cin>>n;

    if( n % 2 == 1 ){
        cout<<0<<endl;
    } else {
        i64 k = n/10;
        i64 ans = n/10;
        while(true){
            if(k/5 >= 1){
                ans += k/5;
                k = k/5;
            } else {
                break;
            }
        }
        cout<<ans<<endl;
    }

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

Measured memory_bytes: 256
import math


def main():
    N, D = (int(x) for x in input().split())
    X = [[int(x) for x in input().split()] for i in range(N)]
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if distance(X[i], X[j]).is_integer():
                ans += 1
    print(ans)


def distance(y, z):
    dis = 0
    for i in range(len(y)):
        dis += (y[i] - z[i]) ** 2
    return math.sqrt(dis)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int n;
LL f[100];
int main() {
	f[0] = 2;
	f[1] = 1;
	scanf("%d", &n);
	for(int i = 2; i <= n; i++)f[i] = f[i - 1] + f[i - 2];
	printf("%lld\n", f[n]);
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4) << "\n";

	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll A,B;

int main(){
    cin>>A>>B;
    cout<<max(0ll,A-B*2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define inl(x,n) for(int e=0;e<n;e++){long long y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int n;
    cin >> n;
    ll res = 0;
    for(int i=1;i<=n;i++){
        if(i%3!=0 and i%5!=0) res += i;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int MOD = 10007;

int main()
{
    vector<int> toIndex(128, -1);
    toIndex['J'] = 0;
    toIndex['O'] = 1;
    toIndex['I'] = 2;

    int n;
    cin >> n;

    vector<int> dp(8, 0);
    dp[1] = 1;
    while(--n >= 0){
        char c;
        cin >> c;

        vector<int> nextDp(8, 0);
        for(int i=0; i<8; ++i){
            bitset<3> bs1(i);
            for(int j=0; j<8; ++j){
                bitset<3> bs2(j);
                if((bs1 & bs2).any() && bs2[toIndex[c]]){
                    nextDp[j] += dp[i];
                    nextDp[j] %= MOD;
                }
            }
        }
        dp.swap(nextDp);
    }

    int ret = accumulate(dp.begin(), dp.end(), 0) % MOD;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int i, n;
  cin>>s;
  n=s.length();
  if(n==1 || n%2!=0)
  {
    cout<<"No";
    return 0;
  }
  if(n==2)
  {
    if(s[0]=='h' && s[1]=='i')
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
  }
  for(i=0;i<n-2;i++)
  {
    if(((s[i]==s[i+2]) && (s[i]!=s[i+1])) && (s[i]=='h' || s[i]=='i'))
    continue;
    else
    {
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

const long long MOD = 1000000007;

void solve(long long n, long long m, std::vector<long long> x,
           std::vector<long long> y) {
    for (int i = 0; i + 1 < x.size(); i++)
        x[i] = x[i + 1] - x[i];
    x.pop_back();
    for (int i = 0; i + 1 < y.size(); i++)
        y[i] = y[i + 1] - y[i];
    y.pop_back();

    long long X = 0;
    long long Y = 0;
    for(int i = 0 ; i < x.size() ; i++){
        X += (i+1) * (x.size()-i) % MOD * x[i];
        X %= MOD;
    }
    for(int i = 0 ; i < y.size() ; i++){
        Y += (i+1) * (y.size()-i) % MOD * y[i];
        Y %= MOD;
    }

    cout << X * Y % MOD << endl;
}

int main() {
    long long n;
    scanf("%lld", &n);
    long long m;
    scanf("%lld", &m);
    std::vector<long long> x(n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &x[i]);
    }
    std::vector<long long> y(m);
    for (int i = 0; i < m; i++) {
        scanf("%lld", &y[i]);
    }
    solve(n, m, std::move(x), std::move(y));
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

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

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

int n,m;
const int maxM = 202020;
const int INF = 1e9;
vector<PII> edge[3*maxM];
map<PII, int> sid;
int lastId = 0;

// 頂点と色を引数に持って新しく追加する頂点との間にエッジを張る
// 今まで出てきた端点と同じものがあったら同じグループに追加する
int getid(int v, int c){
  PII p(v,c);
  if( sid.find(p) !=  sid.end()) return sid[p];
  return sid[p] = lastId++;
}

void addEdge(int a, int b, int c){
  // 同じ辺の要素はコスト0の辺を貼ったのでそれぞれの端点で独立に考える
  int v = getid(a,c), u = getid(b,c);
  edge[v].emplace_back(u,0);
  edge[u].emplace_back(v,0);
}

void dijkstra(){
  int dist[n + lastId];
  rep(i,n+lastId) dist[i] = INF;
  dist[lastId] = 0;
  priority_queue< PII, vector<PII>, greater<PII>> que;
  que.push({0,lastId});
  while(que.empty() == false){
    PII p = que.top(); que.pop();
    int cdist = p.first, current = p.second;

    if(dist[current] < cdist) continue;

    for(PII e: edge[current]){
      if(dist[e.first] > cdist + e.second){
          que.push({cdist + e.second,e.first});
          dist[e.first] = e.second + cdist;
      }
    }
  }

  if(dist[lastId+n-1] == INF){
    cout << -1 << endl;
    return;
  }else cout << dist[lastId+n-1]/2 << endl;

}

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

  int a[m],b[m],c[m];

  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
    addEdge(a[i],b[i],c[i]);
  }

  // 作成した頂点と入力の辺の端点からコスト1の辺を張る
  rep(i,m){
    edge[getid(a[i], c[i])].emplace_back(lastId+a[i], 1);
    edge[getid(b[i], c[i])].emplace_back(lastId+b[i], 1);
    edge[lastId+a[i]].emplace_back(getid(a[i], c[i]), 1);
    edge[lastId+b[i]].emplace_back(getid(b[i], c[i]), 1);
  }

  dijkstra();
  return 0;
}


Measured memory_bytes: 65784
# coding: utf-8

h, w = map(int,input().split())
A = []

for i in range(h):
    l = list(input())
    if list(set(l)) == ['.']:
        h -= 1
    else:
        A.append(l)
#for a in A:
    #print(a)
Ans = []
for i in range(w):
    cnt = 0
    for j in range(h):
        if A[j][i] == '.':
            cnt += 1
    if cnt == h:
        Ans.append(i)

for i in Ans:
    for j in range(h):
        A[j][i] = ''

for a in A:
    print(''.join(a))

Measured memory_bytes: 3188
import sys
n=10**6
p=[True]*n
p[0],p[1]=False,False
for i in xrange(2,int(n**0.5)+1):
    if p[i]==True:
        for j in xrange(i**2,n,i):
            p[j]=False
gr,le=[None]*n,[None]*n
prime=None
for i in xrange(n-1,-1,-1):
    gr[i]=prime
    if p[i]:
        prime=i
for i in xrange(0,n):
    le[i]=prime
    if p[i]:
        prime=i
for line in sys.stdin.readlines():
    num=int(line.strip())
    print le[num],gr[num]

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

const int MAXN = 2010;
long long card[MAXN];

int main()
{
    long long n,z,w;
    cin >> n >> z >> w;
    for(int i = 0; i < n; ++i)
        cin >> card[i];
    if(n == 1)
    {
        cout << abs(card[0] - w) << endl;
        return 0;
    }
    cout << max(abs(card[n-1]-card[n-2]),abs(card[n-1]-w)) <<endl;
    return 0;
}


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

#define MAXN (100010)

int n;
std::vector<int> vec[MAXN]; 
bool vis[MAXN];
int sg[MAXN];

void dfs(int u){
	vis[u] = true;
	bool mark = false;
	for(auto v : vec[u]){
		if(vis[v]) continue;
		mark = true;
		dfs(v);
		sg[u] ^= (sg[v] + 1);
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i < n; ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	dfs(1);
	printf(sg[1]? "Alice\n" : "Bob\n");
	return 0;
}

Measured memory_bytes: 10880
readints()=parse.(Int,split(readline()))

A,B,H,M=readints()
deg=pi/180
hour2deg(H,M)=90-(H/12+M/60/12)*360
Ax,Ay=A*cos(hour2deg(H,M)*deg),A*sin(hour2deg(H,M)*deg)
min2deg(M)=90-(M/60)*360
Bx,By=B*cos(min2deg(M)*deg),B*sin(min2deg(M)*deg)

print(sqrt((Ax-Bx)^2+(Ay-By)^2))

Measured memory_bytes: 212888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,t;cin>>n>>m>>t;
  int a[n],i,ans=0;
  for(i=0;i<n;i++) cin>>a[i];
  ans+=a[0]-m;
  for(i=0;i<n-1;i++) ans+=max(0,a[i+1]-a[i]-m*2);
  ans+=max(0,t-a[n-1]-m);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>
#define MAX 100000
int main(){
  int n;
  int A[MAX];
  int i,j;
  int point;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  point = partitionSort(A,0,n);

  for(i=0;i<point;i++){
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[i]);
  for(i=point+1;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
}

int partitionSort(int *A,int p,int r){
  int x;
  int i,j;
  int tmp;
  x = A[r-1];
  //  printf("x =  %d\n",x);
  i = p - 1;
  for(j=p;j<r-1;j++){
    if(A[j] <= x ){
      i = i + 1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  /*
  for(j=0;j<r;j++){
    printf("%d ",A[j]);
  }
  printf("\n");
  */
  tmp = A[i+1];
  A[i+1] = A[r-1];
  A[r-1] = tmp;
  return i+1;
}



Measured memory_bytes: 2120
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        int b[] = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = N - 1; i >= 0; i--){
            int c = 0;
            for(int j = 2; (i + 1) * j <= N; j++){
                c += b[((i + 1) * j) - 1];
            }
            if(c % 2 == a[i]){
                b[i] = 0;
            }else{
                b[i] = 1;
                count++;
            }
        }
        System.out.println(count);
        for(int i = 0; i < N; i++){
            if(b[i] == 1){
                System.out.print((i + 1) + " ");
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 85816
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long int
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define LN outchar('\n')
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}


int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	inpos(n);
	int dp[n] = {0};
	int arr[n];
	for (int i = 0; i<n;i++) {
		inpos(arr[i]);
	}
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i<n;i++) {
		dp[i] = min (dp[i-2] + abs(arr[i-2] - arr[i]) , dp[i-1] + abs(arr[i-1]- arr[i]) ); 
	}
	outpos(dp[n-1]);LN;
	// cout << arr[n-1] <<en
}


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

import sys
import math


n = 0
datas = []

for (i, line) in enumerate(sys.stdin):
	if i == 0:
		n = int(line)
	else:
		datas.append(map(float, line.split()))

for data in datas:
	x1, y1, x2, y2, x3, y3 = data
	a1 = x2 - x1
	b1 = y2 - y1
	a2 = x3 - x1
	b2 = y3 - y1
	px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
	py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
	r = math.sqrt(px * px + py * py)
	px += x1
	py += y1
	print "{0:.3f} {1:.3f} {2:.3f}".format(px, py, r)

Measured memory_bytes: 4420
mod=10**9+7
k=int(input())
s=input()
n=len(s)
c=1
t=1
ans=0
m=10**20
for i in range(k+1):
  ans+=c*t
  if ans>m:ans%=mod
  c*=(n+k-i)*pow(i+1,mod-2,mod)
  if c>m:c%=mod
  t*=25
  if t>m:t%=mod
print(ans%mod)


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

#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define int long long int
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define INF 200001
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0, sizee = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'R')
      sizee++;
  for (int i = 0; i < sizee; i++)
    if (s[i] != 'R')
      ans++;
  cout << ans << endl;
  return 0;
}

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

int main(){
	string s;
	cin >> s;
	int count = s.length();
	int differ = 0;
	for(int i = 0; i < count; i++){
		if(i % 2){
			if(s[i] == '0'){
				differ++;
			}
		}else{
			if(s[i] == '1'){
				differ++;
			}
		}
	}
	count = count - differ;
	if(count < differ){
		cout << count << endl;
	}else{
		cout << differ << endl;
	}
	return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;

    int n;
    cin>>n;

    cout<<fixed<<endl;
    cout<<setprecision(12)<<endl;

    double ans;
    ans=(double(n)/3)*(double(n)/3)*(double(n)/3);

    cout<<ans<<endl;
}




Measured memory_bytes: 3784
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse);
            var ans = new int[N + 1];
            foreach (var i in A)
            {
                ans[i]++;
            }

            for (int i = 1; i <= N; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
    }
}


Measured memory_bytes: 43052
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0: break

    for i in range(H):
        for j in range(W):
            if (i+j) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()


Measured memory_bytes: 7008
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int ue[2][2] = {
	{1, 0},
	{0, 1}
};

int sita[5][5] = {
	{0, 1, 1, 1, 1},
	{1, 0, 1, 1, 1},
	{1, 1, 0, 1, 1},
	{1, 1, 1, 0, 1},
	{1, 1, 1, 1, 0},
};

int ue_s[5][2];
int sita_s[5][5];

int main(){
	
	int n, dum;
	
	for(int loop = 0; loop >= 0; loop++){
		
		cin >> n;
		
		if(cin.eof()){
			break;
		}
		
		if(loop != 0){
			printf("\n");
		}
		
		for(int i = 0; i < 5; i++){
			dum = n % 10;
			for(int j = 0; j < 2; j++){
				ue_s[i][j] = ue[dum / 5][j];
			}
			for(int j = 0; j < 5; j++){
				sita_s[i][j] = sita[dum % 5][j];
			}
			n /= 10;
		}
		
		for(int i = 0; i < 2; i++){
			for(int j = 4; j >= 0; j--){
				if(ue_s[j][i]){
					printf("*");
				}else{
					printf(" ");
				}
			}
			printf("\n");
		}
		
		printf("=====\n");
		
		for(int i = 0; i < 5; i++){
			for(int j = 4; j >= 0; j--){
				if(sita_s[j][i]){
					printf("*");
				}else{
					printf(" ");
				}
			}
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1120
#include <stdio.h>

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    char s[ 16 ][ 16 ];

    if ( scanf ( " %s %s %s %s %s %s %s %s", s[ 0 ], s[ 1 ], s[ 2 ]
               , s[ 3 ], s[ 4 ], s[ 5 ], s[ 6 ], s[ 7 ] ) != 8 ) break ;

    for ( i = 0; i < 8; ++i )
    for ( j = 0; j < 8; ++j )
    {
      if ( s[ i ][ j ] != '1' ) continue ;

      if ( i < 7
        && s[ i + 1 ][ j ] == '1'
        && s[ i ][ j + 1 ] == '1'
        && s[ i + 1 ][ j + 1 ] == '1' )   puts ( "A" );
      if ( i < 5
        && s[ i + 1 ][ j ] == '1'
        && s[ i + 2 ][ j ] == '1'
        && s[ i + 3 ][ j ] == '1' )       puts ( "B" );
      if ( s[ i ][ j + 1 ] == '1'
        && s[ i ][ j + 2 ] == '1'
        && s[ i ][ j + 3 ] == '1' )       puts ( "C" );
      if ( i < 6 && j > 0
        && s[ i + 1 ][ j - 1 ] == '1'
        && s[ i + 1 ][ j ] == '1'
        && s[ i + 2 ][ j - 1 ] == '1' )   puts ( "D" );
      if ( i < 7
        && s[ i ][ j + 1 ] == '1'
        && s[ i + 1 ][ j + 1 ] == '1'
        && s[ i + 1 ][ j + 2 ] == '1' )   puts ( "E" );
      if ( i < 6
        && s[ i + 1 ][ j ] == '1'
        && s[ i + 1 ][ j + 1 ] == '1'
        && s[ i + 2 ][ j + 1 ] == '1' )   puts ( "F" );
      if ( i < 7 && j > 0
        && s[ i ][ j + 1 ] == '1'
        && s[ i + 1 ][ j - 1 ] == '1'
        && s[ i + 1 ][ j ] == '1' )       puts ( "G" );
      
      goto CONTT;
    }

CONTT: ;
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            p[i] = sc.nextInt();
        }
        int ans = 0;
        boolean flg = false;
        for (int i = 1; i <= n; i++) {
            if(i < n && p[i + 1] == i + 1 && p[i] == i) {
                ans++;
                i++;
            } else if(p[i] == i) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 59636
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> A(n), B(n), C(n - 1);
    for (auto &a : A) {
        cin >> a;
    }
    for (auto &b : B) {
        cin >> b;
    }
    for (auto &c : C) {
        cin >> c;
    }
	int res = 0;
	for (int i = 0; i <= B.size()-1; i++) {
		res += B[i];
	}
	for(int j = 0; j < n-1; j ++){
		if (A[j] + 1 == A[j+1]) {
			res += C[A[j] - 1];
		}
	}
    cout << res << endl;
}

Measured memory_bytes: 3632
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll uf[100010];

ll root(ll i){
    if(uf[i] == i){
        return i;
    }else{
        return uf[i] = root(uf[i]);
    }
}



int main() {
    ll n,m;
    ll x[100010],y[100010],z[100010];
    
    std::cin >> n>>m;
    for (int i = 0; i < n; i++) {
        uf[i] = i;
    }
    for (int i = 0; i < m; i++) {
        std::cin >> x[i]>>y[i]>>z[i];
        x[i]--;
        y[i]--;
        z[i]--;
        uf[root(x[i])] = root(y[i]);
        // if(z[i] %2 == 0){
            
        // }else{
        //     uf[x[i]] = root(y[i]);
        // }
    }
    bool used[100010];
    Fill(used,false);
    
    ll count=0;
    
    for (int i = 0; i < n; i++) {
        if(!used[ root(i) ]){
            count++;
            used[root(i)]=true;
        }
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (n); ++i)
#define repe(i, n) for (int64_t i = 0; i <= (n); ++i)
#define reps(i, s, n) for (int64_t i = (s); i < (n); ++i)
#define repse(i, s, n) for (int64_t i = (s); i <= (n); ++i)
#define repr(i, n) for (int64_t i = (n); i >= 0; --i)
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;

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

  int64_t H, W; cin >> H >> W;
  int64_t h, w; cin >> h >> w;

  cout << H * W - (h * W) - (w * H) + (h * w) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int a,n = 0,i,m = 0,j = 0;
    for(i = 1;i >= 0;i--)
    {
        a = str[i] - '0';
        n += a*pow(10,j++);
    }
    j = 0;
     for(i = 3;i >= 2;i--)
    {
        a = str[i] - '0';
        m += a*pow(10,j++);
    }
    if((n>0 && n<13 && m>=0) && (m>0 && m<13 && n>=0))
        cout<<"AMBIGUOUS\n";
    else if(n>0 && n<13 && m>=0)
         cout<<"MMYY\n";
    else if(m>0 && m<13 && n>=0)
        cout<<"YYMM\n";
    else
        cout<<"NA\n";
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		long X = scan.nextLong();

		//WK変数

		//演算
		l1: for (long B = -142L; B < 142L; B++) {
			for (long A = -142L; A < 142L; A++) {

				if (Math.pow(A, 5) - Math.pow(B, 5)== X) {
					System.out.println(A + " " + B);
					break l1;
				}
			}
		}

		//結果出力
	}
}

Measured memory_bytes: 38780
n,h=map(int, input().split())
a_l=[]
b_l=[]
for _ in range(n):
    a,b=map(int, input().split())
    a_l.append(a)
    b_l.append(b)
a_l.sort(reverse=True)
b_l.sort(reverse=True)
a_max=max(a_l)

b_strong=[]
for b_i in b_l:
    if b_i>a_max:
        b_strong.append(b_i)

cnt=0
for b_s in b_strong:
    if h>0:
        h-=b_s
        cnt+=1
    else:
        break

if h>0:
    cnt+=(h-1)//a_max+1

print(cnt)


Measured memory_bytes: 17828
//Pranet Verma
#include <bits/stdc++.h>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
            cout << i << " " << i + 1 << endl;
            return 0;
        }
    } 
    for (int i = 2; i < s.size(); ++i) {
        if (s[i] == s[i - 2]) {
            cout << i - 1 << " " << i + 1 << endl;
            return 0;
        }
    } 
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        var N = sc.next().toInt()
        val A = IntArray(N) { sc.next().toInt() }
        val buy = mutableSetOf(0)
        val sell = mutableSetOf<Int>()
        for (i in 1 until N) {
            if (A[i] - A[i - 1] < 0) buy += i
        }

        var r = N
        for (b in buy.reversed()) {
            if (b < r - 1) {
                sell += r - 1
            } else {
                buy.remove(b)
            }
            r = b
        }
        //dprint(buy)
        //dprint(sell)

        var yen = 1000L
        var kabu = 0L
        for (i in 0 until N) {
            if (sell.contains(i)) {
                yen += kabu * A[i]
                kabu = 0
            }
            if (buy.contains(i)) {
                kabu += yen / A[i]
                yen -= kabu * A[i]
            }
        }
        pw.println(yen)
    }
}


Measured memory_bytes: 41376
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N,M;
	const int INF=(1<<28);
	while(cin >> N >> M, (N|M)){
		int c[M];
		for(int i=0; i<M; ++i)	cin >> c[i];
		vector<vector<int> > dp(N+1, vector<int>(256, INF));
		dp[0][128]=0;
		int x;
		for(int i=0; i<N; ++i){
			cin >> x;
			for(int j=0; j<=255; ++j)for(int k=0; k<M; ++k){
				int next=max(0,min(255, j+c[k]));
				dp[i+1][next]=min(dp[i+1][next], dp[i][j]+((x-next)*(x-next)));
			}
		}
		int ans=INF;
		for(int i=0; i<=255; ++i)	ans=min(ans, dp[N][i]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 21924
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int ans = 0, ptr = 0;
  while (ptr < n)
  {
    int cc = a[ptr], cnt = 0;
    while (ptr < n && a[ptr] == cc)
    {
      ptr++; cnt++;
    }
    ans += (cnt % 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x,a,b;
    scanf("%d",&x);
    scanf("%d",&a);
    scanf("%d",&b);
    int i;
    if(x-a>=0)
    {
       x=x-a;
    }
    int sum=0;
    for(i=0;;i++)
    {
        sum=sum+b;
        if(sum>x)break;
    }
    sum=sum-b;
    sum=x-sum;
    printf("%d",sum);
    return 0;
}


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

int main() {
   long long a,b,c,d;
   cin >> a >> b >> c >> d;
   if((a>=0 && b>=0 && d >=0) || (a<0 && b>=0 && c>=0 && d >=0) ){
      cout << b * d << endl;
   }
   if(a>=0 && b>=0 && c<0 && d <0){
      cout << a * d << endl;
   }
   if(a<0 && b<0 && c>=0 && d >=0){
      cout << b * c << endl;
   }
   if(a<0 && b<0 && c<0){
      cout << a * c << endl;
   }
   if(a<0 && b>=0 && c<0 && d<0){
       cout << a * c << endl;
   }
   if(a<0 && b>=0 && c<0 && d >=0){
      if(a *c >= b * d){
         cout << a * c << endl;
      }
      else{
         cout << b * d << endl;
      }
   }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> mt;

mt visit;
mt p;
queue<vl> q;
ll w,h;
ll dx[4] = {0, 1, 0, -1};
ll dy[4] = {1, 0, -1, 0};

bool isin(ll x, ll y){
  return x >= 0 && x < w && y >= 0 && y <= h;
}

void show_visit(){
  for(ll i = 0;i <= h;i++){
    for(ll j = 0;j < w;j++){
      cerr << visit[i][j] << " ";
    }
    cerr << endl;
  }
  cerr << endl;
}

int main(){
  while(cin >> w >> h){
    if(w == 0 && h == 0) return 0;
    p = mt(h,vl(w));
    for(ll i = 0;i < h;i++){
      string s;
      cin >> s;
      for(ll j = 0;j < w;j++){
        if(s[j] == '.') p[i][j] = -1;
        else p[i][j] = s[j]-'0';
      }
    }
    p.push_back(vl(w, 0));
    bool flag = true;
    for(ll py = 0;py < h;py++){
      for(ll px = 0;px < w;px++){
        if(p[py][px] == -1) continue;
        visit = mt(h+1,vl(w));
        q = queue<vl>();
        ll xl = w+1,xr = 0;
        visit[py][px] = 1;
        q.push(vl({py, px, p[py][px], 0}));

        ll sum = 0;
        ll block_num = 0;
        while(!q.empty()){
          ll y = q.front()[0];
          ll x = q.front()[1];
          ll block = q.front()[2];
          ll cnt = q.front()[3];
          sum += x;
          block_num++;
          if(cnt == 0){
            if(p[y+1][x] != -1 && p[y+1][x] != block){
              xl = min(xl,x);
              xr = max(xr,x+1);
            }
          }

          q.pop();

          for(ll d = 0;d < 4;d++){
            ll next = x+dx[d];
            ll neyt = y+dy[d];
            if(isin(next, neyt)){
              if(p[neyt][next] == -1) continue;
              if(visit[neyt][next] == 1) continue;
              if(p[neyt][next] == block){
                visit[neyt][next] = 1;
                q.push(vl({neyt, next, p[neyt][next], cnt}));
              }else{
                if(d != 2) continue;
                visit[neyt][next] = 1;
                q.push(vl({neyt, next, p[neyt][next], cnt+1}));
              }
            }
          }



        }
        // show_visit();
        // cerr << sum << " " << xl << " " << xr << endl;
        sum += block_num/2;
        if(sum > xl*block_num && sum < xr*block_num){

        }else{
          flag = false;
        }
      }
    }

    if(flag){
      cout << "STABLE" << endl;
    }else{
      cout << "UNSTABLE" << endl;
    }
  }

}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  string s;
  cin >> s;
  int x=0;
  for(char c:s) if(c=='x') ++x;
  cout << (x<8?"YES":"NO") << endl;
  return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist
K = int(input())
g = [[] for _ in range(K)]
for n in range(1,K+1):
    g[n%K] += [(1,(n+1)%K),(0,10*n%K)]

print(dijkstra(g,K,1)[0]+1)

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

bool isprime(int p){
    if(p==1) return false;
    for(int i=2;i<p;i++){
        if(p%i==0) return false;
    }
    return true;
}

int main(){
   int n;
   cin>>n;
   for(int i=11; i<=55555; i+=10){
       if(isprime(i)){
           if(i!=11) cout<<" ";
           cout<<i;
           n--;
       }
       if(n==0) break;
   }
   cout<<endl;
}

Measured memory_bytes: 256