akhauriyash/Code-Regression huggingface dataset:
s_dash = input()
t = input()
match_index = []
candidate = []
for i in range(len(s_dash) - len(t) + 1):
    for j in range(len(t)):
        if not(t[j] == s_dash[i + j] or s_dash[i + j] == '?'):
            break
        if j == len(t) - 1:
            match_index.append(i)
for index in match_index:
    s = s_dash[:index] + t
    if index != len(s_dash) - len(t):
        s += s_dash[index + len(t):]
    s = list(s)
    for i in range(len(s)):
        if s[i] == '?':
            s[i] = 'a'
    s = "".join(s)
    candidate.append(s)
candidate.sort()
if len(candidate) == 0:
    print('UNRESTORABLE')
else:
    print(candidate[0])

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

int main() {
  int N, X, m[101];
  cin >> N >> X;
  int S = 0, M = 1001001001;
  for (int i = 0; i < N; ++i){
    cin >> m[i];
    S += m[i];
    if (m[i] < M){
      M = m[i];
    }
}
  int ans = N+(X-S)/M;
  cout << ans << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll h, w;
  string tmp, x;
  cin >> h >> w;
  vector <string> s(h + 2);
  vecll dx = {1, 0, -1, 0, 1, -1, -1, 1};
  vecll dy = {0, 1, 0, -1, 1, 1, -1, -1};
  s[0] = string(w + 1, '.');
  forll(i, 1, h+1){
	cin >> x;
	tmp = "." + x;
    tmp += ".";
	s[i] = tmp;
  }
  s[h+1] = string(w + 1, '.');
  
  forll(i, 1, h+1){
	forll(j, 1, w+1){
	  if(s[i][j] == '.'){
		ll count = 0;
		forll(d, 0, 8){
		  if (s[i+dy[d]][j+dx[d]] == '#')
			count++;
		}
		s[i][j] = char('0' + count);
	  }
	}
  }
  forll(i, 1, h+1){
	s[i].pop_back();
	s[i].erase(s[i].begin());
	cout << s[i] << endl;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	static final int ROW = 0;
	static final int COLUMN = 1;
	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		int[][] matrix = new int[n + 1][2];

		for(int i = 1; i < n + 1 ; i++){
			String[] tmpArray = br.readLine().split(" ");
			matrix[i][ROW] = Integer.parseInt(tmpArray[ROW]);
			matrix[i][COLUMN] = Integer.parseInt(tmpArray[COLUMN]);
		}
		
		int[][] DPResult = new int[n + 1][n + 1];
		for(int i = 0 ; i < n + 1; i++){
			Arrays.fill(DPResult[i], 0);
		}
		
		//DP??§?¨??????§????????°????????????
		for(int i = 1; i <= n ; i++){
			for(int j = 1; j <= n - i ;j++){
				int currentI = j;
				int currentJ = i + j;
				if( currentI + 1 == currentJ ){
					//DPResult[i][j] = matrix[j][ROW]*matrix[j][COLUMN]*matrix[j + 1][COLUMN];
					DPResult[currentI][currentJ] = matrix[currentI][ROW] * matrix[currentI][COLUMN] * matrix[currentI + 1][COLUMN];
				}
				else {
					int tmpResult = Integer.MAX_VALUE;
					
					for(int k = currentI ; k < currentJ ; k++){
						int tmp;
						//System.out.println("I "+currentI+" J"+currentJ+" k"+k);
						tmp = DPResult[currentI][k] + DPResult[k+1][currentJ] 
								+ matrix[currentI][ROW]*matrix[k][COLUMN]*matrix[currentJ][COLUMN];
						if(tmp < tmpResult){
							tmpResult = tmp;
						}
						
						DPResult[j][j+i] = tmpResult;
					}
					
				}
			}
			
		}
		
		//TEST PRINT
		/*
		for(int i = 1; i <= n ; i++){
			for(int j = 1; j <= n ;j++){
				System.out.print(DPResult[i][j] + " ");
			}
			System.out.println();
		}*/
		System.out.println(DPResult[1][n]);
	}

}

