akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class A9x9 {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int A, B;
        cin >> A >> B;
        if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
            cout << A * B << endl;
        } else {
            cout << - 1 << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    A9x9 solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
int N;
 
int main() {
  cin >> N;
 
  long long int res = 0;
  for (long long int i = 1; i <= N; i++) {
    long long int x = N / i;
    res += i * x * (x + 1) / 2;
  }
  cout << res << endl;
 
  return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 105;
const int W = 1e5 + 50;
const int INF = 0x3f3f3f3f;

int n, w;
int weight[N];
int val[N];
ll dp[W];

void load() {
    scanf("%d%d", &n, &w);

    for(int i = 0; i < n; ++i)
        scanf("%d%d", weight + i, val + i);
}

void solve() {
    dp[0] = 0;

    for(int j = 0; j < n; ++j) {
        for(int i = w; i >= weight[j]; --i)
                dp[i] = max(dp[i], dp[i - weight[j]] + val[j]);
    }

    printf("%lld\n", *max_element(dp, dp + w + 1));
}

int main() {
    memset(dp, -INF, sizeof dp);

    load();
    solve();

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
ll cnt[65][2]={0};
ll ans[65]={0};
const ll mod=1e9+7;
signed main(){
  ll n;
  cin>>n;
  vector<ll> vec;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  for(int i=0;i<62;i++){
    cnt[i][(vec[0]>>i)&(ll)1]++;
  }
  for(int i=1;i<n;i++){
    for(int j=0;j<62;j++){
      ll b=((vec[i]>>j)&(ll)1);
      b++;
      b%=2;
      ans[j]+=cnt[j][b];
      b++;
      b%=2;
      cnt[j][b]++;
    }
  }
  ll res=0;
  for(int i=0;i<62;i++){
    ll kans=((ll)1<<i);
    kans%=mod;
    kans*=ans[i]%mod;
    kans%=mod;
    res+=kans;
    res%=mod;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
//-----------------------------------------------------
int main()
{
    int a,b,c;
cin>>a;
cin>>b;
cin>>c;
int d=a+b+c;
if(d>=22)
{
    cout<<"bust";
}
else
{
    cout<<"win";
}
return 0;
}

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

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

    string s;
    cin >> s;
    int n = s.size();

    rep1(i, n){
        if((n-i) % 2) continue;
        string sub = s.substr(0, n-i);
        int m = sub.size();

        bool is_ss = true;
        rep(j, m/2){
            if(sub[j] != sub[m/2 + j]) {
                is_ss = false;
                break;
            }
        }
        if(is_ss){
            cout << m << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))

def f(s1, s2):
  a = s1[0]
  b = s1[1]
  c = s2[0]
  d = s2[1]
  if a>c:
    a,b,c,d = c,d,a,b
  if b<c:
    return [-1, -1]
  return [c, min(b,d)]

Mlist_T = [[1, 1] for i in range(N)]#第一要素は最小値、第二要素は最大値のリスト
Mlist_A = [[1, 1] for i in range(N)]
Mlist_T[0][0]=T[0]
Mlist_T[0][1]=T[0]
Mlist_A[N-1][0]=A[N-1]
Mlist_A[N-1][1]=A[N-1]
for i in range(1,N):
  if T[i-1] != T[i]:
    Mlist_T[i][0] = T[i]
  Mlist_T[i][1] = T[i]
for i in range(1,N):
  if A[N-1-(i-1)] != A[N-1-i]:
    Mlist_A[N-1-i][0] = A[N-1-i]
  Mlist_A[N-1-i][1] = A[N-1-i]
fl = True
M = []
for i in range(N):
  m = f(Mlist_T[i],Mlist_A[i])
  if m == [-1, -1]:
    fl = False
    print(0)
    break
  M.append(m)

if fl:

  r = 1000000007
  ss = 1

  for m in M:
    ss = (ss * (m[1]-m[0]+1))%r
  print(ss)

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

int main(){
 ll x;
 cin >> x;
 const double r = 0.01;
 ll ans =0;
 ll n = 100;
 while( n < x){
 n  =  floor(n*(1+r));
 ans++;
}
 cout <<  ans  <<endl;
return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
int main(void){
  int cards[4][13] = {};
  int n,i,c,s,r,k,l;
  char a,b;
  scanf("%d",&n);
  for (i = 0; i < n ;i++ ){
    scanf("%c",&a);
    scanf("%c %d",&b,&c);
    if(b == 'S'){
      s = 0;
    }else if(b == 'H'){
      s = 1;
    }else if(b == 'C'){
      s = 2;
    }else if(b == 'D'){
      s = 3;
    }
   r = c - 1;
   cards[s][r] = 1;
  }
  for (k = 0 ;k <= 3 ;k++){
      for (l = 0 ;l <= 12 ;l++){
        if (cards[k][l] == 0){
          if (k == 0){
            printf("S %d\n",l + 1);
          }else if (k == 1){
            printf("H %d\n",l + 1);
          }else if (k == 2){
            printf("C %d\n",l + 1);
          }else if (k == 3){
            printf("D %d\n",l + 1);
          }
        }
      }
    }
  return 0;
}



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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    rep(i, n) {
        if (a[i] % 2 == 0 && a[i] % 3 && a[i] % 5) {
            cout << "DENIED" << endl;
            return 0;
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

vector<int> make_table(int n, int m) {
    vector<int> table(n);
    table[0] = 1;

    FOR(i, 1, n) table[i] = table[i-1] * 10 % m;

    return table;
}

int main() {
    constexpr int mod = 1e9 + 7, m = 13;
    string s; cin >> s;
    const int n = s.length();

    reverse(s.begin(), s.end());

    auto dp = make_v(n+1, m, 0LL);
    dp[0][0] = 1;

    auto table = make_table(n, m);

    REP(i, n)REP(j, m) {
        if(s[i] == '?') {
            REP(k, 10) {
                (dp[i+1][(k * table[i] + j) % m] += dp[i][j]) %= mod;
            }
        } else {
            int k = s[i] - '0';
            (dp[i+1][(k * table[i] + j) % m] += dp[i][j]) %= mod;
        }
    }

    cout << dp[n][5] << endl;
    
    return 0;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e9
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int mp[1000005];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        fr(i,0,n)
        {
            cin>>a[i];
            mp[a[i]]++;
        }
        int ans=n;
        fr(i,0,n)
        {
            if(mp[a[i]]>1)
            {
                ans--;
                continue;
            }
            if(a[i]==1) continue;
            int z=sqrt(a[i]);
            fr(j,1,z+1)
            {
                if(j==1)
                {
                    if(mp[j]!=0)
                    {
                        ans--;
                        break;
                    }
                }
                else if(a[i]%j==0)
                {
                    if(a[i]/j==j && mp[j]!=0) {ans--;break;}
                    else if(a[i]/j!=j && (mp[j]!=0 || mp[a[i]/j]!=0)) {ans--;break;}
                }
            }
            //cout<<i<<" "<<ans<<endl;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 8248
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, l; cin >> n >> l;
    vector<string> s(n);
    rep(i, n) {
        cin >> s[i];
    }
    sort(all(s));
    rep(i, n) {
        cout << s[i];
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from math import factorial

def comb(a,d):
    return factorial(a)//factorial(b)//factorial(a-b)

mod = 10**9+7

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

C = sorted(C_input)
ans = 0
for ind, s in enumerate(C):
    ans+= C[ind] * (N+1-ind)
    ans %= mod
print(int(ans* 2**(2*N-2)) %mod)

Measured memory_bytes: 27276
#include<bits/stdc++.h>
int n,s[100000],q,t,c,i,j;
main(){
  for(scanf("%d",&n);i<n;scanf("%d",s+i++));
  for(scanf("%d",&q);j++<q;std::binary_search(s,s+n,t)&&c++)scanf("%d",&t);
  printf("%d\n",c);
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n;
char s[maxn];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int ans = 0;
	for (int i = 2; i <= n; ++i) if(s[i] != s[i - 1]) ++ans;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3908
#define _CRT_SECURE_NO_WARNINGS
////#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int abacus[8][5];
	int n, i, a, j, f = 0;
	
	while (~fscanf(stdin, "%d", &n)) {
		if(f) puts("");
		f = 1;
		memset(abacus, 0, sizeof(abacus));
		i = 5;
		while (i--) {
			a = n % 10;
			if (a >= 5) abacus[0][i] = 1, a -= 5;
			else abacus[1][i] = 1;
			abacus[3 + a][i] = 1;
			n /= 10;
		}
		for (i = 0; i < 8; i++, puts("")) {
			for (j = 0; j < 5; j++) {
				if (i == 2) putchar('=');
				else if (abacus[i][j]) putchar(' ');
				else putchar('*');
			}
		}
	}
	return 0;
}

Measured memory_bytes: 592
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

a,b,c = map(int, input().split())
k = int(input())
sum_3 = a+b+c
n=a
if  n < b:
    n = b
if n < c:
    n = c
answer = n
for i in range(k):
    answer = answer * 2
answer = answer + sum_3 - n
print(answer)


Measured memory_bytes: 21672
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        for(int i = 1; i<=n; i++) {
            int d = (int)Math.log10(i) + 1;
            if(d%2==1) cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cctype>
using namespace std;
int main(){
        char ch;
        while(1){
                scanf("%c",&ch);
                if(ch=='\n'){
                        printf("\n");
                        break;
                }
                if(islower(ch)){
                        ch=toupper(ch);
                }else if(isupper(ch)){
                        ch=tolower(ch);
                }
                printf("%c",ch);
        }
        return 0;
}

Measured memory_bytes: 1100
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
using namespace std;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}




int main() {
  int A[3];
  for(int i=0;i<3;i++){
    cin>>A[i];
  }
  sort(A,A+3);
  cout<<10*A[2]+A[1]+A[0]<<endl;








  
 
  
  

  


  

  




  
  
}

 



  
  
  

  






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

int main() {
    int n;
    cin >> n;
    int a[n], x = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x ^= a[i];
    }
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << ' ';
        cout << (x ^ a[i]);
    }
    cout << endl;
}

Measured memory_bytes: 4356
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int a[maxn];
int main(){
	int n;
	int i;
	cin>>n;
	ll ans=0;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	ans+=a[0];
	if(n%2==0){
		for(i=1;i<n/2;i++){
			ans+=a[i]*2;
		}	
	}
	else{
		for(i=1;i<n/2;i++){
			ans+=a[i]*2;
		}
		ans+=a[i];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

vector<pair<ll, ll>> burger;

int main() {
  int n;cin >>n;
  vector<int> a(n);
  for(int i=0;i<n;++i)cin >> a[i];
  sort(all(a));
  int id_h = lower_bound(all(a), a[n-1]/2) - a.begin();
  int a_h = abs(a[n-1]/2 - a[id_h]);
  int a_h_m = abs(a[n-1]/2 - a[id_h-1]);
  if(a_h<=a_h_m && id_h != n-1 ){
    cout <<  a[n-1] << " " <<  a[id_h] << endl;
  } else {
    cout <<  a[n-1] << " " <<  a[id_h-1] << endl;
  }
  return 0;
}


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

int main() {
    int K, S, res;
    
    cin >> K >> S;

    res = 0;
    for (int i = 0; i <= K; i++){
        for (int j = 0; j <= K; j++){
                if (S - i - j >= 0 and S - i - j <= K){
                    ++res;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;

  int m = 0, ans = 0;
  rep(i, n) {
    int x; cin >> x;
    ans += m <= x;
    m = max(m, x);
  } cout << ans;
}
    


Measured memory_bytes: 256
s=list(input())
#print(s)
odd = [s[i] for i in range(0, len(s), 2)]
even = [s[i] for i in range(1, len(s), 2)]
#print(odd,even)

if "R" in even or "L"in odd:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll dp[100005];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n, m;
   cin >> n >> m;
   vector<int> broken(n + 1, false);
   rep(i, 0, m) {
      int a;
      cin >> a;
      broken[a] = true;
   }
   dp[n] = 1;
   rrep(i, n - 1, 0) {
      if (broken[i]) continue;
      dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
   }
   cout << dp[0] << endl;
   return 0;
}

Measured memory_bytes: 4488
package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()

	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = -1
	}
	for i := 0; i < m; i++ {
		s := scanInt()-1
		num := scanInt()

		if c[s] == -1 {
			c[s] = num
		} else {
			if c[s] != num {
				fmt.Fprintln(wr, -1)
				return
			}
		}
	}

	chk := 0
	for i := 0; i < n; i++ {
		if chk == 0 && c[i] == 0 {
			if i == n-1 {
				break
			}
			fmt.Fprintln(wr, -1)
			return
		}
		chk++
	}
	
	if n==1 {
		if c[0] == -1 {
			c[0] = 0
		}
		fmt.Fprintln(wr, c[0])
		return
	}

	d := 1
	for i := 0; i < n; i++ {
		d *= 10
	}


	for i := d/10; i < d; i++ {
		num := i
		f := true
		for j := 0; j < n; j++ {
			if c[n-1-j] == -1 {
				num /= 10
				continue
			}

			if c[n-1-j] != num%10 {
				f = false
			}
			num /= 10
		}

		if f {
			fmt.Fprintln(wr, i)
			return
		}
	}

	fmt.Fprintln(wr, -1)
	
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <functional>
using ll = long long;
const ll mod = 1000000007;

using namespace std;

typedef std::pair<std::string,double> P;

struct less {
	bool operator()(const P& x, const P& y) const {
        if(x.second==y.second){
            return x.first < y.first;
        }
		return x.second > y.second;
	}
};
int field[201][201];
long long a, b, c, d, e;
int N;
int main() {
    cin >> N;
    
    int shita[N+1]={0};
    int ue[N+1] = {0};
    for(int i=1; i<N+1; ++i){
        int a; cin >> a;
        ue[i]=ue[i-1]+a;
    }
    int sum=0;
    int ruisekiwa[N+1]={0};
    for(int i=1; i<N+1; ++i){
        int a; cin >> a;
        sum+=a;
        ruisekiwa[i]=ruisekiwa[i-1]+a;
    }
    for(int i=1; i<N+1; ++i) shita[i] = sum-ruisekiwa[i-1];
    
    int maxV=0;
    for(int i=1; i<N+1; ++i){
        int sum = ue[i]+shita[i];
        maxV = max(maxV, sum);
    }
    cout << maxV << endl; 
	return 0;
}

Measured memory_bytes: 256
import sys
from math import gcd
from functools import reduce

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    print(reduce(gcd, A))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20764
a,b,c,k = gets.split.map(&:to_i)
sum = 0
def main(a, b, c, k, sum)
    pulsA = a > k ? k : a
    k = k-pulsA
    sum = sum + pulsA
    if k <= 0
        print sum
        return
    end
    k = k-b  
    if k <= 0
        print sum
        return
    end
    pulsC = c > k ? k : c 
    sum = sum - pulsC
    print sum
end

main(a,b,c,k,sum)

Measured memory_bytes: 14276
MOD=10**9+7
n,m=map(int,input().split())
xs=list(map(int,input().split()))
ys=list(map(int,input().split()))
x=0
for i in range(n):
  x+=(2*(i+1)-n-1)*xs[i]
  x%=MOD

y=0
for j in range(m):
  y+=(2*(j+1)-m-1)*ys[j]
  y%=MOD

print(x*y%MOD)

Measured memory_bytes: 24456
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long int lli;
typedef pair<int, int> Pii;
const int INF = 193499;
int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N) cin >>d[i];
    set<int> val;
    rep(i,N){
        val.insert(d[i]);
    }
    cout << val.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <cstdlib>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    bool flag = false;
    for(int i=1;i<=9;i++){
        if(N%i==0&&N/i<=9){
           cout << "Yes" << endl;
           return 0;
        }
    }
    cout << "No" << endl;


}




Measured memory_bytes: 256
#include <bits//stdc++.h>
 
using namespace std;
 
void fastIO(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
 
 
int main(){
 
 
 
 fastIO();
 string n;
cin>>n; 

if(n[2]==n[3]&&n[4]==n[5])
cout<<"Yes";
else
cout<<"No";
 
 
 
 
return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();

		sc.close();

		long[] dp = new long[100];
		dp[0] = 1;
		dp[1] = 1;
		for (int i = 2; i < dp.length; i++) {
			dp[i] = dp[i - 1] + dp[i - 2];
		}

		out.println(dp[n]);
	}

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



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

int main(){
    int A, B;
    cin >> A >> B;
    if (A >= 13){
        cout << B << endl;
    }
    else if (6 <= A && A <= 12){
        cout << B / 2 << endl;
    }
    else {
        cout << 0 << endl;
    }
}


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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void run() {
  int k, n;
  cin >> n >> k;
  map <int, int> mp;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    mp[a]++;
  }
  vector < pair <int, int> > v;
  for (auto kv : mp) v.emplace_back(kv.second, kv.first);
  sort(v.begin(), v.end(), greater < pair <int, int> > ());
  debug(v);
  int sum = 0;
  for (int i = 0; i < v.size() && i < k; ++i) {
    sum += v[i].first;
  }
  cout << n - sum << endl;
  
}

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


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

const int INF = 1000000000;

int main() {
  int N;
  cin >> N;
  int a[N];
  int min = INF;
  int max = -INF;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] < min) min = a[i];
    if (a[i] > max) max = a[i];
  }  
  int max_difference = max - min;
  cout << max_difference << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
int calc(int x)
{
	int ans=0;
	while(x)
	{
		ans++;
		x>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		  printf("%d ",calc(i^j));
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=1e6+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,k;
  string s;
  cin>>n>>s>>k;
  for(int i=0;i<n;i++){
      if(s[i]==s[k-1])cout<<s[i];
      else cout<<'*';
  }
  return 0;
}

Measured memory_bytes: 384
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	string s;
	cin>>s;
	if(s=="Sunny")	cout<<"Cloudy";
	else if(s=="Cloudy")	cout<<"Rainy";
	else if(s=="Rainy")	cout<<"Sunny";

	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}



Measured memory_bytes: 256
num=int(input())
word=input()
alound=word.count("R")*word.count("G")*word.count("B")
for i in range(num-2):
  for j in range(i+1,num-1):
    k=2*j-i
    if k<=num-1:
      if word[i]!=word[j] and word[i]!=word[k] and word[k]!=word[j]:
        alound=alound-1
print(alound)
  
      

Measured memory_bytes: 68180
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,t[100005]={0},x[100005]={0},y[100005]={0},a=0;
	cin>>n;
	t[0]=0;
	x[0]=0;
	y[0]=0; 
	int t1,x1,y1;
	for(int i=1;i<=n;i++)
		cin>>t[i]>>x[i]>>y[i];
	for(int i=1;i<=n;i++)
	{
		t1=t[i]-t[i-1];
		x1=x[i]-x[i-1];
		y1=y[i]-y[i-1];
		
		if(t1<x1+y1)
		{
			cout<<"No";
			return 0;
		}
		a=t1-x1-y1;
		if(a%2!=0)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n; cin >> n;
    long long p[n]; for(long long i = 0; i < n; i++) cin >> p[i];
    long long ans[n]; for(long long i = 0; i < n; i++) ans[i] = i+1;

    long long cnt = 0;
    for(long long i = 0; i < n; i++){
        if(p[i] != ans[i]) cnt++;
    }
    if(cnt == 2 || cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
)

var Err = errors.New("cannot read from stdin")

type resultRunes []rune

func (c *resultRunes) Update(s []rune) {
	if len(*c) < len(s) {
		*c = resultRunes(s)
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	
	if !sc.Scan() {
		panic(Err)
	}
	s := []rune(sc.Text())

	res := resultRunes([]rune{})
	c := []rune{}
	for _, r := range s {
		switch r {
		case 'A', 'C', 'G', 'T':
			c = append(c, r)
		default:
			res.Update(c)
			c = []rune{}
		}
	}
	res.Update(c)

	fmt.Println(len(res))
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
#define line "\n"
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
#define vll vector<ll>
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
#define vpii vector<pair<int,int>>
#define vpsi vector<pair<string,int>>
#define mii map<int ,int>
#define mis map<int,string>
#define all(v) v.begin(),v.end()


# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
using namespace std;

void solve()
{ 
int n;
cin>>n;
int ar[4]={0};


loop(i,0,n)
{
   string a;
   cin>>a;
  if(a=="AC")ar[0]++;
  else if(a=="TLE")ar[1]++;
  else if(a=="WA")ar[2]++;
  else ar[3]++;

}
cout<<"AC x "<<ar[0]<<line;
cout<<"WA x "<<ar[2]<<line;cout<<"TLE x "<<ar[1]<<line;cout<<"RE x "<<ar[3]<<line;
}



int main()
{fast
#ifndef ONLINE_JUDGE
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
 #endif
// ll t;
// cin>>t;
// while(t--)
{
solve();
}

}



Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan	= new Scanner(System.in);
		String	s		= scan.next();
		int cnt			= 0;
		if (s.equals("SUN")) {
			cnt = 7;
		} else if (s.equals("MON")) {
			cnt = 6;
		} else if(s.equals("TUE")) {
			cnt = 5;
		} else if(s.equals("WED")) {
			cnt = 4;
		} else if(s.equals("THU")) {
			cnt = 3;
		} else if(s.equals("FRI")) {
			cnt = 2;
		} else {
			cnt = 1;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  ll d = abs(a-b);
  bool ok = false;
  if (v <= w) ok = false;
  else {
    ll dv = v - w;
    ll s = (d + dv - 1) / dv;
    if (s <= t) ok = true;
  }
  if(ok) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3652
n, m = map(int, input().split())

if n == 1 and m == 1:
    ans = 1
elif n == 1:
    ans = max(0, m - 2)
elif m == 1:
    ans = max(0, n - 2)
else:
    ans = (n - 2) * (m - 2)
print(ans)

Measured memory_bytes: 3060
main(s,i,j,k){
	for(;scanf("%d%d",&i,&s),s;printf("%d %d %d\n",i,j,k)){
		for(s-=i,k=0;s>=1000;k++)s-=1000;
		for(j=0;s>=500;j++)s-=500;
		for(i=0;s>=100;i++)s-=100;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; int H[100010] = {}; 
	cin >> N; 
	for(int i = 0; i < N; i++){
		cin >> H[i]; 
	}
	H[N] = 1145141919; 
	int count = 0; int mx = 0; 
	for(int i = 1; i < N; i++){
		if(H[i-1] >= H[i]) {
			count ++; 
			mx = max(mx, count); 
		}
		else{
			count = 0; 
		}
	}
	cout << mx << endl; 
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef long long ll;

int n, a, b;
int h[100000];

bool judge(int x){
    ll k = 0;
    rep(i, n){
        k += (max(h[i] - ll(b) * x, 0ll) + a - b - 1) / (a - b);
    }
    return k <= x;
}

int main(){
    cin >> n >> a >> b;
    rep(i, n){
        cin >> h[i];
    }

    int l = 0;
    int r = 1e9;
    while(r - l > 1){
        int m = (l + r) / 2;
        if(judge(m)){
            r = m;
        }
        else{
            l = m;
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    cin>>n>>a;
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(n+1,vector<ll>(2501, 0)));
    dp[0][0][0] = 1;
    vector<ll> x(n);
    rep(i,n){cin>>x[i];}
    rep(i,n){
        rep(j,n){
            rep(k,2501){
                dp[i+1][j][k] += dp[i][j][k];
                if(k + x[i] <= 2500) {
                    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
                }
            }
        }
    }
    ll res = 0;
    repr(i,1,n+1){
        res += dp[n][i][i*a]; 
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int a, b, m, mn = 1e9, mn1 = 1e9;
    cin >> a >> b >> m;
    int aa[a], bb[b];
    for(int i = 0; i < a; i++){
        cin >> aa[i];
        if(aa[i] < mn) mn = aa[i];
    }

    for(int i = 0; i < b; i++){
        cin >> bb[i];
        if(bb[i] < mn1) mn1 = bb[i];
    }
    int ans = mn + mn1;
    for(int i = 0; i < m; i++){
            int x, y, z;
        cin >> x >> y >> z;
        int sum = aa[x-1] + bb[y-1] - z;
        if(sum < ans) ans = sum;

    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

int main(void){
    int k, a, b;
    std::cin >> k >> a >> b;
    for(int i = a; i <= b; i++){
	if(i % k == 0){
	    std::cout << "OK" << std::endl;
	    return 0;
	}
    }
    std::cout << "NG" << std::endl;
    return 0;
}



Measured memory_bytes: 3520
S = input()
def ABC(S):
    N = len(S)
    dp = [[0 for j in range(4)] for i in range(N+1)]
    model = 'ABC'
    p = 10**9 + 7
    for i in range(N, -1, -1):
        for j in range(3,-1,-1):
            if i == N and j == 3:
                dp[i][j] = 1
            elif i == N and j < 3:
                dp[i][j] = 0
            elif i < N and j == 3:
                if S[i] == '?':
                    dp[i][j] = 3 * dp[i+1][j] % p
                else:
                    dp[i][j] = dp[i+1][j] % p
            else:
                if S[i] == '?':
                    m1 = 3
                else:
                    m1 = 1
                if S[i] == '?' or S[i] == model[j]:
                    m2 = 1
                else:
                    m2 = 0
                dp[i][j] = (m1 * dp[i+1][j])%p + m2 * (dp[i+1][j+1])%p
    return dp[0][0] % p
print(ABC(S))


Measured memory_bytes: 27612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> H(N);
  for (int i=0; i<N; i++){
    cin >> H.at(i);
  }
  
  vector<int> A(M);
  vector<int> B(M);
  
  for (int i = 0; i < M ; i++){
    cin >> A.at(i);
    cin >> B.at(i);
  }
  
  vector<int> ans(N);
 
  for(int i=0; i<M; i++){
    if(H.at(A.at(i)-1) > H.at(B.at(i)-1)){
      ans.at(B.at(i)-1) = 1;
    }
    else if(H.at(A.at(i)-1) == H.at(B.at(i)-1)){
      ans.at(B.at(i)-1) = 1;
      ans.at(A.at(i)-1) = 1;
    }
    else{
      ans.at(A.at(i)-1) = 1;
    }
  }
      
  int answer = 0;
  for (int i = 0; i<N; i++){
    if (ans.at(i) == 0){
      answer++;
    }
  }
      cout << answer << endl;
}

Measured memory_bytes: 5084
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)

map<string,int> dict;
int getId(string s) {
  if (dict.find(s) == dict.end()) {
      int n = dict.size();
      dict.insert(make_pair(s, n));
      return n;
  }
  return dict[s];
}

int price[128];
bool edge[128][128];
int ref[128];

int main() {
  for (;;) {
      dict.clear();
      memset(edge,0,sizeof(edge));
      int N; cin >> N; if (!N) break;
      REP(i, N) {
          string s;
          int p; cin >> s >> p;
          price[getId(s)] = p;
      }
      int M; cin >> M;
      REP(i, M) {
          string goal;
          int K;
          cin >> goal >> K;
          REP(k, K) {
              string elem;
              cin >> elem;
              edge[getId(elem)][getId(goal)] = true;
          }
      }
      memset(ref, 0, sizeof(ref));
      REP(i, N) REP(j, N) {
          if (edge[i][j]) ++ref[j];
      }
      for (;;) {
          bool update = false;
          REP(i, N) if (ref[i] == 0) {
              update = true;
              ref[i] = -1;
          }

          REP(i, N) if (ref[i] != -1) {
              int cnt = 0;
              REP(j, N) if (edge[j][i] && ref[j] == -1) ++cnt;
              if (cnt == ref[i]) {
                  int buy = 0;
                  REP(j, N) if (edge[j][i]) buy += price[j];
                  if (cnt > 0 && buy < price[i])
                      price[i] = buy;
                  ref[i] = 0;
              }
          }
          if (!update) break;
      }

      string goal; cin >> goal;
      cout << price[getId(goal)] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
t = [[1,2],[-1,3],[1,-1],[4,5],[5,2],[2,1]]
while 1:
    s = raw_input()
    if s=='#': break
    q = 0
    for i in xrange(len(s)):
        if q==-1: break
        q = t[q][int(s[i])]
    print "Yes" if q==5 else "No"

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

using namespace std;

int n, m;
int c[20];
int dp[21][50001];

int solve(int idx, int sum) {

    if(sum == 0) return 0;
    if(idx == m) return 1 << 24;

    if(dp[idx][sum] != -1) return dp[idx][sum];

    int ret = 1 << 24;

    if(c[idx] <= sum) {
        ret = min(ret, solve(idx, sum - c[idx]) + 1);
        ret = min(ret, solve(idx + 1, sum - c[idx]) + 1);
    }
    ret = min(ret, solve(idx + 1, sum));

    return dp[idx][sum] = ret;

}

int main() {

    cin >> n >> m;

    for(int i = 0; i < m; ++i) {
        cin >> c[i];
    }

    memset(dp, -1, sizeof(dp));

    cout << solve(0, n) << endl;

}

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

using namespace std;

int main()
{
    long long n;
    cin >> n;
    auto solve=[](long long n,long long k)->bool
    {
        while((n%k)==0) n/=k;
        return ((n%k)==1);
    };
    long long res=0;
    for(long long i=2;i*i<=n;i++)
    {
        if((n%i)>0) continue;
        res+=solve(n,i);
        if(i!=n/i) res+=solve(n,n/i);
    }
    res+=solve(n,n);
    long long x=1;
    while(x<=n)
    {
        long long l=x,r=n+1;
        while(l<r-1)
        {
            long long m=(l+r)/2;
            if(n/x==n/m) l=m;
            else r=m;
        }
        if((n%l)==1) res++;
        else if(x<l&&(n%(l-1))==1) res++;
        x=l+1;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int t;
		
		if (a > b) {
			t = a;
			a = b;
			b = t;
		} 
		
		if (b > c) {
			t = b;
			b = c;
			c = t;
		}
		
		if (b < a) {
			t = b;
			b = a;
			a = t;
		}
		
		System.out.println(a + " " + b + " " + c);
	}

}



Measured memory_bytes: 26076
program main
	implicit none
	integer :: N, ans, i, j
	integer, allocatable :: H(:)
	read(*, *) N
	allocate(H(1:N))
	read(*, *) H
	ans = N
	do i = 2, N
		do j = 1, i-1
			if(H(j) > H(i)) then
				ans = ans -1
				exit
			end if
		end do
	end do
	write(*, *) ans
end program main

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include<tuple>

using namespace std;

int main() {
	string str;
	long long K;

	cin >> str >> K;

	int pos = 0;
	while (pos < str.length() && str[pos] == '1') pos++;

	if (pos < K)cout << str[pos] << endl;
	else cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    if ((N ==1 && A != B) || A > B) {
        cout << 0 << endl;
    } else {
        cout << ((N-1) * B + A) - ((N-1) * A + B) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
#define cons 1000000007 
using namespace std;

signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
 
    int n, i;
    cin>>n;
    int h[n];
    for(i=0;i<n;i++){
        cin>>h[i];
    }
    h[0]--;
    for(i=1;i<n;i++){
        if(h[i]>h[i-1])
            h[i]--;
    }
    for(i=1;i<n;i++){
        if(h[i]<h[i-1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long ans;
    long long temp=n%1000;
    if(temp==0){
        ans=0;
    }
    else{
        ans=1000-temp;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
n,x,m = map(int,input().split())
mod = m
amari = [-1]*m
a = x
cnt = 1
l = 0
r = 0
while 1:
    # print(a)
    if cnt == n:
        break
    
    if amari[a] != -1:
        l = amari[a]
        r = cnt
        # print(a,amari[a])
        break
    else:
        amari[a] = cnt
    cnt += 1
    a = ((a % m)**2) % m
    # if cnt > m:
    #     print("error")
    #     exit()
ans = 0
if cnt == n:
    l = 0
    r = n
# print(l,r)
a = x
temp = 0

for i in range(l-1):
    ans += a
    a = (a**2) % mod
# print(ans)


for i in range(r-l):
    temp += a
    a = (a**2) % mod
ans += temp * ((n-l+1)//(r-l))
# print(ans,a,temp,temp * (n-l)//(r-l),(n-l)//(r-l),temp * ((n-l)//(r-l)))


if r != n:
    for i in range((n-l+1)%(r-l)):
        ans += a
        a = (a**2) % mod
        # print(ans)
if n == 1:
    ans //=2
print(ans)

Measured memory_bytes: 66676
#include <bits/stdc++.h>
using namespace std;
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;


int main(){
    ios::sync_with_stdio(0);
	cin.tie(NULL);
    float n; cin>>n;
    cout<<fixed<<setprecision(12)<<(n/3.0)*(n/3.0)*(n/3.0)<<'\n';
    return 0;
}

Measured memory_bytes: 256