akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int data[9]={399,799,1199,1599,1999,2399,2799,3199,4800};
    int sta[9]={0};
    int n,i,j,tmp,min=0,max=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp<=399){
            sta[0]++;
        }
        for(j=0;j<8;j++){
            if((tmp>data[j])&&(tmp<=data[j+1])){
                sta[j+1]++;
            }
        }
    }
    for(i=0;i<8;i++){
        if(sta[i]>0){
            min++;
        }
    }
    max=min+sta[8];
    if(min==0){
        min++;
    }
    printf("%d %d\n",min,max);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <algorithm>
 
using namespace std;
 
int main(){
 int N=0;
 cin >> N;
 vector<int> vec(N);
 vector<int> vec2(N);
 
 for(int i=0; i<N; i++){
 cin>> vec.at(i);
 }  
 for(int i=0; i<N; i++){
 if(vec.at(i)%2==0){
   vec2.at(i)=vec.at(i);
 }  
 }
  
  for(int i=0;i<N;i++){
  if(vec2.at(i)%3!=0 && vec2.at(i)%5!=0){
     cout<<"DENIED"<<endl;
     return 0;
  }
  }
  cout<<"APPROVED"<<endl;
}

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

int64_t modpow(int64_t x, int64_t n) {
  const int MOD = 1000000007;

  x = x%MOD;
  if(n==0) return 1;  //再帰の終了条件

  else if(n%2==1) {
    return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
  }
  else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}


int main() {
  int n;
  cin>>n;
  int64_t a[n];
  for(int i=0; i<n; i++) cin>>a[i];
  const int MOD = 1000000007;

  int64_t sum = 0;
  for(int i=0; i<n; i++) {
    sum += a[i];
    sum = sum%MOD;
  }

  int64_t nijou = (sum*sum)%MOD;
  int64_t rest = 0;
  for(int i=0; i<n; i++) {
    rest += (a[i]*a[i])%MOD;
    rest = rest%MOD;
  }

  int64_t sub = nijou - rest;
  if(sub<0) sub += MOD;

  int64_t ans = sub*(modpow(2, MOD-2));
  // int64_t ans = sub/2;
  ans = ans%MOD;

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 5176
#include <stdio.h>

static int selectionSort(int A[], int N)
{
    int num_swaps = 0;

    for (int i = 0; i < N; i++) {
        int minj = i;

        for (int j = i + 1; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }

        if (minj != i) {
            int tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            num_swaps++;
        }
    }

    return num_swaps;
}

int main()
{
    int N;
    int A[100];

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

    int num_swaps = selectionSort(A, N);

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


Measured memory_bytes: 2104
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=(min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i])))
print(dp[n-1])

Measured memory_bytes: 13928
a = list(map(int, input().split()))
z = []
z.append(a[0]*a[2])
z.append(a[0]*a[3])
z.append(a[1]*a[2])
z.append(a[1]*a[3])
sum = z[0]
for i in range(0,len(a)):
  if sum < z[i]:
    sum = z[i]
print(sum)


Measured memory_bytes: 9184
using System;
namespace q1
{
    class q2
    {
        static void Main()
        {
            string n = Console.ReadLine();
            if (n == "RRR")
            {
                Console.WriteLine(3);
            }
            else if (n == "RRS"||n == "SRR")
            {
                Console.WriteLine(2);
            }
            else if (n == "SSS")
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }
        }
    }
}

