akhauriyash/Code-Regression huggingface dataset:
mod=10**9+7
io = STDIN
s=io.gets.chomp
N=13
dp=Array.new(N,0)
nextdp=Array.new(N,0)
enum= 10.times.flat_map do |k|
        N.times.map do |j|
          [(10*j+k)%N,j]
        end
      end
dp[0]=1
s.each_char do |c|
  nextdp.fill(0)
  if c=="?"
    enum.each do |i,j|
      nextdp[i]+=dp[j]
    end
  else
    k=c.to_i
    enum[N*k,N].each do |i,j|
      nextdp[i]+=dp[j]
    end
  end
  N.times{|j|dp[j]=nextdp[j]%mod}
end
p dp[5]


Measured memory_bytes: 3836
def convert(n):
  def _convert(c):
    ord_c = ord(c) + n
    ord_c = ord_c - 26 if ord_c > 90 else ord_c
    return chr(ord_c)
  return _convert

n = int(input())
s = input()
result = map(convert(n), list(s))
print(''.join(list(result)))


Measured memory_bytes: 3188
n=int(input())
l=list(input())

e=[0]*n
w=[0]*n

for i in range(n-1):
    if l[i]=='E':
        e[i+1]=e[i]+1
    else:
        e[i+1]=e[i]
    if l[n-1-i]=='W':
        w[n-2-i]=w[n-1-i]+1
    else:
        w[n-2-i]=w[n-1-i]
ew=[0]*n
for i in range(n):
    ew[i]=e[i]+w[i]
print(n-1-max(ew))

Measured memory_bytes: 31732
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	long W = Long.parseLong(scan.next());
	long a = Long.parseLong(scan.next());
	long b = Long.parseLong(scan.next());

	long ans = 0;
	if(a+W < b) ans = b - (a+W);
	else if(b+W < a) ans = a - (b+W);
	
	System.out.println(ans);
	scan.close();
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>

int main(void) {
    std::stack<char> st;
    std::string str;

    std::cin >> str;
    for (auto& v : str) {
        st.push(v);
    }

    do {
        std::cout << st.top();
        st.pop();
    } while (!st.empty());
    std::cout << std::endl;

    return 0;
}

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

#define ll long long
#define ar array

int main() {

    ios::sync_with_stdio(false);
	
	int a, b, c, k, maior;
	
	cin >> a >> b >> c;
	cin >> k;
	
	maior = max(max(a, b), c);
	
	for(int i = 0; i < k; i++){
		maior = maior*2;
	}
	
	cout << a + b + c - max(max(a, b), c) + maior << endl;

    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const LL INF=(LL)1e9*(LL)1e9;


int main()
{
    int n,p;
    cin>>n>>p;
    vector<int> a(n);
    REP(i,n)
        cin>>a[i];

    vector<vector<LL>> dp(n+1,vector<LL>(2));
    dp[0][0]=1;
    REP(i,n)
    {
        if(a[i]%2==0)
        {
            dp[i+1][0]+=dp[i][0]*2;
            dp[i+1][1]+=dp[i][1]*2;
        }
        else
        {
            dp[i+1][0]+=dp[i][0]+dp[i][1];
            dp[i+1][1]+=dp[i][0]+dp[i][1];
        }
    }
    /*REP(j,2)
    REP(i,n+1)
    {
        cout<<dp[i][j]<<" \n"[i==n];
    }*/
    cout<<dp[n][p]<<endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 1000000000000)

	n := nextInt()
	as := make([]int, n)

	mod := int(1e9 + 7)

	for i := int(0); i < n; i++ {
		as[i] = nextInt() % mod
	}

	asum := make([]int, n)
	asum[n-1] = as[n-1]
	for i := int(1); i < n; i++ {
		asum[n-1-i] = (asum[n-i] + as[n-1-i]) % mod
	}

	ans := int(0)
	for i := int(0); i < n-1; i++ {
		ans += as[i] * (asum[i+1]) % mod
		ans = ans % mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7460
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        s: String,
    }
    let mut l: Vec<char> = Vec::new();
    for c in s.chars() {
        if l.contains(&c) {
            println!("no");
            return;
        }
        l.push(c);
    }
    println!("yes");
} 


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    string s;
    cin>>s;

    if(s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3016
x = input()
n = int(x[-1])

if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
    print("pon")
elif n == 3:
    print("bon")

Measured memory_bytes: 9180
import java.util.Scanner;
class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   String s = sc.next();
   int n = s.length();
   String x , y;
   x = s.substring(0,n/2);
   y = s.substring(n/2+1,n);
   if(x.equals(y)){
     System.out.println("Yes");
   }else{
     System.out.println("No");
   }

 }
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