Measured memory_bytes: 24652
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,t;
ll C,A,B,D,n;
int main(){
#ifdef LOCAL
	freopen("A.in","r",stdin);//freopen("A.out","w",stdout);
#endif
	scanf("%lld%lld%lld%lld%lld",&A,&B,&C,&D,&n);
	MIN(D,8*A);MIN(C,4*A);MIN(B,2*A);
	MIN(C,2*B);MIN(D,4*B);
	MIN(D,2*C);
	printf("%lld\n",n/2*D+(n&1)*C);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
	int x,a,b,i,j;
	scanf("%d %d %d",&x,&a,&b);
	i=abs(x-a);
	j=abs(x-b);
	if(i>=j)
		printf("B");
	else printf("A");
	return 0;
}
		 

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

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

  vector<vector<ll>> a(n, vector<ll>(3));
  for (ll i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];

  // dp[day][what he did yesterday] = total
  vector<vector<ll>> dp(n + 1, vector<ll>(3, 0));

  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < 3; j++) {
      ll next_i = i + 1;
      ll next_j1 = (j + 1) % 3;
      ll next_j2 = (j + 2) % 3;
      dp[next_i][next_j1] = max(dp[next_i][next_j1], dp[i][j] + a[i][next_j1]);
      dp[next_i][next_j2] = max(dp[next_i][next_j2], dp[i][j] + a[i][next_j2]);
    }
  }

  cout << max_element(dp[n].begin(), dp[n].end())[0] << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;
    
    if (s == "SSS") cout << 0 << endl;
    if (s == "SSR") cout << 1 << endl;
    if (s == "SRS") cout << 1 << endl;
    if (s == "SRR") cout << 2 << endl;
    if (s == "RSS") cout << 1 << endl;
    if (s == "RSR") cout << 1 << endl;
    if (s == "RRS") cout << 2 << endl;
    if (s == "RRR") cout << 3 << endl;   


    return 0;
}

Measured memory_bytes: 3632
N=int(input())
if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
    print('hon')
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9112
#include<stdio.h>

int main()
{
  int i,N,max=0,max_i,sum=0,L[100];
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++)
  {
  	scanf("%d",&L[i]);
  }
  
   for(i=0;i<N;i++)
  {
  	if(L[i]>max)
    {
      max=L[i];
      max_i=i;
    }
  }
 
  for(i=0;i<N;i++)
  {
  	if(i!=max_i)
    {
      sum+=L[i];
    }
  }
  
  if(max<sum)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  

  return 0;
}

Measured memory_bytes: 128
// default
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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;}

const long long INF = 1LL << 60;

int N;
long long W;
long long weight[110];
long long value[110];

long long dp[110][100100]={0};

void input(void){
    cin >> N >> W;
    for(int i=0; i< N; ++i){
        cin >> weight[i] >> value[i];
    }
    return;
}

void init(void){
    return;
}

void solve(){
    for(int i=0; i<N; ++i){
        for(int sum_w=0; sum_w <= W; ++sum_w){

            // i番目の品物を選ぶ場合
            if( (sum_w - weight[i]) >= 0){ //そもそもテンポラリサイズより余ってないとだめ
                
                // 更新先のマスに元からある値と、
                // 今いるマスの価値にからweightを引いたやつ（サイズが空いているところに価値を足したやつ）
                // 比較して大きいなら更新
                chmax(  dp[i+1][sum_w], 
                        dp[i][sum_w - weight[i]] + value[i]
                        );
            }
                //選ばないときは、そのままの値を表の下におろせるか確認する。
                chmax(  dp[i+1][sum_w],
                        dp[i][sum_w]
                        );


        }
    }
    cout << dp[N][W] << endl;
    return;
}

