akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//
// https://atcoder.jp/contests/abc133/tasks/abc132_f

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename INT>
struct ListCostGraph
{
	struct Edge
	{
		size_t from;
		size_t to;
		INT cost;
	};
	vector<vector<Edge>> edges;
	
	ListCostGraph(size_t size)
	{
		edges.resize(size);
	}
	
	void add_edge(size_t from, size_t to, INT cost)
	{
		edges[from].push_back(Edge{from, to, cost});
	}
	
	void add_edge_bidir(size_t a, size_t b, INT cost)
	{
		add_edge(a, b, cost);
		add_edge(b, a, cost);
	}
	
	vector<INT> dijkstra(size_t s)
	{
		// O(E logV)
		vector<INT> dist(edges.size(), numeric_limits<INT>::max());
		struct P
		{
			size_t vertex;
			INT distance;
			P(size_t vertex, INT distance) : vertex(vertex), distance(distance) {}
		};
		auto compare = [](const P &lhs, const P &rhs) { return lhs.distance > rhs.distance; };
		priority_queue<P, vector<P>, decltype(compare)> que(compare);
		dist[s] = 0;
		que.push(P(s, 0));
		while (!que.empty())
		{
			P p = que.top();
			que.pop();
			size_t v = p.vertex;
			INT d = p.distance;
			if (dist[v] < d)
			{
				continue;
			}
			for (int i = 0; i < edges[v].size(); i++)
			{
				const Edge &e = edges[v][i];
				INT new_dist = dist[v] + e.cost;
				if (dist[e.to] <= new_dist)
				{ // eを使っても最短経路が改善しないとき
					continue;
				}
				dist[e.to] = new_dist;
				que.push(P(e.to, new_dist));
			}
		}
		return dist;
	}
};

int main(int argc, char* argv[]) {
	int N, M, S, T;
	cin >> N >> M >> S >> T;
	S--;
	T--;
	ListCostGraph<ll> yen_graph(N);
	ListCostGraph<ll> snk_graph(N);
	for (int i = 0; i < M; i++) {
		int U, V;
		ll A, B;
		cin >> U >> V >> A >> B;
		U--;
		V--;
		yen_graph.add_edge_bidir(U, V, A);
		snk_graph.add_edge_bidir(U, V, B);
	}
	vector<ll> yen_dist = yen_graph.dijkstra(S);
	vector<ll> snk_dist = snk_graph.dijkstra(T); 
	vector<ll> costs_min;
	ll cost_min = numeric_limits<ll>::max();
	for (int i = 0; i < N; i++) {
		ll cost = yen_dist[N-i-1] + snk_dist[N-i-1];
		cost_min = min(cost_min, cost);
		costs_min.push_back(cost_min);
	}
	for (int i = N-1; i >= 0; i--) {
		cout << 1000000000000000 - costs_min[i] << endl;
	} 
}