Measured memory_bytes: 25876
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> s;
	s.push_back(a);
	s.push_back(b);
	s.push_back(c);
	sort(s.begin(), s.end());
	if (s[0] == 5 && s[1] == 5 && s[2] == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mm(a,b) memset(a,b,sizeof(a))
#define ACCELERATE (ios::sync_with_stdio(false),cin.tie(0))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<long long,long long>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
#define E exp(1.0)
#define db double
#define ll long long
#define ld long double
#define ull unsigned long long
//#define io
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
//#define gc getchar
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
//inline int read()
//{
//    int ret=0,f=0;char c=gc();
//    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
//    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
//    if(f)return -ret;return ret;
//}
char s[500];
int main()
{
    #ifdef io
    freopen("in.txt","r",stdin);
    #endif
    
    scanf("%s",s);
    printf("%s\n",s[0]=='S'?"Cloudy":(s[0]=='C'?"Rainy":"Sunny"));
    return 0;
}

Measured memory_bytes: 256
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t

int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    map<string, int> m;
    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    long ans = 0;
    for(auto it : m)
        ans += 1LL * it.second * (it.second - 1);
    cout << ans/2;
    return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll INF =1e9+7;
    typedef pair<ll,ll> ii;
    #define f(i,a,b) for(long long i = a;i < b;i++)
    #define rf(i,a,b) for(long long i=a;i>=b;i--)
    #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define w(t) while(t--)
    #define c(n); cin>>n;
    #define p(n) cout<<n;
    #define pl(n) cout<<n<<endl;
    #define ps(n); cout<<n<<" ";
    int main(void){
        fastio;
        ll n;
        c(n);
        if(n < 100){
            pl(0);
            return 0;
        }
        ll k = n / 100;
        if(k * 100 <= n && k * 105 >= n){
            pl(1);
        }
        else{
            pl(0);
        }
    }


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

int main()
{
  int w, a, b;
  cin >> w >> a >> b;
  if (a > b + w)
    cout << a - b - w << endl;
  else if (a + w < b)
    cout << b - a - w << endl;
  else
    cout << '0' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,k,cnt=0;
cin>>n;
int a[n],b[n];
for(i=0;i<n;i++)
    {cin>>a[i];b[i]=a[i];}
sort(b,b+n);
for(i=0;i<n;i++)
    if(b[i]!=a[i])
    cnt++;

    if(cnt>2)
        cout<<"NO\n";
    else
        cout<<"YES\n";




return 0; }


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 24.02.2018 15:11:31       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 303;

int f[N][N][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = (int) s.length();
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i; j < n; j++) {
      for (int p = 0; p <= k; p++) {
        if (i == j) {
          f[i][j][p] = 1;
          continue;
        }
        if (i + 1 == j) {
          f[i][j][p] = (s[i] == s[j] || p > 0) ? 2 : 1;
          continue;
        }
        f[i][j][p] = max(f[i + 1][j][p], f[i][j - 1][p]);
        if (s[i] == s[j]) {
          f[i][j][p] = max(f[i][j][p], f[i + 1][j - 1][p] + 2);
        }
        if (p > 0) {
          f[i][j][p] = max(f[i][j][p], f[i + 1][j - 1][p - 1] + 2);
        }
      }
    }
  }
  cout << f[0][n - 1][k] << endl;
  return 0;
}


Measured memory_bytes: 108800
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    map<ll, set<ll>> mp;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        mp[a].insert(i + 1);
    }
    mp[0].insert(0);

    set<ll> st;
    vector<ll> ans(N + 1, 0);
    for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
        auto next = itr;
        next++;
        if (next == mp.rend()) {
            break;
        }

        //setのマージ
        bool sw = (st.size() < itr->second.size());
        if (sw) {
            swap(st, itr->second);
        }
        for (auto e : itr->second) {
            st.insert(e);
        }

        ans[*st.begin()] += (itr->first - next->first) * st.size();
    }

    for (ll i = 1; i <= N; i++) {
        cout << ans[i] << endl;
    }
}

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

int main(){
  long long n;
  string s;
  long long count=0,min;
  cin >> n >> s;
  
  for(int i=1; i<n; i++){
    if(s[i] == 'E'){
      count++;
    }
  }
  
  min = count;
  
  for(int i=1; i<n; i++){
    if(s[i-1] == 'W') count++;
    if(s[i] == 'E') count--;
    if(min > count) min = count;
  }
  
  cout << min << endl;
}

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

void vec_show(vector<int> &vec) {
  for (int i = 0; i < vec.size(); ++i) {
    if (i == vec.size() - 1)
      cout << vec[i];
    else
      cout << vec[i] << " ";
  }
  cout << endl;
}

void insertSort(vector<int> &vec) {
  for (int i = 1; i < vec.size(); ++i) {
    int x = vec[i];
    int j = i - 1;
    while (vec[j] > x && j >= 0) {
      vec[j + 1] = vec[j];
      j--;
    }
    vec[j + 1] = x;
    vec_show(vec);
  }
}

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

  vec_show(A);
  insertSort(A);
}


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

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

   string s, t;
   cin >> s >> t;
   cout << t + s << endl;
   return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/python3


l=input()
M,D=l.split(" ")
M=int(M)
D=int(D)


c=0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1=(d%10)
        d10=int(d/10)
        #print(d,d1,d10)
        if m == d1*d10 and d1>=2 and d10>=2:
            c+=1