int main(void){
    input();
    init();
    solve();
    return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	int M;
	cin>>N>>M;
	float a[N];
	float sum=0;
	for(int i=0;i<N;i++){
		cin>>a[i];
		sum=sum+a[i];
	}
	float x=(sum/(4*M));
	int count =0;
	for(int j=0;j<N;j++){
		if(a[j]>=x){
			count++;
		}
	}
	if(count>=M){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

int main(void) {
    ll n;
    cin>>n;
    vl a(n);
    ll ans = 0;
    rep(i,n){
        cin>>a[i];
        ans += a[i]-1;
    }
    cout<<ans<<endl;
	return 0;
}


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int t = 0;
    while(a >= b)
    {
        b *= 2;
        t++;
    }
    while(b >= c)
    {
        c *= 2;
        t++;
    }
    if(t <= k)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  
  vector<vector<Int> > G(n);
  vector<Int> a(n);
  for(Int i=0;i<n;i++){
    cin>>a[i];
    a[i]--;
    if(~a[i]) G[a[i]].emplace_back(i);
  }

  vector<Int> dist(n,-1);
  queue<Int> qu;
  for(Int i=0;i<n;i++){
    if(G[i].empty()){
      dist[i]=0;
      qu.emplace(i);
    }
  }
  
  while(!qu.empty()){
    Int v=qu.front();qu.pop();
    if(a[v]<0||~dist[a[v]]) continue;
    dist[a[v]]=dist[v]+1;
    qu.emplace(a[v]);
  }
  
  Int ans=0;
  for(Int i=0;i<n;i++){
    if(a[i]<0||dist[i]<k) ans++;    
  } 
  cout<<ans<<endl;
  return 0;
}



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


def remain(a, b):
    if a == 'R':
        if b == 'G':
            return 'B'
        else:
            return 'G'
    elif a == 'G':
        if b == 'R':
            return 'B'
        else:
            return 'R'
    else:
        # a == 'B'
        if b == 'R':
            return 'G'
        else:
            return 'R'
    

n = int(input())
s = input()

cs = {}

cs['R'] = [ 0 for i in range(n) ]
cs['G'] = [ 0 for i in range(n) ]
cs['B'] = [ 0 for i in range(n) ]

for i in range(-1, - n - 1, -1):
    if s[i] == 'R':
        cs['R'][i] = cs['R'][i + 1] + 1
        cs['G'][i] = cs['G'][i + 1]            
        cs['B'][i] = cs['B'][i + 1]
    elif s[i] == 'G':
        cs['R'][i] = cs['R'][i + 1]
        cs['G'][i] = cs['G'][i + 1] + 1
        cs['B'][i] = cs['B'][i + 1]            
    elif s[i] == 'B':
        cs['R'][i] = cs['R'][i + 1]
        cs['G'][i] = cs['G'][i + 1]            
        cs['B'][i] = cs['B'][i + 1] + 1

            
c = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] != s[j]:
            r = remain(s[i], s[j])
            c += cs[r][j]
            if j + j - i < n and s[j + j - i] == r:
                c -= 1
            
print(c)


