akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    vector<P> v;
    vector<int> ans(n*n,-1);
    rep(i,n){
        int x; cin >> x;
        x--;
        //xより左にiをi個
        v.pb({x,i});
        ans[x]=i;
    }
    sort(ALL(v));
    int now=0;
    rep(i,n){
        rep(j,v[i].se){
            if(now>=n*n){
                cout << "No" << endl;
                return 0;
            }
            if(ans[now]==-1) ans[now]=v[i].se;
            else{
                now++;
                j--;
            }
        }
    }
    now=0;
    rep(i,n){
        rep(j,n-v[i].se-1){
            if(now>=n*n){
                cout << "No" << endl;
                return 0;
            }
            if(ans[now]==-1) ans[now]=v[i].se;
            else{
                now++;
                j--;
            }
        }
    }
    vector<int> res(n,0);
    int idx=0;
    rep(i,n*n){
        res[ans[i]]++;
        if(i==v[idx].fi){
            if(res[ans[i]]!=ans[i]+1){
                cout << "No" << endl;
                return 0;
            }
            idx++;
        }
    }
    
    cout << "Yes" << endl;
    for(int u:ans) cout << u+1 << " ";
}


Measured memory_bytes: 4240
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1)
  {
    if((c-b)<=0)
    {
      cout<<"Yes\n";
      break;
    }
    else if((a-d)<=0)
    {
      cout<<"No\n";
      break;
    }
    c=c-b;
    a=a-d;
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;




int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    long long v[3];
    scanf("%lld%lld%lld", &v[0], &v[1], &v[2]);
    sort(v, v + 3);
    long long ans;
    if (v[0] % 2 == 0 || v[1] % 2 == 0 || v[2] % 2 == 0)
        ans = 0;
    else
        ans = v[0] * v[1];

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




	return 0;
}




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

n, m = map(int, input().split())
foods = [1] * m
for n_i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    a = ka[1:]
    mask = [0] * m
    for a_i in a:
        mask[a_i-1] = 1
    for m_i in range(m):
        foods[m_i] *= mask[m_i]

print(sum(foods))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char>> qry(q);
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    qry[i] = {t, d};
  }
  int lft = 0;
  for(int i = q - 1; i >= 0; i--) {
    char t = qry[i].first;
    char d = qry[i].second;
    if (0 <= lft && t == s[lft] && d == 'L') {
      lft++;
    } else if (0 < lft && t == s[lft - 1] && d == 'R') {
      lft--;
    }
    if (lft == n) break;
  }
  int rgt = n;
  for(int i = q - 1; i >= 0; i--) {
    char t = qry[i].first;
    char d = qry[i].second;
    if (rgt < n && t == s[rgt] && d == 'L') {
      rgt++;
    } else if (rgt <= n && t == s[rgt - 1] && d == 'R') {
      rgt--;
    }
    if (rgt == -1) break;
  }
  int ret = rgt - lft;
  ret = max(ret, 0);
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int N;
vector<long long> a;
int main(){
ios::sync_with_stdio(false);
  cin >> N;
  a.resize(N);
  long long S = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    S += a[i];
  }
  long long b = 0;
  long long ans = 1e18;
  for(int i = 0; i < N - 1; i++){
    b += a[i];
    ans = min( ans, abs(S - 2 * b) );
  }
  cout << ans << endl;
}

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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}



int main(void){
	int n;
	scanf("%d",&n);
	int MOD=1e9+7;

	long int A[n];
	long int sum=0;
	for(int i=0;i<n;i++){
		scanf("%ld",&A[i]);

		sum+=A[i];
		sum%=MOD;
	}

	int ans=0;
	for(int i=0;i<n;i++){
		long int now=sum-A[i]+MOD;
		ans+=now*A[i]%MOD;
		ans%=MOD;
	}

	printf("%ld\n",ans*modinv(2,MOD)%MOD);

	return 0;
}

Measured memory_bytes: 3284
package main

import "fmt"

func main() {
	var n, first_digit, second_digit, third_digit int
	fmt.Scan(&n)
	for i := n; i < 1000; i++ {
		first_digit = i % 10
		second_digit = (i / 10) % 10
		third_digit = i / 100
		if first_digit == second_digit && first_digit == third_digit {
			fmt.Println(i)
			return
		}
	}
}

Measured memory_bytes: 512
import sys
from collections import deque, Counter

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, K, L = map(int, input().split())
    Adj_r = [[] for i in range(N)]
    Adj_t = [[] for i in range(N)]

    for i in range(K):
        p, q = map(int, input().split())
        p, q = p-1, q-1
        Adj_r[p].append(q)
        Adj_r[q].append(p)

    for i in range(L):
        r, s = map(int, input().split())
        r, s = r-1, s-1
        Adj_t[r].append(s)
        Adj_t[s].append(r)

    col = 0
    cols_r = [None] * N
    cols_t = [None] * N

    for u in range(N):
        if cols_r[u] is None:
            bfs_color(N, Adj_r, cols_r, u, col)
            col += 1
        if cols_t[u] is None:
            bfs_color(N, Adj_t, cols_t, u, col)
            col += 1

    # debug(cols_r, locals())
    # debug(cols_t, locals())

    cnt = Counter((cols_r[u], cols_t[u]) for u in range(N))

    ans = [cnt[cols_r[u], cols_t[u]] for u in range(N)]

    print(*ans)