print(c)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;
long long dp[400][401];
int main()
{
    long long n;
    cin>>n;
    long long slimes[n],prefixes[n+1];
    prefixes[0]=0;
    for(int i=0;i<n;i++)
    {
        cin>>slimes[i];
        prefixes[i+1]=prefixes[i]+slimes[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++)
    {
        dp[i][1]=0;
    }
    for(int j=2;j<=n;j++)
    {
        for(int i=0;i<=n-j;i++)
        {
            for(int k=1;k<j;k++)
            {
                if(dp[i][k]!=-1&&dp[i+k][j-k]!=-1)
                {
                    if(dp[i][j]==-1)
                    dp[i][j]=prefixes[i+j]-prefixes[i]+dp[i][k]+dp[i+k][j-k];
                    else
                    dp[i][j]=min(dp[i][j],prefixes[i+j]-prefixes[i]+dp[i][k]+dp[i+k][j-k]);

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


Measured memory_bytes: 1536
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var X = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            var G = new List<List<int>>(X[0]);

            for (var i = 0; i < X[0]; i++) G.Add(new List<int>());

            for (var i = 0; i < X[1]; i++) {
                var a = Console.ReadLine().Trim().Split().Select(x => int.Parse(x) - 1).ToArray();
                G[a[0]].Add(a[1]);
                G[a[1]].Add(a[0]);
            }

            var Dist = new int[X[0]].Select(x => -1).ToArray();
            Dist[0] = 0;

            Queue<int> Q = new Queue<int>();
            Q.Enqueue(0);

            while (Q.Count != 0) {
                var a = Q.Dequeue();
                foreach (var g in G[a]) {
                    if (Dist[g] != -1) continue;

                    Dist[g] = a + 1;
                    Q.Enqueue(g);
                }
            }
            if (Dist.Contains(-1)) {
                Console.Write("No");
            } else {
                Console.WriteLine("Yes");
                for (var i = 1; i < X[0]; i++)
                    Console.WriteLine("{0}", Dist[i]);
            }
        }
    }
}

Measured memory_bytes: 52128
#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 <climits>
#include <cfloat>
using namespace std;

int main()
{
    vector<int> ret(4, 0);

    for(;;){
        vector<int> a(3);
        for(int i=0; i<3; ++i)
            cin >> a[i];
        sort(a.begin(), a.end());

        if(a[0] + a[1] <= a[2])
            break;
        ++ ret[0];

        int b = a[0] * a[0] + a[1] * a[1];
        int c = a[2] * a[2];
        if(b < c)
            ++ ret[3];
        else if(b > c)
            ++ ret[2];
        else
            ++ ret[1];
    }

    for(int i=0; i<3; ++i)
        cout << ret[i] << ' ';
    cout << ret[3] << endl;

    return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std ;
long long int power(long long int a,long long int n,long long int m) ;
 long long int power(long long int a,long long int n,long long int m)
{  if(n==0)
   return 1 ;
   long long int x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
int main()
{ long long int n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,m1,a;
  string s  ;
  cin>>n ;
  cin>>s ;
  int arr[n+1],brr[n+1],crr[n+1] ;
  arr[0]=0; brr[0]=0;crr[0]=0 ;
  sum=0 ;
  cnt=0 ;
  count=0 ;

  for(i=0;i<n;i++)
  { if(s[i]=='R')
     sum++ ;
   else  if(s[i]=='G')
        cnt++ ;
     else count++ ;
     arr[i+1]=sum ;
     brr[i+1]=cnt  ;
     crr[i+1]=count ;

  }
  sum=0 ;
   for(i=0;i<n-2;i++)
      {
          for(j=i+1;j<n-1;j++)
          {
              if(s[i]==s[j])
                continue ;
              else  { if(s[i]=='R'&&s[j]=='G'||(s[i]=='G'&&s[j]=='R'))
                        {
                            sum=sum+crr[n]-crr[j+1] ;
                             if((2*j)-i<n)
                             { if(s[2*j-i]=='B')
                             sum-- ; }

                        }
                        else if(s[i]=='R'&&s[j]=='B'||(s[i]=='B'&&s[j]=='R'))
                        {
                            sum=sum+brr[n]-brr[j+1] ;
                            if((2*j)-i<n)
                          {

                           if(s[2*j-i]=='G')
                             sum-- ; }

                        } else
                        {
                            sum=sum+arr[n]-arr[j+1] ;
                            if((2*j)-i<n)
                            {


                            if(s[2*j-i]=='R')
                             sum-- ; }

                        }


                     }
          }
      } cout<<sum ;
      return 0 ;  }


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

#define INF 1000000001
using namespace std;

long counter = 0;

void merge(vector<int> &A,const int left,const int mid,const int right){
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1+1,0),R(n2+1,0);
    for(int i = 0;i < n1;i++) L[i] = A[left + i];
    for(int i = 0;i < n2;i++) R[i] = A[mid  + i];
    L[n1] = INF;R[n2] = INF;
    int j = 0,k = 0;
    for(int i = left;i < right;i++){
        if(L[j] <= R[k]){
            A[i] = L[j];
            j++; 
        }else if(L[j] > R[k]){
            counter += (long)L.size() - j-1;
            A[i] = R[k];
            k++;
        }
    }
}

void mergeSort(vector<int> &A,int left,int right){
    if(left + 1 < right){
        int mid = (left + right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);

    }
}


int main(){
    int flag = 0;
    int len_array;
    int temp;
    scanf("%d",&len_array);
    
    vector<int> int_array(len_array,0);
    for(int i = 0;i < len_array;i++){
        scanf("%d",&temp);
        int_array[i] = temp;
    } 
    
    mergeSort(int_array,0,len_array);
    
    // for(int i = 0;i < len_array;i++){
    //     printf("%d",int_array[i]);
    //     if(i < len_array-1) printf(" ");
    //     else printf("\n");
    // }
    printf("%ld\n",counter);
    return 0;   
}



Measured memory_bytes: 4412
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    int D;
    cin >> D;
    cout << (N + 2 * D) / (2 * D + 1) << endl;
}


Measured memory_bytes: 3588
n,l=map(int,input().split())
arr=list(map(int,input().split()))
pos=0
tmp=0
for i in range(n-1):
  if (arr[i]+arr[i+1])>tmp:
    pos=i
    tmp=(arr[i]+arr[i+1])
if tmp<l:
  print('Impossible')
else:
  print('Possible')
  ans=[]
  for i in range(pos):
    ans.append(i+1)
  for i in range(n-1,pos+1,-1):
    ans.append(i)
  ans.append(pos+1)
  for i in range(n-1):
    print(ans[i])

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

int main() {
  int x, y;
  cin >> x >> y;
  bool same = false;
  if (x==1) {
    if (y==3||y==5||y==7||y==8||y==10||y==12) same = true;
  }
  else if (x==3) {
    if (y==5||y==7||y==8||y==10||y==12) same = true;
  }
  else if (x==4) {
    if (y==6||y==9||y==11) same = true;
  }
  else if (x==5) {
    if (y==7||y==8||y==10||y==12) same = true;
  }
  else if (x==6) {
    if (y==9||y==11) same = true;
  }
  else if (x==7) {
    if (y==8||y==10||y==12) same = true;
  }
  else if (x==8) {
    if (y==10||y==12) same = true;
  }
  else if (x==9&&y==11) same = true;
  else if (x==10&&y==12) same = true;
  if (same) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self):
        self.number = [i for i in range(6)]
        self.command_allpattern = "NNNNENNNNENNNNENNNNNENNNNEENNNNWWWSE"

    def set_number(self, d0, d1, d2, d3, d4, d5):
        self.number[0] = d0
        self.number[1] = d1
        self.number[2] = d2
        self.number[3] = d3
        self.number[4] = d4
        self.number[5] = d5

    def roll(self, command):
        if   command == "E":
            self.set_number(self.number[3],self.number[1],self.number[0],self.number[5],self.number[4],self.number[2])
        elif command == "N":
            self.set_number(self.number[1],self.number[5],self.number[2],self.number[3],self.number[0],self.number[4])
        elif command == "S":
            self.set_number(self.number[4],self.number[0],self.number[2],self.number[3],self.number[5],self.number[1])
        elif command == "W":
            self.set_number(self.number[2],self.number[1],self.number[5],self.number[0],self.number[4],self.number[3])
        else:
            raise

    def get_top(self):
        return self.number[0]

    def get_d2(self, d0, d1):
        flag_correct = False
        
        for command in self.command_allpattern:
            self.roll(command)

            if ((d0 == self.number[0]) and
                (d1 == self.number[1])):
                d2 = self.number[2]
                flag_correct = True

        if flag_correct:
            return d2
        else:
            raise



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

dice = Dice()
dice.set_number(list_face[0], list_face[1], list_face[2], list_face[3], list_face[4], list_face[5])


q = int(input())

for _ in range(q):

    d0, d1 = map(int, input().split())

    print(dice.get_d2(d0, d1))



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

const int N = (int) 2e5 + 5;

int n;
int a[N];
bool f[N * 5];
int cnt[N * 5];

int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	vector <int> v;
	cin >> n;
	int res = 0;
	for (int i = 1; i <= n; i++) cin >> a[i], v.push_back(a[i]), cnt[a[i]]++;
	sort(v.begin(), v.end());
	v.resize(distance(v.begin(), unique(v.begin(), v.end())));
	for (int i = 0; i < v.size(); i++) {
		if (f[v[i]] == 0 && cnt[v[i]] == 1) res++;
		for (int j = v[i]; j <= 1000000; j += v[i]) f[j] = 1;
	}
	cout << res;
	return 0;
}

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


int main(){
  string S;
  cin>>S;
  if(S=="SUN")printf("7");
  if(S=="SAT")printf("1");
  if(S=="FRI")printf("2");
  if(S=="THU")printf("3");
  if(S=="WED")printf("4");
  if(S=="TUE")printf("5");
  if(S=="MON")printf("6");
  printf("\n");
}

Measured memory_bytes: 3648
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int pow(int a, int x){
    int t = 1;
    for(int i = 0 ; i < x ; i++){
        t *= a;
    }
    return t;
}

int main(){
    int d, n;
    cin >> d >> n;
    vector<int> vec(n);
    int tmp = 1;
    for(int i = 0 ; i < n ; i++){
        if(tmp % 100 == 0){
            tmp++;
        }
        vec[i] = pow(100, d) * tmp;
        tmp++;
    }
    cout << vec[n-1] << endl;
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  string ans=s;

  rep(i,s.size()){
    if(s[i]=='?'){

      ans[i]='D';

    }

  }
  
  cout<<ans<<endl;
  
  
  
}


Measured memory_bytes: 3924
#include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<int> V;
  for(int i = 0; i*i < 1<<15; ++i) V.push_back(i*i);
  int n;
  while(cin >> n, n){
    int ans = 0;
    for(int i = 0; V[i] < n; ++i){
      for(int j = i; V[i]+V[j] < n; ++j){
	for(int k = j; V[i]+V[j]+V[k] < n; ++k){
	  for(int l = k; V[i]+V[j]+V[k]+V[l] <= n; ++l){
	    if(V[i]+V[j]+V[k]+V[l] == n) ++ans;
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define dump(x)  cerr << #x << " => " << (x) << endl
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define EQ(a,b) (abs(a - b) < 1e-10)
#define withinRange(w,h,W,H) (0 <= h && h <= (H-1) && 0 <= w && w <= (W-1))

using namespace std;
typedef long long LL;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
// LONG_MAX,LLONG_MAX
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class Key,class Value> ostream& operator << (ostream &s, map<Key,Value> M)
{ for ( auto itr = begin(M); itr != end(M); ++itr) { s << itr->first << ":" << itr->second; } return s;}


typedef struct Result {
    int dist;
} Result;

typedef struct State {
    int x;
    int y;
    int dist;
} State;


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vector<string> A(H);
    vector<vector<Result>> result(H, vector<Result>(W, { -1 }));
    vector<State> queue;
    REP(i,H) {
        cin >> A[i];
        REP(j,W) {
            if (A[i][j] == '#') {
                queue.push_back({ j, i, 0});
                result[i][j] = {0};
            }
        }
    }

    
    for (int i = 0;i < queue.size();i++) {
        State cur = queue[i];
        for (int j = 0;j < 4;j++) {
            if ( withinRange((cur.x)+dx[j],(cur.y)+dy[j],W,H) && result[(cur.y)+dy[j]][(cur.x)+dx[j]].dist == -1 ) {
                result[(cur.y)+dy[j]][(cur.x)+dx[j]] = { (cur.dist) + 1 };
                queue.push_back({ (cur.x)+dx[j],(cur.y)+dy[j] , (cur.dist) + 1});
            }
        }
    }
    int ans = 0;
    REP(i,H) {
        REP(j,W) {
            ans = max(ans,result[i][j].dist);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 19308
#include<iostream>
using namespace std;
struct card{
	char suit,value;
};
void bubble(struct card a[],int n)
{
	for(int i=0;i<n;i++)
	{
		for(int j=n-1;j>=i;j--)
		{
			if(a[j].value<a[j-1].value)
			{
				card t=a[j];a[j]=a[j-1];a[j-1]=t;
			}
		}
	}
}
void selection(struct card a[],int n)
{
	for(int i=0;i<n;i++)
	{
		int minj=i;
		for(int j=i;j<n;j++)
		{
			if(a[j].value<a[minj].value) minj=j;
		}
		card t=a[i];a[i]=a[minj];a[minj]=t;
	}
}
void ptint(struct card a[],int n)
{
	for(int i=0;i<n;i++)
	{
		if(i>0) cout<<" ";
		cout<<a[i].suit<<a[i].value;
	}
	cout<<endl;
}
bool is(struct card c1[],struct card c2[],int n)
{
	for(int i=0;i<n;i++)
	{
		if(c1[i].suit!=c2[i].suit) return false;
	}
	return true;
}
int main()
{
	card c1[100],c2[100];
	int n;
	char ch;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c1[i].suit>>c1[i].value;
	}
	for(int i=0;i<n;i++)
	c2[i]=c1[i];
	bubble(c1,n);
	selection(c2,n);
	ptint(c1,n);
	cout<<"Stable"<<endl;
	ptint(c2,n);
	if(is(c1,c2,n))
	{
		cout<<"Stable"<<endl;
	}
	else
	{
		cout<<"Not stable"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
package main

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

func main() {
	N, _, W := ReadInt(), ReadInt(), ReadInt()
	a := ReadInts(N)
	if N == 1 {
		fmt.Println(Abs(W - a[0]))
	} else {
		fmt.Println(Max(Abs(W-a[N-1]), Abs(a[N-1]-a[N-2])))
	}
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1888
#include <iostream>
using namespace std;
int main(void){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h){
        cout<<"Yes"<<endl;
    }
    else{cout<<"No"<<endl;}
}



Measured memory_bytes: 3108
import java.util.Scanner

import scala.util.Random


object Main {


  def read() = {
    val sc = new Scanner(System.in)
    val s = sc.next()
    s
  }

  def solve(s: String): Long = {
    val ps = s.replace("BC", "K").replace("B", "X").replace("C", "X")
    val n = ps.length

    // sは使わない
    //println(ps.mkString(" ")) //TODO: 提出前削除
    //i=>(i含めて)iより右で一番左のもの

    def makeRightX() = {
      val rightX = Array.fill(n)(-123)
      var idx = n - 1
      var currentRX = n
      while (idx >= 0) {
        if (ps(idx) == 'X') {
          currentRX = idx
        }
        rightX(idx) = currentRX

        idx -= 1
      }
      rightX
    }

    val rightX = makeRightX()
    //println(rightX.mkString(" ")) // TODO

    val cumSumK = ps.map(c => if (c == 'K') 1 else 0).scanLeft(0L)(_ + _)

    def countK(begin: Int, end: Int): Long = cumSumK(end) - cumSumK(begin)

    val hoge:IndexedSeq[Long] = ps.zipWithIndex.map {
      case (c, i) => if (c == 'A') countK(i, rightX(i)) else 0L
    }
    //println(hoge.mkString(" "))
    hoge.sum
  }

  //愚直
  def solve2(s: String): Long = {
    var mutS = s
    var cnt = 0
    while (mutS.contains("ABC")) {
      mutS = mutS.replaceFirst("ABC", "BCA")
      cnt += 1
    }
    cnt
  }

  def readRand(): String = {
    val charList = "AABC"
    val n = 1 + Random.nextInt(16)
    val s = (0 until n).map(_ => charList(Random.nextInt(4))).mkString
    s
  }

  def experiment(): Unit = {
    for (_ <- 0 until 10000000) {
      val s = readRand()
      val result1 = solve(s)
      val result2 = solve2(s)
      if (result1 != result2) {
        println(s)

        println(s"${result1 == result2}, (result1=$result1, result2=$result2)")
      }
    }
  }

  def main(args: Array[String]): Unit = {
    val s = read()
    println(solve(s))
    //println(solve2(s))
  }
}

Measured memory_bytes: 63640
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    dp = [[0 for _ in range(N)] for _ in range(N)]
    for length in range(1, N + 1):
        for left in range(N - length + 1):
            right = left + length - 1
            val = 0
            if left == right:
                val = A[left]
            else:
                val = max([
                    A[left] - dp[left + 1][right],
                    A[right] - dp[left][right - 1]
                ])
            dp[left][right] = val
    print(dp[0][N - 1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 120156
list_ABC = [ list(input()) for _ in range(3) ]
ans = 0
d = "a"
list_ABC[0].append(0)
list_ABC[1].append(0)
list_ABC[2].append(0)
while True:
    if len(list_ABC[0]) == 0:
        ans = "A"
        break
    elif len(list_ABC[1]) == 0:
        ans = "B"
        break
    elif len(list_ABC[2]) == 0:
        ans = "C"
        break

    if d == "a":
        d = list_ABC[0].pop(0)
    elif d == "b":
        d = list_ABC[1].pop(0)
    elif d == "c":
        d = list_ABC[2].pop(0)

print(ans)

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val N = readString()
    val K = readInt()
    val dp = Array(N.length + 1) { Array(2) { LongArray(K + 1) { 0 } } }
    dp[0][1][0] = 1L

    for (i in 1..N.length) {
        dp[i][0][0] = 1
        dp[i][1][0] = 0
        val n = N[i - 1] - '0'
        for (k in 1..K) {
            dp[i][0][k] = dp[i - 1][0][k] + dp[i - 1][0][k - 1] * 9
            if (n != 0)
                dp[i][0][k] += dp[i - 1][1][k] + dp[i - 1][1][k - 1] * (n - 1)

            dp[i][1][k] = if (n == 0) dp[i - 1][1][k] else dp[i - 1][1][k - 1]
        }
    }
    println(dp[N.length][0][K] + dp[N.length][1][K])
}

fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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

int gcd(int a,int b)
{
	if (a%b==0) return(b);
	else return(gcd(b,a%b));
}


int main(void){

	int N, X; cin >> N >> X;
	vector<int> x(N);
	REP(i,N){
		int v; cin >> v;
		x[i] = abs(X-v);
	}

	int ans = x[0];
	FOR(i,1,N){
		ans = gcd(ans, x[i]);
	}

	cout << ans << endl;



	return 0;

}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(2500)
 
def erase(x, y):
    c[y][x] = '0'
    for dx, dy in ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)):
        nx, ny = x + dx, y + dy
        if 0 <= nx < w and 0 <= ny < h and c[ny][nx] == '1':
            erase(nx, ny)
 
while True:
    w, h = map(int, input().split())
    if w == h == 0:
        break
    c = [sys.stdin.readline().split() for _ in range(h)]
    ans = 0
    for y in range(h):
        for x in range(w):
            if c[y][x] == '1':
                ans += 1
                erase(x, y)
    print(ans)

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll P = 1e9+7;



int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll t=1;
	// cin>>t;

	while(t--){
		ll n;
		cin>>n;

		vector<ll> v(n),p(n);
		for(ll i=0;i<n;++i) cin>>v[i];

		p = v;
		for(ll i=p.size()-2;i>=0;--i) p[i] = (p[i] + p[i+1])%P;
		ll ans = 0;
		for(ll i=0;i<n-1;++i){
			ans += (v[i]*(p[i+1])) % P;
			ans %= P;
		}

		cout<<ans<<"\n";
	}	

	return 0;
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = 100500;

int n, A[MAXN];

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d", &n) >= 1){
        forn(i, n)scanf("%d", &A[i]);
        int sz = 1, ans = 0;
        forr(i, 1, n){
            if(A[i] == A[i-1])sz++;
            else{
                ans += sz/2;
                sz = 1;
            }
        }ans += sz/2;
        printf("%d\n", ans);
    }
	return 0;
}


Measured memory_bytes: 256
/* #                          */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <deque>
#include <map>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;

constexpr int               inf = 0x3f3f3f3f;
constexpr long long 		INF = 9123456789123456789;
constexpr long long         MOD = 1000000007LL;
/*************************************************/
vvl dp0, dp1;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

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

    dp0.assign(n+1, vl(k+1, 0));
    dp1.assign(n+1, vl(k+1, 0));

    dp0[0][0] = 1;
    for(int i=0; i<n;i++)
        for (int j = 0; j <= k; j++) {
            dp1[i + 1][j] += dp1[i][j];
            if (s[i] == '0') dp0[i + 1][j] += dp0[i][j];
            else             dp1[i + 1][j] += dp0[i][j];
            for (char ch = '1'; ch <= '9'; ch++) {
                if (j + 1 <= k && s[i] == ch) dp0[i + 1][j + 1] += dp0[i][j];
                if (j + 1 <= k) {
                    dp1[i + 1][j + 1] += dp1[i][j];
                    if (ch < s[i])
                        dp1[i + 1][j + 1] += dp0[i][j];
                }
            }
        }

    ll ans = dp0[n][k] + dp1[n][k];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*---------------Go Code GO---------------*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using Order_Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//(order) Set.order_of_key(); (pointer) Set.find_by_order();

#define PI acos(-1.0)
#define O_O                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define precision(a) fixed << setprecision(a)
#define endl '\n'
#define Flush cout << flush
#define LLMX 0x3fffffffffffffff

long long N;

int main()
{
    O_O;

    long long N, A, B;
    cin >> N >> A >> B;

    cout << max(0ll, B * (N - 1) + A - (A * (N - 1) + B) + 1) << endl;

    return 0;
}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

def main():
    S = input()
    l = len(S)

    T = S.replace('x', '')
    if T != T[::-1]:
        print(-1)
        exit()
    '''
    st, end = 0, l-1
    cnt = 0
    while True:
        if S[st] == S[end]:
            if st+1!=end:
                st += 1
                end -= 1
            else:
                st=end
        elif S[st] == 'x':
            st += 1
            cnt += 1
        elif S[end] == 'x':
            end -= 1
            cnt += 1
        if st==end:
            break
    print(cnt)
    '''
    zero_list = []
    cnt = 0

    for i in range(l):
        if S[i] == 'x':
            cnt += 1
        elif i>0:
            zero_list.append(cnt)
            cnt = 0
        elif i==0:
            zero_list.append(cnt)
    zero_list.append(cnt)
    '''
    #for i in range(l):
    i = 0
    while i < l:
        j = i
        while j<l and S[j]=='x':
            j += 1
        zero_list.append(j-i)
        i = j+1
    '''
    lz = len(zero_list)
    ans = 0
    for i in range(lz//2):
        ans += abs(zero_list[i] - zero_list[lz-1-i])
    print(ans)
        
if __name__ == "__main__":
    main()


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

bool judge(char c){
    return c == 'A' || c == 'T' || c == 'G' || c == 'C';
}

int main()
{
    string str;
    int max_sum = 0, sum=0;
    cin >> str;
    for(int i=0;i<str.size();i++){
        if(judge(str[i])){
            sum++;
        }
        else{
            max_sum = max_sum > sum ? max_sum : sum;
            sum = 0;
        }
    }
    max_sum = max_sum > sum ? max_sum : sum;
    cout << max_sum << endl;;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vpp vector<pair<long long,long long>>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define c1(x) cin>>(x)
#define c2(x,y) cin>>(x)>>(y)
#define c3(x,y,z) cin>>(x)>>(y)>>(z)
#define c4(w,x,y,z) cin>>(w)>>(x)>>(y)>>(z)
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(int i=a;i<b;i++)
#define alld(c) (c).rbegin(),(c).rend()
#define alli(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;




int main() 
{ 
	int n,m;
	sfi(n);
	sfi(m);

	if(m>=n)
	{
		d1("unsafe");
	}
	else
		d1("safe");
	return(0);
}

Measured memory_bytes: 3688
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int ans = 0;
    int j = 1;
    rep(i, N) {
        cin >> a[i];
        if (a[i] != j) {
            ans++;
        }
        else j++;
    }
    if (ans == N)cout << "-1" << endl;
    else cout << ans << endl;
}


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

int n, m;

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a;
    scanf("%d", &a);
    n -= a;
  }

  if (n < 0) printf("-1\n");
  else printf("%d\n", n);

  return 0;
}


Measured memory_bytes: 3764
import java.util.*;
public class Main{
	public static void main(String[] args){
	Scanner sc= new Scanner (System.in);
	double a,b,c,d,e,f;
	
	while(sc.hasNextInt()){
		a=sc.nextInt();
		int tmp=(int) a;
		b=sc.nextInt();
		int tmp2=(int) b;
		c=sc.nextInt();
		int tmp3=(int) c;
		d=sc.nextInt();
		e=sc.nextInt();
		f=sc.nextInt();
		a*=d; b*=d; c*=d;
		d*=tmp;e*=tmp; f*=tmp;
		b-=e;c-=f;
		b=c/b;
		double ans=(tmp3-b*tmp2)/tmp;
		System.out.printf("%.3f %.3f\n",ans,b);
	}
	}
}

	

Measured memory_bytes: 18196
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int H,W;cin>>H>>W;
  int n;cin>>n;
  vector<int>vi(n);
  for(int i=0;i<n;i++)
    cin>>vi[i];
  int Ma[H][W]={};
  int pointer=0;
  int si=0;
  for(int i=0;i<H;i++){
    if(i%2){
      for(int j=0;j<W;j++){
	Ma[i][j]=si+1;
	pointer++;
	if(pointer>=vi[si]){
	  pointer=0;
	  si++;
	}
      }
    }else{
      for(int j=W-1;j>=0;j--){
	Ma[i][j]=si+1;
	pointer++;
	if(pointer>=vi[si]){
	  pointer=0;
	  si++;
	}
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<Ma[i][j];
      if(j!=W-1)
	cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

int main(){
  int n,j;
  vector<int> l;
  cin >> n;
  REP(i,2*n){
    cin >> j;
    l.push_back(j);
  }
  SORT(l);
  int m=0;
  REP(i,n){
    m+=l[2*i];
  }
  cout << m;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<set>
#define MAX 1299710
using namespace std;

bool isPrime[MAX];
set<int> pNum;
void prime(){
  isPrime[0]=isPrime[1]=true;
  for(int i=2;i<MAX;i++){
    if(isPrime[i]==false)pNum.insert(i);
    for(int j=2*i;j<MAX;j+=i)isPrime[j]=true;
  }
}

int main(){
  prime();
  int n;
  while(cin>>n,n){
    int forward,back;
    set<int>::iterator ite;
    ite=pNum.lower_bound(n);
    forward=*ite;
    if(forward!=n && n!=2)ite--;
    back = *ite;
    cout << forward-back << endl;
  }
  return 0;
}

Measured memory_bytes: 7148
#include <stdio.h>

int main(void)

{

int a,b,c,t;

scanf("%d %d %d",&a,&b,&c);

if(a>b){
t=a;
a=b;
b=t;
}

if(b>c){
t=b;
b=c;
c=t;
}


if(a>b){
t=a;
a=b;
b=t;
}

printf("%d %d %d\n",a,b,c);


return 0;

}
 

Measured memory_bytes: 596
program main
implicit None
	integer::a,b,c,p,q
	
	read*,a,b,c
	
	if(b < a)then
		p = a;a = b;b = p
	endif
	
	if(c < b)then
		p = b;b = c;c = p
	endif
	
	if(b < a)then
		p = a;a = b;b = p
	endif
	
	p =(c-a)/2;a = a+2*p
	q =(c-b)/2;b = b+2*q
	
	c = a+b-c-c
	
	if (c == 0)then
		p = p+q
		else if(c == -1)then
		p = p+q+2
		else
		p = p+q+1
	endif
	
	print "(i0)",p
end program main

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

d = 2
ans = 0

while d * d <= n:
    if n % d != 0:
        d += 1
        continue
        
    z = d
        
    while n % z == 0:
        n //= z
        z *= d
        ans += 1
        
    while n % d == 0:
        n /= d
        
if n != 1:
    ans += 1
    
print(ans)

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

int main() {

    string S, T;

    cin >> S >> T;

    string ans = "No";
    
    if (S.substr(0, S.length()) == T.substr(0, T.length()-1)) ans = "Yes";

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
 
int main()
{ 
	ll n,l;
	cin>>n>>l;
	vector<string>vec;
	string ss;
 
	while(n--){
     
     cin>>ss;
     vec.push_back(ss);
 
  
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<vec.size();i++){
		cout<<vec[i];
	}
	
}

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

int main() {
  int n,ans=1e9+7;
  cin >> n;
  vector<int> x(n);
  for(int& e:x)cin >> e;
  sort(x.begin(),x.end());
  for(int i=x[0];i<=x[n-1];i++){
    int keisan=0;
    for(int k=0;k<n;k++)keisan=keisan+(x[k]-i)*(x[k]-i);
    ans = min(ans,keisan);
  }
   cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
al=list(map(int,input().split()))
al.sort()
ans=0
t=0
cnt=0
for i in range(n):
    if al[i]!=t:
        ans+=cnt-t if cnt>=t else cnt
        t=al[i]
        cnt=1
    else:
        cnt+=1
else:
    ans+=cnt-t if cnt>=t else cnt
print(ans)

Measured memory_bytes: 14692
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 入力数字の数 */
	private static final int N = 5;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.println(IntStream.rangeClosed(1, N).filter(i -> 0 == scanner.nextInt())
					.reduce((first, second) -> second).getAsInt());
		}
	}
}


Measured memory_bytes: 35952