int main() {
    int K, S;
    cin >> K >> S;
    int count = 0;
    for (int X = 0; X <= K; ++X) {
        for (int Y = 0; Y <= K; ++Y) {
            int sum = S - X - Y;
            if ((sum >= 0) && (sum <= K)) count++;
        }
    }
    cout << count << endl;

    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') {
        REP(i, vec.size()) {
            vec.at(i) += num;
        }
    } else if (ch == '-') {
        REP(i, vec.size()) {
            vec.at(i) -= num;
        }
    } else if (ch == '*') {
        REP(i, vec.size()) {
            vec.at(i) *= num;
        }
    } else if (ch == '/'){
        REP(i, vec.size()) {
            vec.at(i) /= num;
        }
    } else if (ch == '%') {
        REP(i, vec.size()) {
            vec.at(i) %= num;
        }
    }
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、numの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sf(a) scanf("%d",&a)
#define MX 100000
#define inf 1e9
#define m_p make_pair
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))
#define MOD 100000



int main() {
    int q;
    sf(q);
    map<string,LL> mp;
    while(q--){
        int a;
        sf(a);
        string str;
        LL x;
        if(a==0){
            cin >> str;
            scanf("%lld",&x);
            mp[str] = x;
        }
        else if(a==1){
            cin >> str;
            printf("%lld\n",mp[str]);;
        }
    }


    return 0;
}



Measured memory_bytes: 27808
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
int ask(ll a,ll b,ll c,ll d){
	cout<<"? "<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"<<flush;
	int res;
	cin>>res;
	return res;
}
int main(){
	int h,w,n,K;
	cin>>h>>w>>n>>K;
	int ans[55][55];
	rep(i,h)rep(j,w)ans[i][j]=0;
	rep(i,h)for(int j=0;j<w;j+=4){
		int l=j,r=min(w-1,j+4);
		int res=ask(i,l,i,r);
		for(int k=l;k<r;k++){
			if(res==0)break;
			int cur=ask(i,k,i,k);
			ans[i][k]=cur;
			res-=cur;
		}
		ans[i][r]=res;
	}
	ll fans=0,po2=1;
	rep(i,h)rep(j,w){
		fans=(fans+po2*ans[i][j])%K;
		po2=po2*2%K;
	}
	cout<<"! "<<fans<<"\n"<<flush;
}


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

Measured memory_bytes: 52208
using System;


namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            int x = int.Parse(str);
            int i = 0;
            while (x != 0)
            {
                i++;
                Console.WriteLine("Case " + i + ": " + x);
                str = Console.ReadLine();
                x = int.Parse(str);


            }

            }
        }
}

Measured memory_bytes: 9168
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int i,j,n,x,y,dx,dy,L=1000000;
  vector<pair<int,int> >a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    a.push_back(make_pair(x,y));
  }
  sort(a.begin(),a.end());
  for(i=1;i<n-1;i++)
    for(j=i;j>=0;j--){
      dx=a[i+1].first-a[j].first;
      dy=a[i+1].second-a[j].second;
      if (dx*dx>=L)
        break;
      L=min(L,dx*dx+dy*dy);
    }
  printf("%d\n",L);
}

Measured memory_bytes: 5764
h, w, k = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(h)]
ans = float("inf")
for i in range(2**(h-1)):
  L = [0]
  cnt = 0
  for j in range(h-1):
    if i>>j & 1:
      L.append(j+1)
      cnt += 1
  L.append(h)
  C = [0]*(len(L)-1)
  for j in range(w):
    D = [0]*(len(L)-1)
    for l in range(len(L)-1):
      a, b = L[l], L[l+1]
      for s in range(a, b):
        D[l] += S[s][j]
    if max(D) > k:
      break
    for l, d in enumerate(D):
      if C[l]+d > k:
        break
    else:
      for l, d in enumerate(D):
        C[l] += d
      continue
    cnt += 1
    for l, d in enumerate(D):
      C[l] = d
  else:
    ans = min(ans, cnt)
print(ans)

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

int main()
{
  int a,b;
  int sum=0;
  
  cin>>a;
  cin>>b;
  
  sum=a+b;
  
  if(sum<24)
  {
  	cout<<sum<<endl;
  }
  else
  {
    sum=sum-24;
    cout<<sum<<endl;
  }
  
  return 0;
}

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