def bfs_color(N, Adj, v_cols, u, col):
    v_cols[u] = col
    nxts = deque([u])

    while nxts:
        v = nxts.popleft()

        for w in Adj[v]:
            if v_cols[w] is None:
                v_cols[w] = col
                nxts.append(w)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 124784
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=50;
struct State{
    LL S;
    int cur,val;
    State (LL _S=0,int _cur=0,int _val=0):S(_S),cur(_cur),val(_val){}
    bool operator < (const State &rh)const{
        return val>rh.val;
    }
};
map<LL,int>Dist[maxn]; // Dist[cur][state]
int n,m;
int V[maxn];
LL G[maxn];
vector<int>E[maxn];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>V[i];
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        G[u]|=1LL<<v;E[u].push_back(v);
        G[v]|=1LL<<u;E[v].push_back(u);
    }
    int Init=0;
    for(int i=1;i<=n;i++)
    {
        G[i]|=1LL<<i;
        if(G[1]&(1LL<<i))Init+=V[i];
    }
    priority_queue<State>Q;
    Q.push(State(G[1],1,Init));
    Dist[1][G[1]]=Init;
    while(!Q.empty())
    {
        State now=Q.top();Q.pop();
        int u=now.cur;
        if(u==n)
        {
            cout<<now.val<<endl;
            break;
        }
        for(int i=0;i<(int)E[u].size();i++)
        {
            int v=E[u][i];
            LL newS=now.S|G[v];
            int newVal=0;
            for(int j=1;j<=n;j++)
                if(newS & (1LL<<j))
                    newVal+=V[j];
            if(Dist[v].find(newS)==Dist[v].end() || Dist[v][newS]>newVal)
            {
                Dist[v][newS]=newVal;
                Q.push(State(newS,v,newVal));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4580
N,Q = gets.split.map(&:to_i)
S = gets.chomp
ac = [0]*(N)
(N-1).times do |i|
  if S[i] == "A" && S[i+1] == "C"
    ac[i+1] = ac[i] + 1
  else
    ac[i+1] = ac[i]
  end
end
Q.times do
  l,r = gets.split.map(&:to_i)
  p ac[r-1]-ac[l-1]
end


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

int main() {
    int n, a[100];
    cin >> n;
    
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    }
    
	for (int k = 0; k < n; k++) {
		cout << a[k];
		if (k < n - 1) {
			cout << " ";
		} else	{
			cout << endl;
		} 	 
	}
     
    for (int i = 1; i < n; i++) {
    	int v = a[i];
    	int j = i - 1;
    	while (j >= 0 && a[j] > v) {
    		a[j+1] = a[j];
    		j--;
    	}
    	a[j+1] = v;
    	
        for (int k = 0; k < n; k++) {
     	    cout << a[k];
     	    if (k < n - 1) {
     	 	    cout << " ";
            } else	{
         	 cout << endl;
            }
        } 	
    }
     
	return 0;
}


Measured memory_bytes: 3088
N, Q = [int(_) for _ in input().split()]
S = '.' + input() + '.'
TD = [input().split() for _ in range(Q)]


def check(x):
    for t, d in TD:
        if S[x] == t:
            if d == 'L':
                x -= 1
                if x == 0:
                    return -1
            else:
                x += 1
                if x == N + 1:
                    return 1
    return 0


#to_left_end
ok = 0
ng = N + 1

while ng - ok > 1:
    mid = (ok + ng) // 2
    if check(mid) == -1:
        ok = mid
    else:
        ng = mid
l = ok

#to_right_end
ok = N + 1
ng = 0
while ok - ng > 1:
    mid = (ok + ng) // 2
    if check(mid) == 1:
        ok = mid
    else:
        ng = mid
r = ng
print(r - l)

# https://img.atcoder.jp/exawizards2019/editorial.pdf


Measured memory_bytes: 92588
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string S;
    cin >> S;
    // YYMM => 1 <= MM <= 12ならあり得る
    // MMYY => 1 <= MM <= 12ならあり得る
    bool flag1 = false, flag2 = false;
    int mm1 = stoi(S.substr(2));
    int mm2 = stoi(S.substr(0, 2));

    if(mm1 >= 1 && mm1 <= 12) flag1 = true;
    if(mm2 >= 1 && mm2 <= 12) flag2 = true;
    if(flag1 && flag2) {
        cout << "AMBIGUOUS" << endl;
    } else if(flag1) {
        cout << "YYMM" << endl;
    } else if(flag2) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
from collections import defaultdict

s=input()
d=defaultdict(int)

dp=0
d[0]+=1
r=1
for i in range(len(s)-1,-1,-1):
	dp+=int(s[i])*r
	dp%=2019
	d[dp]+=1
	r*=10
	r%=2019
	
res=0

l=list(d.values())
for a in l:
	res+=a*(a-1)//2
	
print(res)


Measured memory_bytes: 9532
class Dice():
    def __init__(self,num):
        self.num = num
    def n_roll(self):
        self.num = [self.num[1],self.num[5],self.num[2],self.num[3],self.num[0],self.num[4]]
    def e_roll(self):
        self.num = [self.num[2],self.num[1],self.num[5],self.num[0],self.num[4],self.num[3]]
    def r_spin(self):
        self.num = [self.num[0],self.num[2],self.num[4],self.num[1],self.num[3],self.num[5]]
dice = Dice(input().split())
n = int(input())
for i in range(n):
    top, front = input().split()
    right = ""
    if top == dice.num[0] or top == dice.num[1] or top == dice.num[4] or top == dice.num[5]:
        for j in range(4):
            if top == dice.num[0]:
                break
            dice.n_roll()
    else:
        for j in range(4):
            dice.e_roll()
            if top == dice.num[0]:
                break
    for j in range(4):
        if top == dice.num[0] and front == dice.num[1]:
            break
        dice.r_spin()
    print(dice.num[2])


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N, T;
    cin >> N >> T;
    int c[N], t[N];
    for (int i = 0; i < N; i++)
    {
        cin >> c[i] >> t[i];
    }

    int ans = 1e9;
    for (int i = 0; i < N; i++)
    {
        if(t[i] <= T) ans = min(ans, c[i]);
    }

    if(ans == 1e9) cout << "TLE" << endl;
    else cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    vector<double> x(n), y(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    vector<int> a(n);
    iota(a.begin(), a.end(), 0);
    double sum = 0.0;
    do{
        for(int i = 1; i < n; i++) {
            sum += sqrt(pow((x[a[i]] - x[a[i-1]]), 2) + pow((y[a[i]] - y[a[i-1]]), 2));
        }
    }while(next_permutation(a.begin(), a.end()));
    for(int i = 1; i <= n; i++) sum /= (double)i;
    printf("%.12lf\n", sum);

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderPre
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var B = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            long count = 0;

            for (int i = 0; i < N; i++)
            {
                if (A[i] >= B[i])
                {
                    count += B[i];
                    A[i] -= B[i];
                    //Console.WriteLine("大きい");
                    //Console.WriteLine(count);
                }
                else
                {
                    count += A[i];

                    if (B[i] - A[i] >= A[i + 1])
                    {
                        count += A[i + 1];
                        A[i + 1] = 0;
                        //Console.WriteLine("小さい大きい");
                        //Console.WriteLine(count);

                    }
                    else
                    {
                        count += B[i] - A[i];
                        A[i + 1] -= (B[i] - A[i]);
                        //Console.WriteLine("小さい小さい");
                        //Console.WriteLine(count);
                    }
                }
            }

            Console.WriteLine(count);

        }

    }
}