Measured memory_bytes: 74736
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x) 
const ll x=1000000000000001ll;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vlong fg;
  ll kake=26;
  int count=0;
  while(kake<=x){
      fg.push_back(kake);
      kake*=26;
      count++;
  }
  string a="a";
  string cp=a;
  string ans;
  while(n!=0){
    a=cp;
      if(n*26<fg[count]){
          count--;
          continue;
      }
    ll tmp=n-fg[count];
    n/=26;
    tmp=tmp%26;
    if(tmp==0){
      tmp=26;
      n--;
    }
    a[0]+=(tmp-1);
    //cout<<a<<'\n';
    ans+=a;
  }
  int si=ans.size();
  for(int i=si-1;i>=0;i--){
  	cout<<ans[i];
  }
  return(0);
}

Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
signed main(){
    int n,k,q;
    cin>>n>>k>>q;
    int p[114514];
    for(int i=0;i<n;i++)p[i]=k-q;
    for(int i=0;i<q;i++){
        int a;
        cin>>a;
        p[a-1]++;
    }
    for(int i=0;i<n;i++){
        if(p[i]>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
using namespace std;
const int M = 1000000007;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> cnt(26);
    for (auto c : s) cnt[c - 'a']++;
    int ans = 1;
    for (auto p : cnt) {
        ans *= (p + 1);
        ans %= M;
    }
    ans += (M - 1);
    ans %= M;
    cout << ans;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int ans=0;
void aout(void){
	cout<<ans<<endl;
}
void out(int a){
	cout<<a<<endl;
}
int main(void){
	int d[999],a,b,i,j;
	cin>>a>>b;
	d[0]=1;
	for(i=1;i<999;++i)d[i]=d[i-1]+i+1;
	for(i=1;i<999;++i){
		if(d[i]-d[i-1]==b-a){
			cout<<d[i]-b<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <climits>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

struct RMQ {
	int n;
	vector<int> t;
	RMQ (int l) :
		n(1 << (32 - __builtin_clz(l - 1))),
		t(n * 2, INT_MAX) {}
	void update(int i, int v) {
		i += n, t[i] = v;
		while (i > 1) {
			i >>= 1;
			t[i] = min(t[i << 1], t[i << 1 | 1]);
		}
	}
	int find(int a, int b) {
		int x = INT_MAX;
		for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
			if (a & 1) x = min(x, t[a++]);
			if (b & 1) x = min(x, t[--b]);
		}
		return x;
	}
};

int main() {
	RMQ r(in());
	for (int q = in(); q; q--) {
		int o = in(), x = in(), y = in();
		if (o)
			outl(r.find(x, y + 1));
		else
			r.update(x, y);
	}
}


Measured memory_bytes: 3324
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k,s;
int main()
{
	scanf("%d %d %d",&n,&k,&s);
	if(s==1000000000)
	{
		for(int i=1;i<=k;++i)printf("%d ",s);
		for(int i=k+1;i<=n;++i)printf("%d ",1);
	}
	else
	{
		for(int i=1;i<=k;++i)printf("%d ",s);
		for(int i=k+1;i<=n;++i)printf("%d ",1000000000);
	}
	return 0;
}


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

#define debug(x) cout << #x << ": " << (x) << endl

int main(int argc, char *argv[]) {
  int N, A;
  cin >> N >> A;
  int x[N];
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }

  long long dp[2*N*50 + 1];
  memset(dp, 0, sizeof(dp));
  dp[N*50] = 1;

  for (int i = 0; i < N; ++i) {
    int y = x[i] - A;
    int j = 0 < y ? 2*N*50 : 0;
    while (0 <= j - y and j - y <= 2*N*50) {
      dp[j] += dp[j - y];
      j += 0 < y ? -1 : 1;
    }
  }

  cout << dp[N*50] - 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
 
const double PI=3.141592653589793;
 
int main()
{
 
  //今回はdoubleじゃだめらしい
  //A*(B*100)/100にすることで、小数のBを整数にすることで楽にする
  ll A;
  double B;
  cin>>A>>B;
  ll ib = B * 100 + 0.5;  //doubleからllへのキャスト（切り捨て）なので、微妙な誤差が生じるらしい->0.1とか0.5とか足すと狙った整数になるらしい
 
  A *= ib;
  A /= 100;
  cout << A << endl;
 
  return 0;
}

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

class Program
{
    static void Main(string[] args) {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());
        int d = int.Parse(Console.ReadLine());
        int e = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int[] l = new int[10];
        l[0] = b - a;
        l[1] = c - a;
        l[2] = d - a;
        l[3] = e - a;
        l[4] = c - b;
        l[5] = d - b;
        l[6] = e - b;
        l[7] = d - c;
        l[8] = e - c;
        l[9] = e - d;
        Console.WriteLine(l.Where(x => x <= k).Count() == 10 ? "Yay!" : ":(");
    }
}

Measured memory_bytes: 11220
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
  char s[1001];
  char t[1001];
  int c;
  int retval = 0;
  if(scanf("%s",s)<1){
    exit(1);
  }
  if(scanf("%s",t)<1){
    exit(1);
  }
  int slen = strlen(s);
  int tlen = strlen(t);
  for(int i = 0; i <= (slen-tlen);i++){
    c = 0;
    for(int j = 0;j<tlen;j++){
      if(s[i+j]==t[j]){
        c++;
      }
    }
    if(c>retval){
      retval=c;
    }
  }
  printf("%d",tlen-retval);
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define repd(i,a,b) for (int i=a;i<int(b);i++)
#define rep(i,n) repd(i,0,n)
#define VARNAME(v) #v
using P = pair<int,int>;


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int BEAM = 750;
  int d;vector<int> c(26);cin>>d;rep(i,26)cin>>c[i];
  vector<array<int, 26>> s(d);
  rep(i,d)rep(j,26)cin>>s[i][j];
  vector<int> curs = {0};
  vector<array<int, 26>> curl(1);
  vector<vector<int>> cura(1);
  rep(i,d){
    int len = int(curs.size()) * 26, ind = 0;
    vector<P> nxs(len);
    vector<array<int, 26>> nxl(len);
    vector<vector<int>> nxa(len);
    rep(j, curs.size()){
      rep(t, 26){
        int score = curs[j];
        array<int, 26> last = curl[j];
        vector<int> ans = cura[j];
        score += s[i][t];
        last[t] = i+1;
        rep(k,26)score -= c[k]*(i+1 - last[k]);
        ans.emplace_back(t);
        nxs[ind] = P(score, ind);
        nxl[ind] = last;
        nxa[ind] = ans;
        ind++;
      }
    }
    sort(nxs.rbegin(), nxs.rend());
    len = min(len, BEAM);
    curs.resize(len);curl.resize(len);cura.resize(len);
    rep(j,len){
      curs[j] = nxs[j].first;
      curl[j] = nxl[nxs[j].second];
      cura[j] = nxa[nxs[j].second];
    }
    if(i % 73 == 0)BEAM -= 100;
  }
  int ans = 0;
  rep(i,min(int(curs.size()), BEAM)){
    if(curs[ans] < curs[i])ans = i;
  }

  for(auto x : cura[ans]){
    cout << x+1 << endl;
  }
}


Measured memory_bytes: 16332
import * as fs from "fs";

// inputで受け取り配列化する
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

const s = input[0];
const t = input[1];

let counter = 0;

for (let index = 0; index < s.length; index++) {
  if (s[index] !== t[index]) {
    counter++;
  }
}

console.log(counter);


Measured memory_bytes: 33004
import Data.List (group)
import Data.Bool (bool)
import qualified Data.Sequence as Q

main :: IO ()
main = do
  (n : k : _) <- map read . words <$> getLine :: IO [Int]
  s <- getLine :: IO String
  let
    s' = bool id (0 :) (head s == '0') . map length . group $ s
    (pr, sf) = splitAt (2 * k + 1) s'
    go (m, l, q) (l0 : l1 : ls) = let {(l1' Q.:< q') = Q.viewl q; (l0' Q.:< q'') = Q.viewl q'; l' = l - l1' - l0' + l0 + l1} in go (max m l', l', q'' Q.|> l0 Q.|> l1) ls
    go (m, l, q) (l0 : _) = let {(l1' Q.:< q') = Q.viewl q; (l0' Q.:< _) = Q.viewl q'; l' = l - l1' - l0' + l0} in max m l'
    go (m, _, _) _ = m
  print . go (sum pr, sum pr, Q.fromList pr) $ sf


Measured memory_bytes: 8572
#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 + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second

int main() {
  int n, m, tmp1;
  string tmp2;
  cin >> n >> m;
  vector<bool> acflg(n + 1, false);
  vector<int> wa(n + 1, 0);
  rep(i, m) {
    cin >> tmp1 >> tmp2;
    if (tmp2 == "AC") acflg[tmp1] = true;
    if (!acflg[tmp1]) {
      if (tmp2 == "WA") wa[tmp1]++;
    }
  }
  int acsum = 0;
  int wasum = 0;
  FOR(i, 1, n) {
    if (acflg[i]) {
      acsum++;
      wasum += wa[i];
    }
  }
  cout << acsum << " " << wasum << endl;

  return 0;
}


Measured memory_bytes: 3768
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		if(n >= k){
			System.out.println(k * x + (n - k) * y);
		}else {
			System.out.println(n*x);
		}
	}
}


Measured memory_bytes: 23636
#include<iostream>

int main(){
    int N, K;
    std::cin >> N >> K;
    // greedy
    int num = 1;
    for(int i = 0; i < N; i++){
        num = std::min(num + K, num * 2);
    }

    std::cout << num << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int a;
	cin >> a;
	cout << "ABC" << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)

using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


signed main() {
	int N,W;cin2(N,W);

	vi v(N+1,0),w(N+1,0);
	rep(i,1,N+1) {
		cin2(v[i],w[i]);	
	}
	
	
	vvi dp(N+1,vi(W+1,0));

	rep(i,1,N+1) {
		rep(j,1,W+1) {
			if (j - w[i] >= 0) {
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			}else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	
	cout(dp[N][W]);
	

	return 0;
}

Measured memory_bytes: 10820
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
const int rootN = 1555;
 
int freq[600000];
int distinct;
int ar[600000];
 
struct query
{
    int L;
    int R;
    int q_no;
    int block_no;
    bool operator < (query& q2)
    {
        if(block_no < q2.block_no)
            return 1;
        else if(block_no > q2.block_no)
            return 0;
        else return R < q2.R;
    }
};
 
void Add(int& elem)
{
    if(!freq[elem])distinct++;
    freq[elem]++;
}
void Remove(int& elem)
{
    freq[elem]--;
    if(!freq[elem])
        distinct--;
}
 
void adjust(int& curr_l, int& curr_r, query& q)
{
    while(curr_l > q.L)
    {
        curr_l--;
        Add(ar[curr_l]);
    }
    while(curr_r < q.R)
    {
        curr_r++;
        Add(ar[curr_r]);
    }
	while(curr_l < q.L)
    {
        Remove(ar[curr_l]);
        curr_l++;
    }
    while(curr_r > q.R)
    {
        Remove(ar[curr_r]);
        curr_r--;
    }
 
}
 
void solve(vector<query>& queries)
{
    vector<int> answer(queries.size());
    sort(queries.begin(), queries.end());
    memset(freq, 0, sizeof freq);
    distinct = 1;
 
    int curr_l = queries[0].L;
    int curr_r = queries[0].L;
 
    freq[ar[curr_l]]++;
 
    for(query& qr : queries)
    {
        adjust(curr_l, curr_r, qr);
        answer[qr.q_no] = distinct;
    }
 
    for(int x : answer)
            cout<<x<<'\n';
}
 
int main() {
   fast_io;
   int n,q;
   cin >> n >> q;
 
   map<int,int> coordinateCompress;
   int compressed_Num = 1;
 
   for(int i = 0; i < n; i++)
   {
       cin >> ar[i];
       if(coordinateCompress.find(ar[i]) != coordinateCompress.end()){
        ar[i] = coordinateCompress[ar[i]];
       }
       else{
        coordinateCompress[ar[i]] = compressed_Num;
        ar[i] = compressed_Num++;
       }
   }
 
   vector<query> queries(q);
   for(int i = 0; i < q; i++)
   {
       int u,v;
       cin >> u >>v;
       queries[i].L = u-1;
       queries[i].R = v-1;
       queries[i].q_no = i;
       queries[i].block_no = u/rootN;
   }
   solve(queries);
   return 0;
}

Measured memory_bytes: 41296
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
ll k;
int main(){
  cin>>k;
  ll r=(k-1)%50+1;
  ll m=50+(k-1)/50;
  ll a[60];
  rep(i,r){
    a[i]=m-i;
  }
  rep(i,50-r){
    a[r+i]=i+k/50;
  }
  prin(50);
  rep(i,50){
    cout<<a[i]<<" ";
  }
  cout<<"\n";
  

  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,d;
    cin >> n >> d;
    long long int x[n],y[n];
    long double z[n];
    int cnt = 0;
    for(int i = 0; i < n; i ++) {
        cin >> x[i] >> y[i];
        z[i] = sqrt(x[i] * x[i] + y[i] * y[i]);
        if(z[i] <= d){
            cnt++;
        }
    }   
    cout << cnt << endl;


    return 0;
}

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

lr=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
    li,ri=map(int,input().split())
    lr[li][ri]+=1
    
for i in range(n+1):
    asum=0
    for j in range(n+1):
        asum+=lr[i][j]
        lr[i][j]=asum
            
for i in range(q):
    pi,qi=map(int,input().split())
#    pi-=1
#    qi-=1
    asum=0
    for j in range(pi,qi+1):
#        print("j:",j,"j-1",j-1,"qo:",qi,lr[j][qi]-lr[j][j-1])
        asum+=lr[j][qi]-lr[j][j-1]
    print(asum)


Measured memory_bytes: 76828
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rng(i,a,b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define repd(i, n) for(ll i = (ll)(n)-1;i>=0;--i)
#define rngd(i,b,a) for(ll i = (ll)(b);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define ctoi(x) ((x)-'0')

int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<bool> > e(n,vector<bool>(n));
  vector<int> x(n);
  rep(i,n){
    x[i]=i;
  }
  rep(i,m){
    int a,b;
    cin>>a>>b;
    e[a-1][b-1]=1;
    e[b-1][a-1]=1;
  }
  int ans=0;
  int cnt=0;
  do{
    cnt=0;
    rep(i,n){
     if(i>=n-1){
        break;
      }
      if(e[x[i]][x[i+1]]){
        cnt++;
      }else{
        break;
      }
    }
    if(cnt==n-1){
      ans++;
    }
  }while(next_permutation(x.begin()+1,x.end()));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from statistics import *
from collections import *
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

li = na()
l = sum(li[:2])
r = sum(li[2:])
if l == r:
    print('Balanced')
elif r > l:
    print('Right')
else:
    print('Left')

Measured memory_bytes: 5528
N = int(input())
for i in range(N):
    lst = list(map(int, input().split()))
    B = 0
    C = 0
    r = 0
    for j in lst:
        if B < j:
            B = j
        elif C < j:
            C = j
        else:
            r = 1
            break
    
    if r:
        print('NO')
    else:
        print('YES')


Measured memory_bytes: 5592
n = gets.to_i
stones = gets.chomp

w = 0
r = stones.count('R')
answer = r

stones.each_char do |c|
  case c
  when 'W'
    w += 1
  when 'R'
    r -= 1
  end
  answer = [answer, [w, r].max].min
end

puts answer


Measured memory_bytes: 14636
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char ch = ' ';
  string sums = "";
  int alpha[26];
  for (int i = 0; i < 26; i++)
  {
    alpha[i] = 0;
  }
  while (scanf("%c", &ch) != EOF)
  {
    sums += ch;
  }
  for (int i = 0; i < sums.size(); i++)
  {
    if (sums.at(i) >= 65 && sums.at(i) <= 90)
    {
      alpha[sums.at(i) - 65]++;
    }
    else if (sums.at(i) >= 97 && sums.at(i) <= 122)
    {
      alpha[sums.at(i) - 97]++;
    }
  }
  for (int i = 0; i < 26; i++)
  {
    char c = i + 97;
    cout << c << " "
         << ":"
         << " " << alpha[i] << "\n";
  }
}


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

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

const long long MOD = 1000000007;

int main(){
  int n,k;
  cin >> n >>k;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n-k){
    if(a.at(i)<a.at(i+k)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 3980
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#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()
	


int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << ((A <= C && C <= B) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 10e9+5;
int main()
{
    int n,x,i,j,k;
    cin>>n>>k;
    vector<int>v;
    vector<int>dp(n,INF);
   for(i=1;i<=n;i++)
   {
       cin>>x;
       v.push_back(x);
   }
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<=i+k;j++)
        {
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		Long x = sc.nextLong();
		Long y = sc.nextLong();
		Long count = 0L;
		for(long l = x; l <= y; count++) {
			l *= 2;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23764
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others

//Hang in there!
//LOVE Ayane Sakura
//LOVE Nyantako_GG

using namespace std;


int main() {
	int N, M;
	cin >> N >> M;
	vector<int>data(M);
	for (int i = 0; i < N; i++) {
		int K;
		cin >> K;
		for (int j = 0; j < K; j++) {
			int A;
			cin >> A;
			data[A - 1]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		if (data[i] == N) {
			ans++;
		}
	}
	cout << ans << endl;
}


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

int main(){
  int N;
cin>>N;
  vector<long long>A(N),B(N+1);
  long long a,b,c,r;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  B[0]=A[0];
  for(int i=0;i<N;i++){
    a=A[i];
    b=B[i];
    if(b>a){
      c=b;
      b=a;
      a=c;
    }
r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  B[i+1]=b;
  }
  

    cout<<B[N]<<endl;


}


Measured memory_bytes: 1792
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
const int N = 5005;

int main()
{
    map<ll,ll> y;
    ll n;
    cin >> n;
    for(ll i=0;i<n;i++)
    {
       ll x;
       cin >> x;
       y[x]++;
    }
    for(auto X:y)
    {
        if(X.ss>=2)  return cout<<"NO",0;
    }
    cout<<"YES";
}

Measured memory_bytes: 12800
s = gets.chomp
tob=0
tow=0
s.size.times do |i|
  tob += 1 if i.even? and s[i] == "0"
  tob += 1 if i.odd? and s[i] == "1"
  tow += 1 if i.even? and s[i] == "1"
  tow += 1 if i.odd? and s[i] == "0"
end
p [tob, tow].min


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

std::vector<std::pair<ll, int>> prime_factor(ll n) {
  std::vector<std::pair<ll, int>> ret;
  for(ll i = 2; i * i <= n; ++i) {
    int cnt = 0;
    while(n % i == 0) {
      ++cnt;
      n /= i;
    }
    ret.emplace_back(i, cnt);
  }
  if(n != 1) ret.emplace_back(n, 1);
  return ret;
};

ll modinv(ll a) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;

    return u;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<ll> A(N);
  rep(i, N) {
    std::cin >> A[i];
  }

  std::map<ll, int> L_prime;
  rep(i, N) {
    auto factors = prime_factor(A[i]);
    for(auto &p : factors) {
      L_prime[p.first] = std::max(L_prime[p.first], p.second);
    }
  }

  ll L = 1;
  for(auto &p : L_prime) {
    rep(i, p.second) {
      L *= p.first;
      L %= MOD;
    }
  }

  ll ans = 0;
  rep(i, N) {
    ll B = (L * modinv(A[i])) % MOD;
    B %= MOD;
    ans += B;
    ans %= MOD;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
        int N,K,i,h,a=0;
        scanf("%d%d",&N,&K);
        for(i=0;i<N;i++){
                scanf("%d",&h);
                if(h>=K) a++;}
        printf("%d\n",a);
        return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

using ll = long long;

ll N, A, B;
ll X[MAX_N];
std::vector<ll> vs;
ll S[MAX_N+1];

int main()
{
	scanf("%lld%lld%lld", &N, &A, &B);
	rep(i, N)
		scanf("%lld", X + i);

	rep(i, N - 1)
		vs.push_back( X[i+1]-X[i] );

	std::sort( vs.begin(), vs.end() );

	rep(i, N-1)
		S[i + 1] = S[i] + vs[i];

	ll ans = 1e14;
	rep(k, N)
		ans = std::min(ans, k*B + S[N-1-k]*A);

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

	return 0;
}

Measured memory_bytes: 2676
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] N = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int K = intRead();
        Console.WriteLine(N.Sum() - N.Max() + (N.Max() * Math.Pow(2,K)));
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 11348
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

#define MAX_N 1000

char field[MAX_N][MAX_N];
int square[MAX_N][MAX_N];

int main() {
	int n;
	while (cin >> n, n) {
		getchar();
		memset(square, 0, sizeof(square));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				field[i][j] = getchar();
				if (field[i][j] == '*') square[i][j] = 0;
				else square[i][j] = 1;
			}
			getchar(); // 改行をつぶす
		}

/*		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				putchar(field[i][j]);
			}
			putchar('\n');
		} */

		for (int i = 1; i < n; i++) {
			for (int j = 1; j < n; j++) {
				if (field[i][j] == '.') {
					square[i][j] = min(min(square[i-1][j], square[i][j-1]), square[i-1][j-1])+1;
				}
			}
		}

		int max_l = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				max_l = max(max_l, square[i][j]);
			}
		}
		
		cout << max_l << endl;
	}
	return 0;
}

Measured memory_bytes: 5744
(N, K), ps_, cs_ = readlines.map{_1.split.map(&:to_i)}
Ps, Cs = [nil] + ps_, [nil] + cs_

ma = ->(a, b){a > b ? a : b}
mi = ->(a, b){a < b ? a : b}
@m = Array.new(N + 1, false)

def loop(i)
  ret = []
  while !@m[i]
    @m[i] = true
    ret << (i = Ps[i])
  end
  ret
end

ans = (1 .. N).inject(-Float::INFINITY) do |r, i|
  next r if @m[i]
  lp = loop(i)
  l = lp.size
  ss = (1 .. 3*l).each_with_object([0]){|j, o| o << o.last + Cs[lp[j%l]]}
  k = mi[K, l + K%l]
  ma[r, (0 ... l).map{(K - k)/l*ma[0, ss[l]] + ss[_1 + 1, k].max - ss[_1]}.max]
end
puts ans

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

int main() {
    map<ll, ll> A;
    REP(i, 9) {
        ll tmp;
        cin >> tmp;
        A[tmp] = i + 1;
    }

    ll N;
    cin >> N;

    bool isHit[9];
    REP(i, 9) {
        isHit[i] = false;
    }

    REP(i, N) {
        ll num;
        cin >> num;
        if(A[num] != 0) {
            isHit[A[num] - 1] = true;
        }
    }

    ll atari[8][3] = {
        {0, 1, 2},
        {3, 4, 5},
        {6, 7, 8},

        {0, 3, 6},
        {1, 4, 7},
        {2, 5, 8},

        {0, 4, 8},
        {2, 4, 6}
    };

    REP(i, 8) {
        bool tmp = true;
        REP(j, 3) {
           if(!isHit[atari[i][j]]) {
               tmp = false;
           }
        }

        if(tmp) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
	int p, q, dig, i, j, f;
	int  quo[2048], sur[2048];
	int loop;
	
	while (scanf("%d%d", &p, &q) != EOF){
		for (i = 0; i < 2048; i++){
			quo[i] = 0;
			sur[i] = 0;
		}
		
		quo[0] = p;
		
		dig = 0;
		while (1){
			quo[dig + 1] = quo[dig] % q * 10;
			sur[dig] = quo[dig] % q;
			quo[dig] = quo[dig] / q;
			
			if (sur[dig] == 0){
				break;
			}
			
			for (j = 0, f = 0; j < dig; j++){
				if (sur[dig] == sur[j]){
					f = 1;
					loop = j;
					break;
				}
			}
			if (f == 1){
				break;
			}
			
			dig++;
		}
		
		for (i = 1; i <= dig; i++){
			printf("%d", quo[i]);
		}
		puts("");
		if (f == 1){
			for (i = 1; i <= dig; i++){
				if (i > loop){
					printf("^");
				}
				else {
					printf(" ");
				}
			}
			puts("");
		}
	}
	
	return (0);
}

Measured memory_bytes: 624
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  char x, y;
  readf("%s %s\n", &x, &y);
  if (x < y) {
    writeln("<");
  } else if (x > y) {
    writeln(">");
  } else {
    writeln("=");
  }
}


Measured memory_bytes: 256