int main(){
    int N; cin >> N;
    long long ans = 0;
    for(int i = 0; i < N; i++){
        int x; cin >> x;
        ans += x-1;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c;
	cin>>a>>b;
	c=a-(b*2);
	if(c>0)
	{
		cout<<c;
	}
	if(c<=0)
	{
		cout<<"0";
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

int main()
{
	int n;
	string lr;
	cin >> lr;
	n = (int)lr.size();
	vector<int> res(n, 0);

	int r = 0;
	for(int i = 0; i < n; i++) {
		if(lr[i] == 'R') {
			r = i;
		} else {
			res[r + (i - r) % 2]++;
		}
	}

	int l = n - 1;
	for(int i = n - 1; i >= 0; i--) {
		if(lr[i] == 'L') {
			l = i;
		} else {
			res[l - (l - i) % 2]++;
		}
	}

	for(int i = 0; i < n; i++) {
		cout << res[i] << " ";	
	}

	return 0;
}


Measured memory_bytes: 1024
// select maximum alphabetically character in each iteration 
// KOI NI YAAR SAB SAHI HOEGA  BAS  CHORRO MAT
// ENJOR KARO YAAR
// HAAR MAT MAANO
// // APNA TIME AAYEGA
// BEILIEVE IN GOD
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define loopb(i,a,b) for (lli i=a;i>=b;i--)
#define pb push_back
#define mod 1000000007
#define fast() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define gcd(a,b) (__gcd((a),(b)))
#define lcm(a,b)(((a)*(b))/gcd((a),(b)))
#define ma 1e18
#define bc __builtin_popcountll
#define vi vector<lli>
#define pr pair<lli,lli>
#define vp vector<pr>
#define F  first
#define S   second
#define lld long double
lli dp[3001][3001][2];
lli a[3009];

lli solve(lli start,lli end , lli prev)
{if(start>end)
{return 0;
}
if(dp[start][end][prev]!=-1)
{return dp[start][end][prev];
}
if(prev==1)
{return dp[start][end][prev]=max(a[start]+solve(start+1,end,0) , a[end]+solve(start,end-1,0));
}
else
{return dp[start][end][prev]=min(solve(start+1,end,1),solve(start,end-1,1));
}
}


int main()
{lli n,sum,x,y;
sum=0;
cin>>n;
loop(i,0,n)
{cin>>a[i];
sum+=a[i];
}
loop(i,0,n)
{loop(j,0,n)
{loop(k,0,2)
{dp[i][j][k]=-1;
}
}
}

x=solve(0,n-1,1);
y=sum-x;
cout<<x-y<<"\n";
}



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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
vector<vector<ll>>vec(ll x, ll y, ll w){
  vector<vector<ll>>v(x,vector<ll>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

ll MAX_V = 3000; //頂点数
struct edge {
    ll to;
    ll cost;
};
vector<vector<struct edge>> G(MAX_V); //隣接リスト
vector<ll> d(MAX_V); //各頂点への最短距離
vector<ll> neg(MAX_V,0);
ll n;
bool bellmanford(ll s){
  fill(ALL(d), INF);
  d[s]=0;
  for(ll i=0;i<3*MAX_V;i++){
    for(ll j=0;j<G.size();j++){
      for(ll k=0;k<G[j].size();k++){
        struct edge e=G[j][k];
        if(d[e.to]>d[j]+e.cost){
          d[e.to]=d[j]+e.cost;
          if(i>=MAX_V){
            neg[e.to]=1; //負閉路はfalse
          }
        }
      }
    }
  }
  if(neg[n]==1)return false;
  else return true;
}


int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll m,p;cin>>n>>m>>p;
  vector<ll> u(m),v(m),a(m);
  for(ll i=0;i<m;i++){
    cin>>u[i]>>v[i]>>a[i];
    struct edge e ={v[i],p-a[i]};
    G[u[i]].push_back(e);
  }
  if(bellmanford(1)){
    cout<<max(0LL,-d[n])<<endl;
  }
  else{
    cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 768
n = int(input())
a = list(map(int, input().split()))
a.sort()
import collections

c = collections.Counter(a).most_common()
c.sort()
c.reverse()
first=0
second=0

for tmp in c:
        if tmp[1] >=4 and first==0 and second==0:
                first=tmp[0]
                second=tmp[0]
                break
        if tmp[1] >=2:
                if first==0:
                        first=tmp[0]
                else:
                        second=tmp[0]
                        break
print(first*second)

Measured memory_bytes: 21540
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define MOD 1000000007
using namespace std;
int prime[1005];
int check[1005];
int tot = 0;
void olsf(){
    for (int i = 2; i < 1005; ++i)
    {
        if(!check[i])prime[tot++] = i;
        for (int j = 0; j < tot; ++j)
        {
            if (i * prime[j] > 1005)break;
            check[i*prime[j]] = 1;
            if (i % prime[j] == 0)break;
        }
    }
}
int a[1005];
int main()
{
    olsf();
    ll n, t;
    cin>>n;
    t = n;
    ll ans = 1;
    for(int i = 2; i <= t; i++){
        int temp = i;
        for(int j = 2; j <= temp; j++){
            while(!check[j] && temp % j == 0){
                a[j]++;
                temp/=j;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        if(a[i] != 0)ans = ans*(a[i]+1)%MOD;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	string S;

	cin >> N >> S;

	if((int)S.size()%2==0 && S.substr(0,N/2)==S.substr(N/2))
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
	return 0;
}



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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    FOR (i, 1, N + 1) if (((int)floor (log10 (i)) + 1) % 2 == 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3948
def get_lcs(S: str, T: str):
    N, M = len(S), len(T)
    dp = [[0] * (M + 1) for _ in range(N + 1)]
    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if s == t:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

    reversed_lcs = ""
    while N and M:
        if S[N - 1] == T[M - 1]:
            N -= 1
            M -= 1
            reversed_lcs += S[N]
            continue
        if dp[N - 1][M] > dp[N][M - 1]:
            N -= 1
        else:
            M -= 1
    return reversed_lcs[::-1]


def main():
    S, T = open(0).read().split()
    print(get_lcs(S, T))


if __name__ == "__main__":
    main()


Measured memory_bytes: 111708
#include<cstdio>
typedef long long ll;
ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
int main()
{
    ll n,x;
    scanf("%lld",&n);
	ll s=1;
	while(n--)
	{
		scanf("%lld",&x);
		s=x/gcd(s,x)*s;
	}
    printf("%lld\n",s);
    return 0;
}

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

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

int encode(const vector<int> &state) {
  int h = 0;
  REP(i, state.size())
      h = h * 3 + state[i];
  return h;
}

int decode(int h, vector<int>& out) {
  int N = out.size();
  REP(i, N) {
      out[N - 1 - i] = h % 3;
      h /= 3;
  }
}

vector<int> move(vector<int> v, int from, int to) {
  int maxFrom = -1, maxTo = -1;
  REP(i, v.size()) {
      if (v[i] == from && maxFrom < i) maxFrom = i;
      if (v[i] == to && maxTo < i) maxTo = i;
  }

  if (maxFrom > maxTo) {
      v[maxFrom] = to;
  }
  return v;
}

bool finish(vector<int> state) {
  int N = state.size();
  return N == count(state.begin(), state.end(), 0) ||
      N == count(state.begin(), state.end(), 2);
}

bool visited[15000000];

int main() {
  for (int N, M; cin >> N >> M, (N || M); ) {
      memset(visited, 0, sizeof(visited));

      vector<int> state(N, -1);
      for (int i = 0; i < 3; i++) {
          int K; cin >> K;
          while (K--) {
              int a; cin >> a;
              state[a - 1] = i;
          }
      }
      queue<int> q;

      visited[encode(state)] = true;
      q.push(encode(state));
      q.push(0);

      int ans = -1;
      while (!q.empty()) {
          decode(q.front(), state); q.pop();
//          REP(i, N) cout << state[i] << " "; cout << endl;
          int step = q.front(); q.pop();
          if (step > M) break;
          if (finish(state)) {
              ans = step;
              break;
          }

          int next;
          next = encode(move(state, 0, 1));
          if (!visited[next]) {visited[next] = true; q.push(next); q.push(step + 1);}

          next = encode(move(state, 1, 0));
          if (!visited[next]) {visited[next] = true; q.push(next); q.push(step + 1);}

          next = encode(move(state, 2, 1));
          if (!visited[next]) {visited[next] = true; q.push(next); q.push(step + 1);}

          next = encode(move(state, 1, 2));
          if (!visited[next]) {visited[next] = true; q.push(next); q.push(step + 1);}
      }
      cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 15000
N, A, B = map(int,input().split())
h = []
for _ in range(N):
    h.append(int(input()))
 
def solve(n):
    cnt = 0
    for i in h:
        i -= B * n
        cnt += max((i - 1) // (A - B) + 1, 0)
    return cnt <= n
 
left = 0
right = 10 ** 9

while left + 1 < right:
    mid = (left + right) // 2
    if solve(mid):
        right = mid
    else:
        left = mid
 
print(right)

Measured memory_bytes: 51032
S = gets
s1 = S[0..1].to_i
s2 = S[2..3].to_i

if s1 >= 1 && s1 <= 12 && s2 >= 1 && s2 <= 12
  puts "AMBIGUOUS"
elsif s1 >= 1 && s1 <= 12
  puts "MMYY"
elsif s2 >= 1 && s2 <= 12
  puts "YYMM"
else
  puts "NA"
end

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

int main(void) {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    mp[a] += 1;
  }
  int ans = 0;
  for (auto e: mp) {
    if (e.second % 2 == 1) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
n=int(input())
a=list(map(int,input().split()))
ans=[0]*3
for i in a:
  if i%4==0:
    ans[2]+=1
  elif i%2==0:
    ans[1]+=1
  else:ans[0]+=1
if ans[0]<=ans[2] or (ans[0]<=ans[2]+1 and ans[1]==0):print('Yes')
else:print('No')

Measured memory_bytes: 85212
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        bool judge = true;
        var list = new List<string>();
        for (int i = 0; i < n; i++)
        {
            list.Add(Console.ReadLine());
        }
        for (int i = 1; i < n; i++)
        {
            if (list[i - 1].Last() != list[i].First()) judge = false;
        }
        if (list.Count() != list.Distinct().Count()) judge = false;
        Console.WriteLine(judge ? "Yes" : "No");
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int N,alice,bob;
    alice=0;
    bob=0;
    vector<int> A;
    cin >> N;
    A.resize(N);
    for (int i =0;i<N;i++){
        cin >> A.at(i);
    }
    sort(A.begin(),A.end(),greater<int>());
    for (int i=0;i<N;i++){
        if(i%2==0){
            alice+=A.at(i);
        }else{
            bob+=A.at(i);
        }
    }
    cout<<(alice-bob);
}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int a[55], b[55];
    int i;
    for (i = 0; i < m; i++)
        scanf("%d %d", &a[i], &b[i]);
    int ans = 0;
    int j;
    int p[55];
    int x;
    for (i = 0; i < m; i++)
    {
        for (j = 0; j <= n; j++)
            p[j] = 0;
        p[1] = 1;
        x = 1;
        while (x > 0)
        {
            x = 0;
            for (j = 0; j < m; j++)
            {
                if (j != i)
                {
                    if (p[a[j]] == 1 && p[b[j]] == 0)
                    {
                        p[b[j]] = 1;
                        x = 1;
                    }
                    else if (p[a[j]] == 0 && p[b[j]] == 1)
                    {
                        p[a[j]] = 1;
                        x = 1;
                    }
                }
            }
        }
        x = 0;
        for (j = 1; j <= n; j++)
            if (p[j] == 0)
                x++;
        if (x > 0)
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import itertools

n,m,q=map(int,input().split())
l=[i for i in range(1,m+1)]
que=list(itertools.combinations_with_replacement(l, n))
point=[0 for i in range(len(que))]
ans=0

for i in range(q):
  a,b,c,d=list(map(int,input().split()))
  a-=1
  b-=1
  for j in range(len(que)):
    if que[j][b]-que[j][a]==c:
      point[j]+=d
print(max(point))

Measured memory_bytes: 24984
def binarysearch(S,x):
    a=0
    b=len(S)
    while b>a+1:
        m=(b+a)//2
        if S[m]>x:
            b=m
        elif S[m]<=x:
            a=m
    if S[a]==x:
        return True
    return False
            

n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))
count = 0
for i in range(q):
    if binarysearch(S,T[i]):
        count += 1
print(count)



Measured memory_bytes: 16712
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int get_sum(int a) {
    int res = 0;
    while (a) {
        res += a % 10;
        a /= 10;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    int ans = 1e9;
    for (int i = 1; i <= n - 1; ++i) {
        ans = min(ans, get_sum(i) + get_sum(n - i));
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String is;
        while(true){
        	is = br.readLine();
			String[] sp = is.split(" ");

			int a = Integer.parseInt(sp[0]);
			String op = sp[1];
			int b = Integer.parseInt(sp[2]);

	        switch(op){
	        case "+":
	        	System.out.println(a+b);
	        	break;
	        case "-":
	        	System.out.println(a-b);
	        	break;
	        case "/":
	        	System.out.println(a/b);
	        	break;
	        case "*":
	        	System.out.println(a*b);
	        	break;
	        case "?":
	        	return;
	        }
        }
    }
}

Measured memory_bytes: 24240
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p <<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n;
	cin >> n;
	vl a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll x = a.back();
	ll y = 0;
	ll dif;
	if (x % 2 == 0) {
		dif = x / 2;
	}
	else {
		dif = min(x / 2, x / 2 + 1);
	}
	rep(i, n - 1) {
		if (x % 2 == 0) {
			ll temp = abs(x / 2 - a[i]);
			if (dif > temp) {
				dif = temp;
				y = a[i];
			}
		}
		else {
			ll temp = min(abs(x / 2 - a[i]), abs(x / 2 + 1 - a[i]));
			if (dif > temp) {
				dif = temp;
				y = a[i];
			}
		}
	}
	cout << x << " " << y << endl;
}

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

int main(){
  string a,b;
  cin >> a >> b;
  int c = stoi(a+b);
  int d = sqrt(c);
  if(d*d == c){
    puts("Yes");
  }
  else{
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
e[999],*p,*r,*q,d[21];B(s){d[s]=!memset(d,1,84);for(s=*e;--s;)for(p=e+2;r-p;p+=4)q=d+p[1],d[*p]=fmin(d[*p],*q+p[3]),*q=fmin(*q,d[*p]+p[2]);}main(t){for(r=e;~scanf("%d,",r++););r-=5;B(*r),t=d[r[1]],B(r[1]);p=!printf("%d\n",r[2]-r[3]-t-d[*r]);}

Measured memory_bytes: 0
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> as;
    bool overK = false;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        if(a >= k){
            overK = true;
        }else{
            as.push_back(a);
        }
    }
    if(accumulate(as.begin(), as.end(), 0) < k){
        cout << as.size() << '\n';
        return 0;
    }
    int ans = 0;
    vector<int> sums(k + 1);
    sums[0] = 1;
    for(uint i=0;i<as.size();i++){
        for(int j=k;j>=0;j--){
            if(sums[j] && j + as[i] <= k){
                // sums[j + as[i]]++;
                sums[j + as[i]] += sums[j];
            }
        }
        prints(sums);
    }
    for(uint i=0;i<as.size();i++){
        bool needed = false;
        auto sum2 = sums;
        for(int j=0;j<=k;j++){
            if(sums[j] && j + as[i] <= k && sums[j + as[i]]){
                sums[j + as[i]] -= sums[j];
            }
        }
        for(int j=1;j<=k;j++){
            // if(sums[j - as[i]] && sums[j] == 1){ continue; }
            if(sums[j] && k - as[i] <= j && j < k){
                prints(i, "is neeeded", j);
                needed = true;
                break;
            }
        }
        prints(as[i], sums, needed);
        if(!needed){
            ans++;
        }
        sums = sum2;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,c;
  cin >> a;
  cin >> c;
  string b;
  cin >> b;
  int x = 0;
  for(int i = 0;i < a-1;i++){
    if(b.at(i) == b.at(i+1))x++;
  }
  x = min(a-1,x+2*c);
  cout << x << endl;
}

Measured memory_bytes: 512
/*
* @author:  codancer
* @createTime:  2020-05-02, 20:13:17
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
int main(){
	ll N,x=100;
	cin>>N;
	rep(i,1,10000000000){
		x=x+x/100;
		if(x>=N){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b, c, d, e, k;
    int s;

    cin >> a >> b >> c >> d >> e >> k;
    s = max({
        abs(a - b),
        abs(a - c),
        abs(a - d),
        abs(a - e),
        abs(b - c),
        abs(b - d),
        abs(b - e),
        abs(c - d),
        abs(c - e),
        abs(d - e)
        }
    );

    if (s <= k){
        cout << "Yay!";
    } else {
        cout << ":(";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int c[500010],last[500010],ans[500010];
pair<pair<int,int>,int> p[500010];
int n,seg[1000010];
void update(int p,int val){
    for(seg[p += n] = val;p>1;p>>=1){
        seg[p>>1] = seg[p] + seg[p^1];
    }
}

int query(int l,int r){
    int res = 0;
    for(l += n,r += n; l<r;l>>=1,r>>=1){
        if(l&1) res += seg[l++];
        if(r&1) res += seg[--r];
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,q; cin >> n >> q;
    for(i=0;i<n;i++){
        cin >> c[i]; c[i]--; last[i] = -1;
    }
    for(i=0;i<q;i++){
        int l,r; cin >> l >> r; l--; r--;
        p[i] = {{r,l},i};
    }
    sort(p,p + q);
    int r = 0;
    for(i=0;i<q;i++){
        pair<int,int> pp = p[i].first;
        while(r<=pp.first){
            if(last[c[r]]!=-1) update(last[c[r]],0);
            update(r,1);
            last[c[r]] = r; r++;
        }
        ans[p[i].second] = query(pp.second,pp.first + 1);
    }
    for(i=0;i<q;i++) cout << ans[i] << "\n";
}

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

int main() {
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        string C;
        cin >> C;
        cout << C << endl << C << endl;
    }
    return 0;
}

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

int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    auto itr = lower_bound(A.begin(),A.end(),0);
    int pos = distance(A.begin(),itr);
    ll sum = 0;
    if(pos == 0){
        sum -= A[0];
        for(int i = 1; i < N; i++){
            sum += A[i];
        }
        cout << sum << endl;
        ll tmp = A[0];
        for(int i = 1; i < N-1; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
        cout << A[N-1] << " " << tmp << endl;
    }else if(pos == N){
        sum += A[N-1];
        for(int i = 0; i < N-1; i++){
            sum -= A[i];
        }
        cout << sum << endl;
        ll tmp = A[N-1];
        for(int i = N - 2; i >= 0; i--){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
    }else{
        for(int i = 0; i < N; i++){
            if(i < pos) sum -= A[i];
            else sum += A[i];
        }
        cout << sum << endl;
        ll tmp = A[0];
        for(int i = pos; i < N-1; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
        cout << A[N-1] << " " << tmp << endl;
        tmp = A[N-1] - tmp;
        for(int i = 1; i < pos; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
    }
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  int in[3][3];
  rep(i,3)rep(j,3)cin >> in[j][i];
  
  rep(a1,202)rep(a2,202)rep(a3,202){
    int b1,b2,b3;
    b1 = in[0][0] - a1;
    b2 = in[0][1] - a1;
    b3 = in[0][2] - a1;
    //cerr << b1 << b2 << b3 << endl;
    if(
      a2 + b1 == in[1][0] &&
      a3 + b1 == in[2][0] &&
      a2 + b2 == in[1][1] &&
      a3 + b2 == in[2][1] &&
      a2 + b3 == in[1][2] &&
      a3 + b3 == in[2][2]
    ){
        cout <<"Yes" << endl;
        return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int R,C,N;
struct node{
	int u;
	int v;
	int flag;
}no[200005];
bool cmp(node a,node b)
{
	return a.u < b.u;
}
int Change(int x, int y)
{
    if (y == 0)
        return x;
    else if (x == R)
        return x+y;
    else if (y == C)
        return R+C+R-x;
    else if (x == 0)
        return R+R+C+C-y;
    else 
		return -1;
}
int main()
{
	int cnt=0;
	scanf("%d%d%d",&R,&C,&N);
	for(int i=0;i<N;i++)
	{
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int flag1=Change(a,b);
		int flag2=Change(c,d);
		if(flag1 == -1 || flag2 == -1)
			continue;
		if(flag1 > flag2)
			swap(flag1,flag2);
		no[cnt].flag=1;
		no[cnt].u=flag1;
		no[cnt++].v=flag2;
		no[cnt].flag=2;
		no[cnt].u=flag2;
		no[cnt++].v=flag1;
	}
	stack<int>S;
	sort(no,no+cnt,cmp);
	for(int i=0;i<cnt;i++)
	{
		if(no[i].flag==1)
			S.push(no[i].v);
		else if(S.top()==no[i].u)
			S.pop();
		else
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
typedef  long long ll;
#define INF 1000000000
using namespace std;
#define N 101
bool check(string s,string t,int start){
    string tmp=s.substr(start,t.size());
    for(int i=0;i<tmp.size();i++){
        if(tmp[i]=='?'){
            continue;
        }else if(tmp[i]!=t[i]){
            return false;
        }
    }
    return true;
}
int main(void){
    string s,t;
    cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    vector<string>cand;
    int len_t=t.size(),len_s=s.size();
    for(int i=0;i<=len_s-len_t;i++){
        if(check(s,t,i)){
            string tmp=s;
            int j=0;
            for(int k=i;k<t.size()+i;k++){
                tmp[k]=t[j++];
            }
            for(int j=0;j<s.size();j++){
                if(tmp[j]=='?'){
                    tmp[j]='a';
                }
            }
            cand.push_back(tmp);
        }
    }
    if(cand.size()==0){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    sort(cand.begin(),cand.end());
    cout<<cand[0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x>>y;
  if(x==0){
    if(y==100)std::cout << 101 << '\n';
    else std::cout << y << '\n';
  }else if(x==1){
    if(y==100)std::cout << 10100 << '\n';
    else std::cout << y*100 << '\n';
  }else if(x==2){
    if(y==100)std::cout << 1010000 << '\n';
    else std::cout << y*10000 << '\n';
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int a,b,d,r;
	double f;
	
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    double ans = 0.0;
    if (x >= (a*a*b+1)/2) {
        double num = (double)b - ((double)x / (a*a));
        double den = (double)a / 2.0;
        ans = atan(num / den) / PI * 180.0;
    }
    else {
        double num = (double)b;
        double den = ((double)x / a * 2) / b;
        ans = atan(num / den) / PI * 180.0;
    }
    printf("%.10f\n", ans);
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

// vector(geometric) definition
typedef complex<double> cdouble;
// define with polor
const int N = 4;

int main()
{
    cdouble v[N + 2];
    double x[N], y[N];
    char t;
    while(cin>>x[0]>>t>>y[0]>>t >>x[1]>>t>>y[1]>>t >>x[2]>>t>>y[2]>>t
            >>x[3]>>t>>y[3])
    {
        REP(N) v[i] = cdouble(x[i], y[i]);
        v[N] = v[0];
        v[N + 1] = v[1];
        double ang[N + 2];
        //REP(6)cout << v[i] << endl;

        for(int i = 1; i <= 4; i++)
        {
            ang[i] = fmod( arg(v[i - 1] - v[i]) - arg(v[i + 1] - v[i]) + (10 * M_PI), M_PI * 2); 
            //cout << i << "th angle = " << ang[i] << endl;
        }
        int ans = 1;
        if(ang[1] > M_PI) {REP(4)if(ang[i + 1] < M_PI) ans = 0; }
        else {REP(4)if(ang[i + 1] > M_PI) ans = 0;}
        if(ans) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int x,y;
	cin >> x >> y;

	int result = 0;
	if(x == 1){
		result += 300000;
	}
	if(x == 2){
		result += 200000;
	}
	if(x == 3){
		result += 100000;
	}
	if(y == 1){
		result += 300000;
	}
	if(y == 2){
		result += 200000;
	}
	if(y == 3){
		result += 100000;
	}
	if(x == 1 && y == 1){
		result += 400000;
	}
	cout << result << endl;
	

	return;
}

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

Measured memory_bytes: 256
def insertion_sort(l):
    print(' '.join(map(str, l)))
    for i in range(1, len(l)):
        tmp = l[i]
        for j in range(i-1, -1, -1):
            if l[j] > tmp:
                l[j+1] = l[j]
            else:
                l[j+1] = tmp
                break
        else:
            l[0] = tmp
        print(' '.join(map(str, l)))
    return l

if __name__ == '__main__':
    N = int(input())
    l = list(map(int, input().split()))

    insertion_sort(l)



Measured memory_bytes: 5600
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=10000007;
int main(){
int k,x;cin >> k >> x;
if(500*k>=x)cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
map = []
for i in range(H):
    tmp = list(str(input()))
    tmp.insert(0,".")
    tmp.append(".")
    map.append(tmp)
tmp = ["."]*(W+2)
map.insert(0,tmp)
map.append(tmp)


for i in range(1,H,1):
    for j in range(1,W,1):
        if map[i][j] == "#":
            if map[i-1][j] != "#" and map[i][j-1] != "#" and map[i][j+1] != "#" and map[i+1][j] != "#":
                print("No")
                exit()
print("Yes")

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

int main(){
  int N,K;
  cin>>N>>K;
  vector <int> T(N);
  for (int i=0;i<N;i++){
    cin>>T[i];
  }
  sort(T.begin(),T.end());
  int minmax=1000000001;
  for (int i=0;i<N-K+1;i++){
    minmax=min(minmax,T.at(i+K-1)-T.at(i));
  }
  cout<<minmax<<endl;
  return 0;
}


    

Measured memory_bytes: 640