Measured memory_bytes: 35024
n=gets.to_i
a=gets.split.map(&:to_i)
m=a.delete(a.max)
l=0
lm=1/0.0
a.each do |aa|
  ab=(aa-m/2.0).abs
  lm,l=ab,aa if ab<lm
end
puts "#{m} #{l}"

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

int gcd(int a, int b){
    if(a < b) swap(a,b);
    return((a%b == 0 ? b : gcd(b,a%b)));
}

int main(){
    int N;
    cin>>N;
    vector<int>  A(N);
    vector<int> R(N+1);
    vector<int> L(N+1);

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

    L[0] = A[0];
    R[N] = A[N-1];

    for(int i=0; i<N-1; i++){
        L[i+1] = gcd(A[i],L[i]);
    }

    for(int i=N-1; i>=0; i--){
        R[i] = gcd(A[i],R[i+1]);
    }

    vector<int> dic;
    dic.push_back(R[1]);

    for(int i=1; i<N; i++){
        if(N-1 == i) dic.push_back(L[i]);
        else dic.push_back(gcd(L[i],R[i+1]));
    }

    sort(dic.begin(),dic.end());

    int ans = *max_element(dic.begin(),dic.end());

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2044
integer(8)::a(9)=[1,2,4,7,12,20,29,38,52],f(10)=0
read(*,*)n
f(3)=1
do i=4,n
 f(i)=f(i-1)*(a(i-2)+a(i-3)+1)
enddo
do i=1,n
 do j=1,n
  write(*,*)merge(0_8,f(max(i,j))*a(min(i,j))+1,i==j)
 enddo
enddo
end

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

#define ll long long

int MAX(int a, int b){
    if(a >= b) return a;
    else return b;
}

int main(){

    int N,M;
    int i,j,k;
    int count=0;
    bool flag = false;

    cin >> N;

    vector<int> a(100);

    for(i=0;i<N;i++)cin >> a.at(i);

    sort(a.begin(),a.end(),greater<int>());

    int ans = 0;

    for(i=0;i<N;i+=2)ans += (a.at(i)-a.at(i+1));

    cout << ans << endl;

}

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

  vector<ll> divisor(ll n){
    vector<ll> ret;
    for (ll i = 1 ; i*i <= n ; i++){
      if(n%i == 0 ){
        ret.push_back(i);
        if(i!=1&&i*i!=n){
          ret.push_back(n/i);
        }
      }
    }
    sort(ret.begin(),ret.end());
    return ret;
  }

int main(){
	int N ;
	cin >> N ;
	int ans = 0 ;
    auto P = divisor(N) ;
    //cout << P.size() << endl;
	rep(i,N+1){
      if( i%2 == 1 ){
        auto A = divisor(i) ;
        if( A.size() == 7 ) ans++ ;
      }
    }
	cout << ans << endl;
}

Measured memory_bytes: 256
from math import ceil

def main():
    A, B, C, D = map(int, input().split())

    t_turns = ceil(A / D)
    a_turns = ceil(C / B)

    if t_turns >= a_turns:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()



Measured memory_bytes: 9164
from sys import stdin, stdout  
  
def main(): 
	s = stdin.readline().rstrip()
	t = stdin.readline().rstrip()
	if len(t) == len(s) + 1 and t[:len(s)] == s:
		stdout.write('Yes\n')
	else:
		stdout.write('No\n')


if __name__ == "__main__": 
	main()

Measured memory_bytes: 9044
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> A(n);
    for(int i = 0; i < n; ++i) cin >> A[i];
    vector<int> Sum(n+1);
    Sum[0] = 0;
    for(int i = 0; i < n; ++i){
        Sum[i+1] += (Sum[i] + A[i]) % m;
    }
    long long ans = 0;
    map<int, int> hash;
    for(int i = 0; i < Sum.size(); ++i){
        ans += hash[Sum[i]];
        hash[Sum[i]]++;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3968
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int y,m,d;
    scanf("%d/%d/%d",&y,&m,&d);
    bool f=true;
    if(y<=2018){
        
    }else{
        if(m<=4){

        }else{
            f=false;
        }
    }
    if(f){
        cout << "Heisei\n";
    }else{
        cout << "TBD\n";
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> height(n);
  for(int i = 0; i < n; i++){
    cin >> height.at(i);
  }
  int max = 0;
  for(int i = 0; i < n-1; i++){
    int cnt = 0;
    int j = i;
    while(j < n-1 && height.at(j) >= height.at(j+1)){
      j++;
      cnt++;
    }
    if(cnt >= max) max = cnt;
    if(max > n/2) break;
  }
  cout << max << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;


void solve(){
    string s;
    cin >> s;
    string ans = "AC";
    if(s[0]!='A') ans = "WA";
    
    int siz = s.size();
    int count = 0;
    for(int j=2; j<=siz-2; j++){
        if(s[j]=='C') count++;
    }
    if(count!=1) ans = "WA";

    bool b=true;
    rep(i,siz){
        char c = s[i];
        b = b && (c=='A'||c=='C'||('a'<=c&&c<='z'));
    }
    if(!b) ans = "WA";
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef pair<int, int> PII;
typedef queue<int> QI;
typedef long long LL;

int main() {
	int n; cin >> n;
	VI a; REP(i, n) { int x; cin >> x; a.PB(x); }
	if (all_of(ALL(a), [](int x) { return x % 2 == 0; }))puts("second"); else puts("first");
}

Measured memory_bytes: 892
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
from collections import defaultdict
ns = defaultdict(set)
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    ns[a].add(b)
    ns[b].add(a)

# 二部グラフ判定 bipertite
cs = [None]*n
def is_bip(u):
    q = [start]
    cs[start] = 1
    v1 = 1
    v0 = 0
    bip = True
    while q:
        u = q.pop()
        c = cs[u]
        cc = int(not c)
        for v in ns[u]:
            if cs[v] is None:
                cs[v] = cc
                if cc==0:
                    v0 += 1
                else:
                    v1 += 1
                q.append(v)
            elif cs[v]==c:
                bip = False
    if bip:
        return True, v0, v1
    else:
        return False, v0+v1, 0
types = []
vals = []
ans = 0
n0 = 0
n1 = 0
n2 = 0
nv = 0
for start in range(n):
    if cs[start] is not None:
        continue
    res, v0, v1 = is_bip(start)
#     print(res, v0,v1)
    if v0+v1==1:
        # 孤立点
        n0 += 1
    elif res:
        # 二部グラフ
        nv += (v0+v1)
        n1 += 1
    else:
        nv += (v0+v1)
        n2 += 1
ans += n0*nv*2
ans += n0**2
ans += (n1+n2)**2 + n1**2
print(ans)

Measured memory_bytes: 111860
import java.util.Scanner;

public class Main {

    static int MOD = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int sq = (int) Math.ceil(Math.sqrt(M));
        int prime = 0;
        long ans = 1;
        Combination comb = new Combination(N + sq, MOD);
        for(int i = 2; i <= sq; i++){
            if(M%i == 0){
                prime = 0;
                while(M%i == 0){
                    prime++;
                    M /= i;
                }
                ans = (ans * comb.comb(N-1+prime, Math.min(N-1, prime))) %MOD;
            }
        }
        if(M > 1) ans = (ans * N) %MOD;
        System.out.println(ans);
        sc.close();

    }

}

class Combination {

    long fac[]; // factorial:階乗
    long inv[]; // inverse:逆元（ここでは、fac[i]をMOD-2乗したものをMODで割った余り）
    int MOD;

    Combination(int size, int mod){
        this.fac = new long[size +1];
        this.inv = new long[size +1];
        this.MOD = mod;

        this.fac[0] = 1;
        this.inv[0] = 1;

        for(int i = 1; i <= size; i++){
            fac[i] = (fac[i -1] * i) %MOD;
            inv[i] = modPow(fac[i], (int)MOD -2) %MOD;
        }
    }

    /*
     * n個の中からr個選ぶ組み合わせの数 nCr をMODで割った余りを算出する
     */
    long comb(int n, int r){
        return fac[n] * inv[r] %MOD * inv[n - r] %MOD;
    }

    /*
     * base^exp をMODで割った余りを算出する
     * 計算量：O(log(exp))
     */
    private long modPow(long base, int exp) {
        long ret = 1;
        while(exp > 0){
            if((exp & 1) == 1){
                ret = ret * base %MOD;
            }
            base = base * base %MOD;
            exp >>= 1;
        }
        return ret;
    }

}



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


int main(){
  int H,N; cin >> H >> N;
  vector<pair<int,int>> magic;
  int maxpower=0;
  for(int i=0; i<N; i++){
    int a,b; cin >> a >> b;
    maxpower=max(maxpower,a);
    magic.emplace_back(a,b);
  }
  
  //first power, second mp
  vector<int> dp(H+maxpower, 1e9);
  dp[0]=0;
  for(int i=1; i<H+maxpower; i++){
    for(int m=0; m<N; m++){
      if(i>=magic[m].first){
        if(dp[i-magic[m].first]<1e9){
          dp[i]=min(dp[i],dp[i-magic[m].first]+magic[m].second);
        }
      }
    }
  }
  
  int result=1e9;
  for(int i=H; i<H+maxpower; i++) result=min(result,dp[i]);
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
//typedef tuple<ll, ll, ll> tp;
const ll INF = 1e18;
const ll mod = 1e9+7;

ll par[100005];
ll rnk[100005];
ll nnum[100005];

ll find(ll x){
  if(par[x] == x) return x;
  else{
    par[x] = find(par[x]);
    return par[x];
  }
}
  
void unite(ll x, ll y){
  x = find(x);
  y = find(y);
  if (x == y) return;
  
  if (rnk[x] < rnk[y]){
    par[x] = y;
    nnum[y] = nnum[x] + nnum[y];
  }
  else{
    par[y] = x;
    nnum[x] = nnum[x] + nnum[y];
    if(rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(ll x, ll y){
  return find(x) == find(y);
}


int main() {
  ll n, m;
  cin >> n >> m;
  deque<edge> que;
  for(int i=0;i<m;i++){
    ll a, b;
    cin >> a >> b;
    que.push_front(edge(a,b));
  }
  
  ll ans[m];
  for (int i=0;i<n;i++){
    par[i]=i;
    rnk[i]=0;
    nnum[i]=1;
  }
  
  ans[m-1] = n*(n-1)/2;
  for(int i=1; i<m; i++){
    edge e = que.front(); que.pop_front();
    ll e1 = e.first;
    ll e2 = e.second;
    if (same(e1, e2)){
      //cout << "t" << e1 << e2 << endl;
      ans[m-1-i] = ans[m-i];
    }
    else{
      //cout << "a" << e1 << e2 << endl;
      //cout << "b" << find(e1) << find(e2) << endl;
      //cout << "c" << nnum[find(e1)] << nnum[find(e2)] << endl;
      ans[m-1-i] = ans[m-i] - nnum[find(e1)]*nnum[find(e2)];
      unite(e1, e2);
    }
  }
  
  for(int i=0; i<m; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(i) cout<<i<<endl;
const int mod=720720;
int main(){
//IOS;
lli x,y,z,k,i,j;
cin>>x>>y>>z>>k;
lli a[x],b[y],c[z];
for(i=0;i<x;i++){
    cin>>a[i];
}
for(i=0;i<y;i++){
    cin>>b[i];
}
for(i=0;i<z;i++){
    cin>>c[i];
}
sort(a,a+x,greater<lli>());
sort(b,b+y,greater<lli>());
sort(c,c+z,greater<lli>());
set<vector<int> > s;
priority_queue<pair<lli,vector<int> > > pq;
vector<int> index(3,0);
pq.push({a[0]+b[0]+c[0],index});
s.insert(index);
lli sum;
//cout<<"yo";
while(k--){
    sum=pq.top().first;
    cout<<sum<<endl;
    index=pq.top().second;
    pq.pop();
    for(i=0;i<3;i++){
        index[i]++;
        if(index[0]<x&&index[1]<y&&index[2]<z){
        if(s.find(index)==s.end()){
            //cout<<index[0]<<" "<<index[1]<<" "<<index[2]<<endl;
            sum=a[index[0]]+b[index[1]]+c[index[2]];
            pq.push({sum,index});
            s.insert(index);
        }
        }
        index[i]--;
    }
    //cout<<pq.size()<<endl;
}
}


Measured memory_bytes: 1280
import heapq as hq
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
ans = 0
seat = [-A[0]]
hq.heapify(seat)
for i in range(1, N):
	a = A[i]
	ans -= hq.heappop(seat)
	hq.heappush(seat, -a)
	hq.heappush(seat, -a)
print(ans)

Measured memory_bytes: 31820
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readIntegerList()
    val xList = readIntegerList()

    var ans = Int.MAX_VALUE
    for (i in 0 until (n - k + 1)) {
        val left =  xList[i]
        val right = xList[i + k - 1]
        ans = if (left < 0 && 0 < right) {
            val a = min(ans, abs(left) * 2 + right)
            min(a, abs(left) + right * 2)
        } else {
            min(ans, max(abs(left), abs(right)))
        }
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)




Measured memory_bytes: 50976
#include<stdio.h>
#include<string.h>
char data[1000];
char s[1000];
int main(){
  gets(data);
  strcat(s,data);
  strcat(s,data);
  gets(data);
  char*p=s;
  int len=strlen(data);
  while(*p!=0){
    if(!strncmp(p,data,len)){
      printf("Yes\n");
      return 0;
    }
    ++p;
  }
  printf("No\n");
  return 0;
}

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

using namespace std;

int main(){
    int n,a,b,c;
    cin >> n;
    vector<vector<int>> inp(n,vector<int>(3));
    for(int t=0;t<n;t++){
        cin >> a >> b >> c;
        inp[t][0]=a;
        inp[t][1]=b;
        inp[t][2]=c;
    }
    vector<vector<int>> dp(n,vector<int>(3));
    dp[0][0]=inp[0][0];
    dp[0][1]=inp[0][1];
    dp[0][2]=inp[0][2];
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+inp[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+inp[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+inp[i][2];
    }
    cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << '\n';
}

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

using namespace std;

#define up(i,j,n)	for(int i=j;i<=n;i++)
#define pii	pair<int,int>
#define fi 	first
#define se	second

const int MAXN=2e5+5;

int N,M,a[MAXN],lower=0;
multiset<pii>S;

int main(){
	// freopen("input.in","r",stdin);
	scanf("%d%d",&N,&M);
	up(i,1,N){
		a[i]=i;
		S.insert(make_pair(i,i));
	}
	while(M--){
		int x;
		scanf("%d",&x);
		S.erase(S.find(make_pair(a[x],x)));
		a[x]=lower--;
		S.insert(make_pair(a[x],x));
	}
	for(multiset<pii>::iterator it=S.begin();it!=S.end();it++)
		printf("%d\n",(*it).se);
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool a[26];
  int i;
  char j;
  for(i = 0; i < 26; i++) a[i] = true;
  for(i = 0; i < s.length(); i++){
    j = s[i] - 97;
    a[j] = false;
  }
  j = 0;
  for(i = 0; i < 26; i++){
    if(a[i]){
      j = i + 97;
      break;
    }
  }
  if(j != 0) cout << j << endl;
  else cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
def read():
    N = int(input().strip())
    S = str(input().strip())
    return N, S

def solve(N, S):
    if N % 2 == 0:
        half = N // 2
        return S[:half] == S[half:]
    return False

def yesno(flag):
    return "Yes" if flag else "No"

if __name__ == '__main__':
    inputs = read()
    output = solve(*inputs)
    output = yesno(output)
    print("%s" % output)


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#define loop(n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define INF 999999999;
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
#define ll long long int 

using namespace std;

int main()
{
	int n;
	cin >> n;
	ans(n*(n + 1) / 2);
}

Measured memory_bytes: 256
n = int(input())
lis = list(map(int, input().split()))
mod = 1000000007
pre = [0] * n
su = 0
total = sum(lis)
for i in range(n):
    su += lis[i]
    pre[i] = su
suf = [0] * n
for i in range(n):
    suf[i] = total-pre[i]
ans = 0
for i in range(n):
    ans = (ans + (lis[i] * suf[i]) % mod) % mod
print(ans)

Measured memory_bytes: 36068
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int L, R, d;
  cin >> L >> R >> d;
  
  int count = 0;
  
  for (int i = L; i <= R; i++)
  {
    if(i % d == 0) count++; 
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    sc.close();
    int ans = 0;
    for(int i = 0; i < n.length(); i++){
      ans += (n.charAt(i) - '0');
    }
    System.out.println(ans % 9 == 0 ? "Yes" : "No");
  }
}

Measured memory_bytes: 40260
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    int n,i,x;
    vector<int>v;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    if(n==1)
    {
        cout<<"0"<<endl;
    }
    else
    {
    sort(v.begin(),v.end());
        cout<<v[v.size()-1]-v[0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, i, j, ans=0, pro, tas;
    cin >> n;
    vector<long long> a(n), rui(n+1);
    rui.at(0)=0;
    for(i=0;i<n;i++){
        cin >> a.at(i);
        rui.at(i+1)=rui.at(i)+a.at(i);
        rui.at(i+1);
        
    }
    for(i=0;i<n-1;i++){
        tas = (rui.at(n)-rui.at(i+1));
        tas%=1000000007;
        if(tas<0) tas+=1000000007;
        pro=(a.at(i)%1000000007)*tas;
        pro%=1000000007;
        ans+=pro;
        ans%=1000000007;
    }

    cout << ans <<endl;
}

Measured memory_bytes: 6388
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a,b[200200],l[200200],r[200200];
long long res;
int main() {
  scanf("%d",&n);
  for (i=1; i<=n; i++) {
    scanf("%d",&a);
    b[a]=i;
  }
  for (i=n; i>0; i--) {
    j=b[i];
    l[j]=r[j]=j;
    if (j>1 && r[j-1]!=0) l[j]=l[j-1];
    if (j<n && l[j+1]!=0) r[j]=r[j+1];
    l[r[j]]=l[j];
    r[l[j]]=r[j];
    res+=(j-l[j]+1LL)*(r[j]-j+1LL)*i;
  }
  printf("%lld\n",res);
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



int main() {
	string s;
	ll k;
	cin >> s;
	cin >> k;
	ll l = s.length();
	bool ok = true;
	char res;
	ll cnt = 0;
	REP(i, l) {
		if (s[i] != '1') {
			if (ok) {
				res = s[i];
				ok = false;
				break;
			}
			else {
				break;
			}
		}
		cnt++;
	}
	if (k <= cnt)cout << 1 << endl;
	else cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int a,b,c;

while(1)
{
scanf("%d %d %d",&a,&b,&c);
if(0<=a,b,c&&a,b,c<=100);
break;
}

if(a<b&&b<c)
printf("Yes\n");

else
printf("No\n");

return 0;
}

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

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

int main(void){
	int N;
	string s;
	cin >> N >> s;
	int ans = 0;
	REP(i,N-2) if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] =='C') ans++;
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  ll A,B,N;
  cin >> A >> B >> N;
  ll ans = 0;
  if(B > N){
    cout << (A*N)/B << endl;
    return 0;
  }else{
    /*
    for(int i = B-1;i <= N;i+=B){
      ll tmp;
      tmp = (A*i)/B - A*(i/B);
      ans = max(ans,tmp);
    }*/

    ll i = B-1;
    //while(i <= N){
      ll tmp = 0;
      tmp = (A*i)/B - A*(i/B);
      ans = max(ans,tmp);
    //  i += B;
    //}
  }
  cout << ans << endl;


}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);

using namespace std;

int main(){_
    int n,k;
    cin >> n >> k;
    int fruits[n];
    for(int i=0;i<n;i++){
        cin >> fruits[i];
    }
    sort(fruits, fruits+n);
    int min_soma = 0;
    for(int i=0;i<k;i++) min_soma += fruits[i];
    cout << min_soma << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



signed main() {
	int n; cin >> n;
	for (int i = 1; i < 10; i++) {
		if (n % i == 0 && n / i < 10) {
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        for (int i = 1; i <= N; i++) {
            A[i] = sc.nextInt();
        }
        Map<Integer, Integer> diff = new HashMap<>();
        for (int i = 1; i <= N; i++) {
            int d = i-A[i];
            diff.put(d, diff.getOrDefault(d,0)+1);
        }
        long ans = 0;
        for (int i = 1; i <= N; i++) {
            int sum = i+A[i];
            ans += diff.getOrDefault(sum,0);
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 68572
#n = int(input())
n,x,t = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
v=0
if n%x==0:
    ans=(n//x)*t
else:
    ans=(n//x)*t+t
print(ans)

Measured memory_bytes: 9104
using System;
class P{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int ans = (n < 105) ? 0 : (n < 135) ? 1 : (n < 165) ? 2 : (n < 189) ? 3 : (n < 195) ? 4 : 5;
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13140
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
W = len(list(A[0]))-len(list(B[0]))+1
H = N - M + 1
ans = "No"
for i in range(H):
    for j in range(W):
        tmpA = []
        for k in range(M):
             tmpA.append(A[i+k][j:j+len(list(B[0]))])
        if tmpA == B:
            ans = "Yes"
            break
print(ans)

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

int main() {
 int N,K;
  string S;
  cin >> N >>K >>S;
  int m= S.size();
  vector<char> k(m);
  for (int i=0;i<m;i++){
    k.at(i) = S.at(i);
  }
  if(k.at(K-1) == 'A'){
   k.at(K-1) = 'a' ;
  }
  else if(k.at(K-1) == 'B'){
   k.at(K-1) = 'b' ;
  }
  else {
   k.at(K-1) ='c' ;
  }
  for (int i=0;i<m;i++){
   cout << k.at(i); 
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
MOD = 10**9 + 7

d = {}
for i in range(2,n+1):
    for j in range(2,i+1):
        while i%j==0:
            if j not in d:
                d[j] = 1
            d[j] += 1
            i = i//j
ret = 1
for v in d.values():
    ret = (ret*v)%MOD
print(ret)


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

int dp[2][200000];

int main() {
  string s;
  cin>>s;
  int n = s.length();
  for (int i=0; i<n; i++) {
    dp[0][i] = 0;
    dp[1][i] = 0;
  }
  dp[0][0] = 1;
  dp[1][1] = 1;
  dp[0][1] = (s[0] != s[1]) + 1;

  for (int i=2; i<n; i++) {
    if (s[i] != s[i-1]) dp[0][i] = dp[0][i-1] + 1;
    dp[0][i] = max(dp[1][i-1] + 1, dp[0][i]);
    if (i > 3 && s.substr(i-1, 2) != s.substr(i-3, 2)) dp[1][i] = dp[1][i-2] + 1;
    dp[1][i] = max(dp[0][i-2] + 1, dp[1][i]);
  }
  cout<<max(dp[0][n-1], dp[1][n-1])<<endl;
}

Measured memory_bytes: 2180
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int x;
	cin>>x;
	cout<<((x<1200)?"ABC":"ARC")<<endl;
	return 0;	
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from functools import reduce

def main():
    N, M = LI()
    if N >= M // 2:
        return M // 2
    rem = M - 2 * N
    ans = N + rem // 4
    return ans

print(main())

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

int main() {
    int a, b; cin >> a >> b;

    if (a * b % 2 == 0)
        puts("No");
    else
        puts("Yes");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
//nまでの数の総和を求める
int64 f(int64 n) {
	return (n * (n + 1) / 2);
}

void solve() {
	int64 N; cin >> N;
	int64 ans = 0;
	for (int64 i = 1; i <= N; ++i) {
		//1～Nまでの総和はn * (n + 1) / 2→1の倍数を全て足しているとみなせる
		//上記をf(N)とする
		//Nをiで割り、f(N / i) * iとすることで、iのNまでの倍数の総和が求められる
		//上記は1～Nまでの1の倍数からiの倍数を取り出して、足し合わせている操作とみなせる
		ans += (i * f(N / i));
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3640
// E-E - XOR Partitioning.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <cassert>
#include <string>
#include <cstdlib>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define ALL(x) x.begin(), x.end()
#define MOD lolo(1000000007)

lolo myPow(lolo x, lolo n, lolo m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

int main()
{
	lolo N;
	cin >> N;
	vec A(N);
	vec s(N+1,0);
	FOR(i, N) cin >> A[i];
	FOR(i, N) s[i + 1] = A[i] ^ s[i];

	vvec DP1(N + 1, vec(2, 0));
	vvec DP2(N + 1, vec(2, 0));
	// DP1が有効、DP2 は無効( スキップ )

	DP1[0][0] = 1;

	FOR(i, N+1)
		cerr << s[i] << " ";
	cerr << endl;

	if (s.back() != 0) {
		lolo X = s.back();
		FOR(i, N) {
			(DP2[i + 1][0] += DP2[i][0]) %= MOD;
			(DP2[i + 1][1] += DP2[i][1]) %= MOD;
			(DP2[i + 1][0] += DP1[i][0]) %= MOD;
			(DP2[i + 1][1] += DP1[i][1]) %= MOD;

			if (s[i+1 ] == 0) {	
				(DP1[i + 1][0] += DP1[i][1]) %= MOD;
				(DP1[i + 1][0] += DP2[i][1]) %= MOD;	
			}
			else if (s[i+1] == X) {
				(DP1[i + 1][1] += DP1[i][0]) %= MOD;
				(DP1[i + 1][1] += DP2[i][0]) %= MOD;
			}
		}
		cout << DP1[N][1] << endl;			
	}
	else {
		vec X(1 << 20, 0);
		vec Y(1 << 20, 1);
		vec Z(1 << 20, 0); 

		lolo z = 0;
		
		FOR(i, N) {
			lolo n = s[i+1];

			if (n == 0) {
				z += 1;
				continue;
			}
			else {
				// Xはその数字を踏んだ場合の数
				// Yはすでにゼロを踏んだ(しかしそのマスは踏まない)場合の数

				lolo nz = z - Z[n];
				lolo newX;
				lolo newY; 

				//newY = (nz * X[n] + Y[n]) % MOD;
				//newX = (X[n] + newY) % MOD;


				newX = (nz + 1) * X[n] + Y[n];
				newY = nz * X[n] + Y[n];


				X[n] = newX % MOD;
				Y[n] = newY % MOD;
				Z[n] = z % MOD;
			}
		}

		lolo ans = 0;
		lolo zero_cnt = 0;
		FOR(i, N) {
			if (s[i + 1] == 0) zero_cnt += 1;
		}
		ans += myPow(2, zero_cnt - 1, MOD);

		FOR(i, 1 << 20) {
			(ans += X[i]) %= MOD;
		}

		cout << ans % MOD << endl;
	}

}


Measured memory_bytes: 87424