Measured memory_bytes: 22780
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int M = 120000;
typedef long long ll;
int n,m,k;
char s[M];
bool ok(){
    if(n&1) return 1;
    fo(i,0,n-1){
        if(s[i]!='h'||s[i+1]!='i') return 1;
        ++i;
    }
    return 0;
}
int main(){
    cin>>s;
    n=strlen(s);
    if(ok()) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
s = len(S)
t = len(T)

def checkCommonLength(a: str, b: str) -> int:
    l = len(a)
    count = 0
    for i in range(l):
        if a[i] == b[i]:
            count += 1
    return count

max_val = 0
for i in range(s):
    if i + t <= s:
        testStr = S[i : i + t]
        #print(testStr)
        max_val = max(max_val, checkCommonLength(S[i : i + t], T))

print(t - max_val)


Measured memory_bytes: 9076
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=650;
//↑templete
vint node[SIZE];
int N, M;
double DFS(int now, int rem, vector<double>& ex){
	if(now==N-1)
		return 0.;
	if(ex[now])
		return ex[now];
	double ret=0.;
	double maxi=0.;
	for(int next:node[now]){
		double temp=DFS(next, rem, ex);
		ret+=temp;
		maxi=max(maxi, temp);
	}
	if(now==rem && node[now].size()>1){
		ret-=maxi;
		ret/=(node[now].size()-1);
	}
	else{
		ret/=node[now].size();
	}
	ex[now]=ret+1.;
	return ret+1.;
}
int main(){
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int s,t;
		cin>>s>>t;
		s--, t--;
		node[s].pb(t);
	}
	double ans=INF;
	for(int i=0;i<N;i++){
		vector<double> ex(N);
		ans=min(ans, DFS(0, i, ex));
	}
	cout<<setprecision(20)<<fixed<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  int x[109];
  cin>>n;
  rep(i,n)cin>>x[i];
  double sum=0;
  rep(i,n)sum+=x[i];
  int p=round(sum/(double)n);
  int ans=0;
  rep(i,n){
    ans+=(x[i]-p)*(x[i]-p);
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<int> sieve_of_eratosthenes(int n) {
	vector<int> primes(n);
	for (int i = 2; i < n; ++i)
		primes[i] = i;
	for (int i = 2; i*i < n; ++i)
		if (primes[i])
			for (int j = i*i; j < n; j += i)
				primes[j] = 0;
	return primes;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int res = 0;
	vector<int> primes = sieve_of_eratosthenes(N + 10);
	for (int i = 3; i <= N; i++) {
		//cerr << i << endl;
		//cerr << primes[i] << " " << primes[i + 2] << endl;
		if (primes[i] == i && primes[i + 2] == i+2) {
			res++;
		}
	}
	cout << res*2 << endl;
}


Measured memory_bytes: 80972
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
int L, R;
int m[2020];
int ans = 2018;

int main() {
	for (int i = 0;i < 2019;i++) {
		m[i] = 0;
	}

	cin >> L >> R;
	for (int i = L;i <= min(R,L+4038);i++) {
		if (m[i % 2019] == 0) {
			m[i % 2019] = 1;
		}	else if (m[i % 2019] == 1) { //2個以上のとき
			m[i % 2019] = 2;
		}
	}

	for (int i = 0;i < 2019;i++) {
		for (int j = 0;j <= i;j++) {
			if (m[i] != 0 && m[j] != 0 && (j < i || m[i] == 2)) {

				if ((i * j) % 2019 < ans) {
					ans = (i * j) % 2019;
				}
			}
		}
	}

	cout << ans;

	return 0;
}


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

using namespace std;

typedef long long ll;

void find(vector <ll> &ans, ll h, ll w){
    if(((h+1)/2)*w-(h/2)*w < ((w+1)/2)*h-(w/2)*h){
        ans.push_back((h/2)*w);
        ans.push_back(((h+1)/2)*w);
    }
    else{
        ans.push_back((w/2)*h);
        ans.push_back(((w+1)/2)*h);
    }
}

int main(){
    ll h,w;
    cin >> h >> w;
    ll res=LONG_LONG_MAX;
    for(int i=1;i<h;i++){
        int rem=h-i;
        vector <ll> ans;
        ans.push_back(i*w);
        find(ans,rem,w);
        sort(ans.begin(),ans.end());
        res = min(res,ans.back()-ans.front());
    }
    for(int i=1;i<w;i++){
        int rem=w-i;
        vector <ll> ans;
        ans.push_back(i*h);
        find(ans,h,rem);
        sort(ans.begin(),ans.end());
        res = min(res,ans.back()-ans.front());
    }
    cout << res << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    p = i*500
    for j in range(b+1):
        q = j * 100
        for k in range(c+1):
            r = k * 50
            if p+q+r == x:
                count+=1           
                
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int n;
  while(cin >> n){
    int ans = -1;

    FORE(x,1,50000){
      if(x * 108 / 100 == n){

        ans = x;
        break;
      }
    }
    


    if(ans == -1){
      cout << ":(" << endl;
    }else{
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
s = input()
if s=="SUN":
  print(7)
elif s=="MON":
  print(6)
elif s=="TUE":
  print(5)
elif s=="WED":
  print(4)
elif s=="THU":
  print(3)
elif s=="FRI":
  print(2)
else:
  print(1)

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

int main() {
  int N, M;
  cin >> N >> M;

  int K [N][M];
  int A [N];
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    A[i] = a;
    
    for(int j = 0; j < a; j++){
      cin >> K[i][j];
    }
  }

  int counter [M];
  memset(counter, 0, sizeof(counter));

  for(int i = 0; i < N; i++){
    for(int j = 0; j < A[i]; j++){
      int index = K[i][j] - 1;
      counter[index] = counter[index] + 1;
    }
  }

  int ans = 0;
  for(int i = 0; i < M; i++){
    if(counter[i] == N){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  long long int size[n];
  for(int i = 0; i < n; i ++){
    cin >> size[i];
  }
  sort(size,size + n);
  int cnt = 1;
  long long ab = size[0];
  for(int i = 1;i < n;i++){
    if(ab * 2 >= size[i]){
      cnt++;
      ab += size[i];
    }
    else{
      cnt = 1;
      ab += size[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef int64_t lint;
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using lb = long double;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SI(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define debug(x) cerr << #x << ": " << x << "\n"//手動デバッグ
#define debugV(x) for(int i=0;i<((ll)(x).size());i++)cerr << #x <<"at:"<<i<< ": " << x[i] << "\n"//手動デバッグ 
#define YES(c) cout<<((c)?"YES\n":"NO\n"),0
#define Yes(c) cout<<((c)?"Yes\n":"No\n"),0
#define O(p) cout<<p<<"\n",0
#define OS(p) cout<<p<<" ",0
#define ON(p) cout<<p,0
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define endl "\n"//endlを置き換える
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定

const int dy[4]={1,0,-1,0};
const int dx[4]={0,1,0,-1};//^>v<

template<class T=int> T in(){
    T x;
    cin>>x;
    return (x);
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
//------------------------------------------------------------





//------------------------------------------------------------
int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
//------------------------------------------------------------
    int n;cin>>n;
    vector<ll> A(n);
    ll sum=0;
    rep(i,n){
        cin>>A[i];
        sum+=A[i];
        sum%=MOD;
    }
    //debug(sum);
    ll ans=0;
    rep(i,n-1){
        sum-=A[i];
        if(sum<0)sum+=MOD;
        ans+=(A[i]%MOD)*sum;
        ans%=MOD;
    }
    O(ans);
    
    
    
    
    
//------------------------------------------------------------
	return 0;
}


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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int x, y;

int main() {
    
    scanf("%d %d", &x, &y);
    for (int a = 0; a <= x; a++) {
        int b = x - a;
        if (a * 2 + b * 4 == y) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 3684
def cnt(str,word)
    return str.scan(word).length
end

s = gets.chomp

dreameraser = cnt(s,"dreameraser")
dreamerase  = cnt(s,"dreamerase" ) - dreameraser
dreamer = cnt(s,"dreamer") - ( dreameraser + dreamerase)
dream   = cnt(s,"dream")  -  ( dreameraser + dreamerase + dreamer)
eraser  = cnt(s,"eraser") - dreameraser
erase   = cnt(s,"erase")  - (dreameraser + dreamerase + eraser )

# puts [dreamer, dream, eraser, erase]
if s.size == 11 * dreameraser + 10 * dreamerase + 7 * dreamer + 5 * dream + 6 * eraser + 5 * erase
    puts "YES"
else
    puts "NO"
end


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

int main() {
    int N;
    cin >> N;
    int h, h_prev;
    int acc = 0;
    cin >> h;
    h_prev = h;
    if ( N > 1) {
        for (int i = 1; i < N; i++) {
            cin >> h;
            if (h < h_prev)
                acc += (h_prev - h);
            if (i == N - 1)
                acc += h;
            h_prev = h;
        }
    } else
        acc = h;
    cout << acc;
    return 0;
}

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


void warshall_floyd(int N, vector<vector<int>> &G, int INF) {
    rep(k, N) rep(i, N) {
        if (G[i][k] == INF) continue;
        rep(j, N) {
            if (G[i][j] > G[i][k] + G[k][j]) {
                G[i][j] = G[i][k] + G[k][j];
            }
        }
    }
}


int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    rep(i, R) cin >> r[i];
    rep(i, R) r[i]--;
    sort(r.begin(), r.end());
    int INF = 1 << 30;
    vector<vector<int>> G(N, vector<int>(N, INF));
    int A, B, C;
    rep(i, M) {
        cin >> A >> B >> C;
        A--; B--;
        G[A][B] = C;
        G[B][A] = C;
    }

    warshall_floyd(N, G, INF);

    int cost, ans = INF;
    do {
        cost = 0;
        rep(i, R - 1) cost += G[r[i]][r[i + 1]];
        ans = min(ans, cost);
    } while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=200001;
ll two[M];

int n;
vvi g;

ll res=0;

int dfs(int v,int p){
	int t=n-1,s=1;
	(res+=two[n-1])%=mod;
	for(auto u:g[v]) if(u!=p){
		int tmp=dfs(u,v);
		res=(res-two[tmp]+1+mod)%mod;
		t-=tmp;
		s+=tmp;
	}
	res=(res-two[t]+mod)%mod;
	return s;
}

int main(){
	two[0]=1;
	for(int i=1;i<M;i++) two[i]=two[i-1]*2%mod;
	cin>>n;
	g=vvi(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1);
	for(int i=0;i<n;i++) (res*=mod/2+1)%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    vector<int> vec(9);
    rep(i,9){
        cin >> vec[i];
    }
    vector<int> bingo(9);
    int N;
    cin >> N;
    vector<int> num(N);
    rep(i,N){
        cin >> num[i];
    }
    rep(i,N){
        rep(j,9){
            if (num[i] == vec[j]){
                bingo[j] = 1;
            }
        }
    }
    bool bingou = false;
    if (bingo[0] == 1 && bingo[1]  == 1 && bingo[2] == 1){
        bingou = true;
    }
    else if (bingo[3] == 1 && bingo[4] == 1 &&  bingo[5] == 1){
        bingou  = true;
    }
    else if (bingo[6] == 1  && bingo[7] == 1 && bingo[8] ==1){
        bingou = true;
    }
    else if (bingo[0] == 1 && bingo[3] == 1 && bingo[6] == 1){
        bingou = true;
    }
    else if (bingo[1] == 1 && bingo[4] == 1 && bingo[7]  == 1){
        bingou = true;
    }
    else if (bingo[2] == 1 && bingo[5] == 1 && bingo[8] == 1){
        bingou = true;
    }
    else if (bingo[0] == 1 && bingo[4] == 1 && bingo[8] == 1){
        bingou = true;
    }
    else if (bingo[2] == 1 && bingo[4] == 1 && bingo[6] == 1){
        bingou = true;
    }
    if (bingou){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

bool	One(long A, long &MA, long &MI) {
	if (A>MA)
		return false;
	MA /=A;
	MA *=A;
	MA +=A-1;
	MI=(MI+A-1)/A;
	MI *=A;
	if (MI>MA)
		return false;
	else
		return true;
}

int	main() {
	long K;
	cin >>K;
	vector<long> A(K);
	for (long i=0; i<K; i++)
		cin >>A.at(i);
	reverse(A.begin(), A.end());
	long MA=2;
	long MI=2;
	for (long i=0; i<K; i++)
		if (One(A.at(i), MA, MI))
			continue;
		else {
			cout <<-1 <<endl;
			return 0;
		}
	cout <<MI <<' ' <<MA <<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    ll sum = 0;
    if (A + 2 >= B || K + 1 < A + 2) {
        sum += K + 1;
    } else {
        sum += A + ((K + 1) - A) / 2 * (B - A);
        sum += ((K + 1) - (A + 2)) % 2;
    }
    cout << sum << endl;
}

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

res = 0
if X <= 3:
    res = 1
else:
    for i in range(2,X):
        c = 2
        while 1:
            a = i**c
            if a <= X:
                if res < a:
                    res = a
                c += 1
            else:
                break
print(res)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    vec v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    ll K;
    cin >> K;
    K--;
    cout << v[K] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] x = new int[m];
        for(int i=0;i<m;i++) x[i]=sc.nextInt();
        Arrays.sort(x);
        int ans = help(n,m,x);
        System.out.println(ans);
    }
    static int help(int n, int m, int[] x){
        if(n>=m) return 0;
        int[] dif = new int[m-1];
        for(int i=0;i<m-1;i++) dif[i]=x[i+1]-x[i];
        int sum = 0;
        Arrays.sort(dif);
        for(int i=0;i<m-n;i++) sum+=dif[i];
        return sum;
    }
}


Measured memory_bytes: 50700
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    long b=sc.nextLong(),n=sc.nextLong(),max=0;
    long f=0;
    if(a<b) {
	    if(n>=b-1) {
	    	System.out.println(a-1);
	    }else {
		    System.out.println((a*n)/b-a*(n/b));
	    }
    }else {
	    if(n>=b-1) {
	    	System.out.println(a-(long)Math.ceil(a*1.0/b));
	    }else {
	    	 System.out.println((a*n)/b-a*(n/b));
	    }
    }
  }
}


Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, a, b, c, d;
    scanf("%d", &n);
    a = n / 1000;
    b = (n / 100) % 10;
    c = (n / 10) % 10;
    d = n % 10;
    if (a == b && a == c) printf("Yes\n");
    else if (b == d && c == d) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

int main(){
  int n;
  cin >> n;
  int result = 0;
  int lastorder[31];
  REP(i,31)lastorder[i]=-1;
  vector<pii> schedule(n);
  REP(i,n){
    int a,b;
    cin>>a>>b;
    --a;--b;
    schedule[i] = make_pair(b-a,a);
  }
  sort(ALL(schedule));
  REP(i,n){
    int span = schedule[i].first;
    int start = schedule[i].second;
    for(int d=start;d<=start+span;++d){
      if(lastorder[d]==-1){
        lastorder[d]=i;
        result += 100;
        break;
      }
    }
  }
  REP(i,31){
    if(lastorder[i]==-1){
      result += 50;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

const int INF=1001001001;

int main() {
  int X;
  cin>>X;
  if(X>=30){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int cnt[3000];

int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

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

    string S; cin >> S;
    int A[SZ(S)+1];
    A[SZ(S)]=0;
    per(i,SZ(S)){
        A[i]=(A[i+1]+((S[i]-'0')*power(10,SZ(S)-i,2019))%2019)%2019;
    }
    map<int,int> m;
    rep(i,SZ(S)+1){
        m[A[i]]++;
    }
    int ans=0;
    for(auto a:m){
        ans+=(a.se-1)*a.se/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5312
#include<bits/stdc++.h>
using namespace std;
int n,k;
#define MAXN 200005
int pos[MAXN];
int maxz;
int main()
{
    scanf("%d%d",&k,&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&pos[i]);
        if(i>1&&pos[i]-pos[i-1]>maxz)
        maxz=pos[i]-pos[i-1];
    }
    maxz=max(pos[1]+k-pos[n],maxz);
    printf("%d\n",k-maxz);
    return 0;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
A = [int(x)-1 for x in input().split()]

isSearched = [False]*n
isSearched[0] = True
ans = []
def f():
    global k
    now = 0
    nex = A[0]
    ans.append(now)
    for i in range(k):
        now = nex
        ans.append(now)
        isSearched[now] = True
        nex = A[nex]
        if(isSearched[nex]):
            break

    if((len(ans)-1)==k):
        print(ans[-1]+1)
        return
    for i in range(len(ans)):
        if(ans[i]==nex):
            savei = i
    k -= savei
    mod = len(ans) - savei
    print(ans[savei+k%mod]+1)

f()

Measured memory_bytes: 32152
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    int maxi = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(a-maxi <= -2){
            cout << "No" << endl;
            return;
        }
        maxi = max(a,maxi);
    }
    cout << "Yes" << endl;
}

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


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

const int MAXN = 2e5+5;

int n, da[MAXN], db[MAXN], x, y;
vector<int> a[MAXN], b[MAXN];
int ans = 0;
map<pii, int> m;
bool s[MAXN];

void compdb(int v, int f = -1) {
    if (f == -1)
        db[v] = 0;
    else
        db[v] = db[f]+1;

    for (int u : b[v])
        if (u != f)
            compdb(u, v);
}

void dfs(int v, int f = -1) {
    if (f == -1)
        da[v] = 0;
    else
        da[v] = da[f] + 1;
    if (da[v] > db[v])
        return;
    ans = max(ans, db[v]);
    if (da[v] >= db[v])
        return;

    if (s[v]) {
        cout << "-1\n";
        exit(0);
    }

    for (int u : a[v])
        if (u != f)
            dfs(u, v);
}

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

    cin >> n >> x >> y;
    x--; y--;
    for (int i = 0; i < n-1; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        a[u].push_back(v);
        a[v].push_back(u);
    }

    for (int i = 0; i < n-1; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        b[u].push_back(v);
        b[v].push_back(u);
        m[pii(u, v)] = m[pii(v, u)] = 1;
    }

    for (int i = 0; i < n; ++i) {
        for (int v : a[i]) {
            bool z = 1;
            if (b[i].size() > b[v].size())
                continue;
            if (m.count(pii(i, v)) > 0)
                z = 0;
            for (int u : b[i])
                if (m.count(pii(u, v)) > 0)
                    z = 0;
            s[i] |= z;
            s[v] |= z;
        }
    }

    compdb(y);
    dfs(x);

    cout << 2*ans << endl;
}

Measured memory_bytes: 57340
n=int(input())
sp=[list(map(str,input().split()))+[i+1] for i in range(n)]
for i in range(n):
    sp[i][1]=int(sp[i][1])

sp.sort(key=lambda x:x[1],reverse=True)

sp.sort(key=lambda x:x[0])
for i in range(n):
    print(sp[i][2])


Measured memory_bytes: 38256
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int a,b,t=0,m=0;
  cin>>a;
  for(int i=0;i<a;i++){
  	cin>>b;t+=b;m=max(m,b);
  }
  if(m<(t-m)) cout<<"Yes";
  else cout<<"No";
}

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


int main(){
	int h, w;
	cin >> h >> w;

	vector<string> row; 
	cin.ignore();
	for(int i=0;i<h;i++){
		string tmp;
		getline(cin, tmp, '\n');
		row.push_back(tmp);
	}
	int qr[] = {-1, -1, -1, 0, 0, 1, 1, 1};
	int qc[] = {-1, 0, 1, -1, 1, -1, 0, 1};
	for (int r = 0; r < h; r++){
		for(int c = 0; c < w; c++){
			if(row[r][c]=='.'){
				int sum = 0;
				for(int q=0; q<8; q++){
					if((0 <= r+qr[q]) && (r+qr[q] < h) && (0 <= c+qc[q]) && (c+qc[q] < w)){
						if(row[r+qr[q]][c+qc[q]]=='#'){ sum ++; }
					}
				}

				row[r][c] = (char) (48+sum);
			}
		}
	}
	for(int i=0;i<h;i++){
		cout << row[i] << endl;
	}
}

Measured memory_bytes: 3612
using System;

namespace ITP1_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            double r = double.Parse(strs[0]);
            double pi = Math.PI;
            Console.WriteLine("{0} {1}", pi * r * r, 2 * pi * r);
        }
    }
}

Measured memory_bytes: 9168
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x,y = readInts()
MAX = 10**18
if x % y == 0:
    print(-1)
    exit()
while x <= 10**18:
    if x%y != 0:
        print(x)
        exit()
    x += x
print(-1)

Measured memory_bytes: 10328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;



int main() {
  //
  int n;
  long long T;
  cin >> n >> T;

  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  //
  long long s = 0, sum_s = 0;
  int i = 0;
  while(i < n){
    if(a[i] - s <= T){
      sum_s += a[i] - s;
    }else if(a[i] - s > T){
      sum_s += T;
    }
    s = a[i];
    i++;
  }


  cout << sum_s + T << endl;
  return 0;
}



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

int main(){
  int N;
  cin >> N;
  int memo=0;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A,A+N);
  for(int i=1;i<N;i++){
    if(A[i]==A[i-1]){
      memo = 1;
    }
  }
  if(memo == 1) cout <<"NO";
  else cout << "YES";
}

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

int main() {
    vector<string> s(3);
    for(int i = 0; i < 3; i++)
    {
        cin >> s.at(i);
    }
    string ans;
    for (int i = 0; i < 3; i++) {
        ans += s.at(i).at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import functools
import itertools
import math
INF = float('inf')
MOD = 10**9+7

N = int(input())
As = [None] * N
ts = [[] for i in range(N)]
for i in range(N):
    As[i] = int(input())
    for j in range(As[i]):
        x, y = map(int, input().split())
        ts[i].append((x-1, y))
ans = 0
for ps in itertools.product([0, 1], repeat = N):
    # print(ps)
    qs = [None] * N
    flg = 1
    for i in range(N):
        if qs[i] != None and qs[i] != ps[i]:
            flg = 0
            break
        qs[i] = ps[i]
        if ps[i]:
            for j in range(As[i]):
                x, y = ts[i][j]
                if qs[x] == None:
                    qs[x] = y
                elif qs[x] != y:
                    flg = 0
                    break
        if flg == 0:
            break
    if flg:
        ans = max(ans, sum(ps))
print(ans)


Measured memory_bytes: 46828
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int,int>pii;
bool ope(pii a,pii b){
    if(a.first!=b.first)return a.first>b.first;
    return a.second<b.second;
}
int main(){
    int n,m;
    while(cin>>n>>m,n||m){
        vector<pii>V;
        for(int i=0;i<m;i++)V.push_back(pii(0,i));
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                int f;
                cin>>f;
                if(f)V[j].first++;
            }
        }
        sort(V.begin(),V.end(),ope);
        for(int i=0;i<m;i++){
            if(i!=0)cout<<" ";
            cout<<V[i].second+1;

        }
        cout<<endl;
    }


}

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

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    rep(i,N+1){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
    }

    ll sum = 0;

    rep(i,N){
        ll diff = A[i] - B[i];
        if(diff < 0){
            B[i] = -diff;
            diff = A[i+1]-B[i];
            if(diff < 0){
                sum += A[i] + A[i+1];
                A[i+1]  = 0;
            }else{
                sum += A[i] + B[i];
                A[i+1] -= B[i];
            }
        }else{
            sum += B[i];
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long k,ans,nasht,m;
bool ok[1000000009];
int main()
{
	cin>>k;
	nasht=7%k;
	ok[nasht]=true;
	ans++;
	if(nasht!=0)
		while(true)
		{
			ans++;
			nasht=nasht*10+7;
			nasht%=k;
			if(nasht==0)
			{
				break;	
			}	
			if(ok[nasht]==true)
			{
				cout<<"-1";
				return 0;
			}
			ok[nasht]=true;
		}
	cout<<ans;	
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define vd vector<double>
#define all(a) a.begin(),a.end()
using namespace std;

int main(){
  int n;
  string s;
  cin>>n>>s;
  bool A=true;
    if(n%2==1)A=false;
  n/=2;
  for(int i=0;i<n;i++){
    if(s.at(i)!=s.at(i+n)) A=false;
  }
  if(A) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int h, w, c;

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

int count(vector<vector<int> > p, int c)
{
	vector<vector<bool> > ischecked(h, vector<bool>(w, false));
	int result = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(ischecked[i][j] || p[i][j] != c) continue;
			ischecked[i][j] = true;
			int cnt = 1;
			queue<pair<int, int> > qu;
			qu.push(make_pair(i, j));
			while(!qu.empty()){
				int x = (qu.front()).first;
				int y = (qu.front()).second;
				qu.pop();
				for(int k = 0; k < 4; k++){
					int nx = x + dx[k];
					int ny = y + dy[k];
					if(nx < 0 || ny < 0 || nx >= h || ny >= w || ischecked[nx][ny]) continue;
					ischecked[nx][ny] = true;
					if(p[nx][ny] == c){
						cnt++;
						qu.push(make_pair(nx, ny));
					}
				}
			}
			result = max(result, cnt);
		}
	}
	return result;
}

vector<vector<int> > change(vector<vector<int> > p, int c)
{
	int beforec = p[0][0];
	vector<vector<int> > newp = p;
	newp[0][0] = c;
	queue<pair<int, int> > qu;
	qu.push(make_pair(0, 0));
	while(!qu.empty()){
		int x = (qu.front()).first;
		int y = (qu.front()).second;
		qu.pop();
		for(int k = 0; k < 4; k++){
			int nx = x + dx[k];
			int ny = y + dy[k];
			if(nx < 0 || ny < 0 || nx >= h || ny >= w || newp[nx][ny] != beforec) continue;
			newp[nx][ny] = c;
			qu.push(make_pair(nx, ny));
		}
	}
	return newp;
}

int solve(vector<vector<int> > p, int c, int cnt)
{
	if(cnt == 5) return count(p, c);
	int result = 0;
	for(int i = 1; i <= 6; i++){
		if(p[0][0] == i) continue;
		vector<vector<int> > np = change(p, i);
		result = max(result, solve(np, c, cnt + 1));
	}
	return result;
}

int main()
{
	while(1){
		cin >> h >> w >> c;
		if(h == 0 && w == 0 && c == 0) break;
		vector<vector<int> > p(h, vector<int>(w));
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> p[i][j];
			}
		}
		cout << solve(p, c, 0) << endl;
	}
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 1 ; i <(n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int n;
  cin>>n;
  bool ok=false;
  
  rep(i,10){
   rep(j,10){
    if(n==i*j){
      ok=true;
    }
   }
  }
  
  
  
  
  
  
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in(),d[n],ans=0;
    forin(d,n);
    for (int i=0;i<n-1;i++){
        for (int i2=i+1;i2<n;i2++){
            ans+=d[i]*d[i2];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

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

using CC = pair<ll, ll>;

template<typename T>
constexpr T divide_floor(T a, T b)
{
	T remainder = a % b;
	return (a - remainder) / b;
}

int main()
{
	int N, M;
	cin >> N >> M;

	vector<CC> P(N);

	rep(i, N)
	{
		ll A, B;
		cin >> A >> B;

		P[i] = pair<ll, ll>(A, B);
	}

	sort(P.begin(), P.end(), [](CC a, CC b) { return a.first < b.first; });

	ll ans = 0;
	rep(i, N)
	{
		if (P[i].second >= M)
		{
			ans += P[i].first * M;
			break;
		}
		else
		{
			ans += P[i].first * P[i].second;
			M -= P[i].second;
		}
	}

	cout << ans << endl;

	return 0;
}

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

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (x > y) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
};

int main() {
    int n, k, l; cin >> n >> k >> l;
    UnionFind road(n); UnionFind train(n);
    for (int i = 0; i < k; i++) {
        int p, q; cin >> p >> q;
        p--; q--;
        road.unite(p, q);
    }
    for (int i = 0; i < l; i++) {
        int r, s; cin >> r >> s;
        r--; s--;
        train.unite(r, s);
    }
    pair<int, int> p[n];
    for (int i = 0; i < n; i++) {
        p[i] = make_pair(road.find(i), train.find(i));
    }
    map<pair<int, int>, int> m;
    for (int i = 0; i < n; i++) m[p[i]]++;
    for (int i = 0; i < n; i++) {
        cout << m[p[i]] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 15104
#include <stdio.h>

int main(){
	int i;
	int w, h, n;
	scanf("%d %d %d", &w, &h, &n);
	int xl = 0, yl = 0, xh = w, yh = h;
	for(i = 0; i < n; i++){
		int a;
	scanf("%d %d %d", &w, &h, &a);
		switch(a){
			case 1:
			if(xl<w){
			xl = w;
			}
			break;
			case 2:
			if(xh>w){
			xh = w;
			}
			break;
			case 3:
			if(yl<h){
			yl = h;
			}
			break;
			case 4:
			if(yh>h){
			yh = h;
			}
			break;
			default:
			return 1;
		}
	}
	if(xl>xh||yl>yh){
	printf("%d", 0);
	}
	else{
		printf("%d", (xh-xl)*(yh-yl));
	}
	return 0;
}

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

int main() 
{
    int n;
    cin >> n;
    bool y=true;
    set<string> s;
    string old;
    cin >> old;
    s.insert(old);
    for (int i=1; i<n; i++)
    {
        string x;
        cin >> x;
        if (x[0] != old[old.size()-1])
            y = false;
            // cout << "abd";
        if (find(s.begin(), s.end(), x) != s.end())
            y = false;
            // cout << "abc";
        s.insert(x);
        old = x;
    }
    cout << (y?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, j, k, N, L[2000], sw = 0, sw2 = 0;

	scanf("%d", &N);

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

	for (i = 0; i < N - 2; i++) {
		for (j = i + 1; j < N - 1; j++) {
			for (k = j + 1; k < N; k++) {
				if (L[i] < L[j] + L[k]) {
					sw++;
				}
				if (L[j] < L[k] + L[i]) {
					sw++;
				}
				if (L[k] < L[i] + L[j]) {
					sw++;
				}

				if (sw == 3) {
					sw2++;
				}
				sw = 0;
			}
		}
	}

	printf("%d", sw2);
}

Measured memory_bytes: 256
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N = intinp()
A = [list(mapint_inp()) for _ in range(2)]

mx = 0
for i in range(N):
    temp = sum(A[0][:i+1])
    temp += sum(A[1][i:])
    # print(A[0][:i+1],A[1][i:])
    mx = max(mx, temp)

print(mx)

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

using namespace std;


void solve() {
    int n; cin >> n;
    string s; cin >> s;
    int sum = 0, mi = 0;
    for (char c:s) {
        sum += c=='('?1:-1;
        mi = min(mi, sum);
    }
    if (mi < 0) sum -= mi;
    mi *= -1;
    string res;
    for (int i = 0; i < mi; i++) {
        res.push_back('(');
    }
    res += s;
    for (int i = 0; i < sum; i++) {
        res.push_back(')');
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.size();
	if (t.substr(0, n) == s) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    cin>>n;
    string ans="Three";
    for(int i=0;i<n;i++){
        char a;
        cin>>a;
        if(a=='Y'){
            ans="Four";
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	double A[100], N;
	double tmp = 0;

	cin >> N;

	rep(i, N)
		cin >> A[i];

	rep(i, N)
		tmp += 1 / A[i];

	cout << 1 / tmp << endl;

	return 0;
}

Measured memory_bytes: 256