akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    string s;
    cin>>s;
    int l=s.size(),k;
    cin>>k;
    set<string> sub;
    for(int p=1;p<k+1;p++){
        for(int i=0;i+p-1<l;i++){
            sub.insert(s.substr(i,p));
        }
    }
    vector<string> v(All(sub));
    sort(All(v));
    cout<<v[k-1]<<endl;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



#define N 500
int main(){fastio
    ll n,ma,mb;cin>>n>>ma>>mb;
    ll dp[N][N];rep(i,0,N-1)rep(j,0,N-1)dp[i][j]=inf;
    dp[0][0]=0;
    while(n--){
        ll a,b,c;cin>>a>>b>>c;
        for(ll i=N-1;i>=0;i--){
            for(ll j=N-1;j>=0;j--){
                if(i-a>=0&&j-b>=0)Min(dp[i][j],dp[i-a][j-b]+c);
            }
        }
    }
    ll ans=inf;
    rep(i,1,N){
        if(ma*i<=N-1&&mb*i<=N-1)Min(ans,dp[ma*i][mb*i]);
    }
    if(ans>=inf/2)cout<<-1<<endl;
    else cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 2176
N=int(input())
a=list(map(int, input().split()))
k=list(map(str,a))
j=' '.join(k)
print(j)
for i in range(1,N):
    v=a[i]
    j=i-1
    while a[j]>v and j>=0:
        a[j+1]=a[j]
        j -=1
    a[j+1]=v
    b=list(map(str, a))
    c=' '.join(b)
    print(c)


Measured memory_bytes: 5596
using System;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var S = Console.ReadLine();

            if (S == "AAA" || S == "BBB")
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main()
{
    int board[3][3],n,store[15];
    for(int i = 0;i<3;i++)
        for(int j = 0;j<3;j++)
            cin>>board[i][j];
    cin>>n;
    for(int i = 0;i<n;i++)
    {
        cin>>store[i];
        for(int a = 0;a<3;a++)
        for(int b = 0;b<3;b++)
            if(board[a][b]==store[i])
                board[a][b]=0;
    }
    if(board[0][0]==0&&board[1][1]==0&&board[2][2]==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(board[0][2]==0&&board[1][1]==0&&board[2][0]==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(board[0][0]==0&&board[0][1]==0&&board[0][2]==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(board[1][0]==0&&board[1][1]==0&&board[1][2]==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(board[2][0]==0&&board[2][1]==0&&board[2][2]==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(board[0][0]==0&&board[1][0]==0&&board[2][0]==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(board[0][1]==0&&board[1][1]==0&&board[2][1]==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(board[0][2]==0&&board[1][2]==0&&board[2][2]==0)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}

template<typename T>
void ppp(T n){cout << n << endl;}

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


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<string> vstr;



vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    
    rep(i, 30){
        rep(j, 20){
            if(n == 4*i+7*j){
                Yes();
                return 0;
            }
        }
    }

    No();
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ld w,h,x,y;
    cin>>w>>h>>x>>y;
    if(w==2*x&&h==2*y){
        cout<<fixed<<setprecision(10)<<(w*h)/2<<" "<<1;
    }
    else cout<<fixed<<setprecision(10)<<(w*h)/2<<" "<<0;
}

Measured memory_bytes: 3712
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<complex>
#include<deque>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=1e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a[50]={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
};
int main(){
	int n;
	cin>>n;
	cout<<a[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 1000000000

double pi=3.14159265358979;

void func()
{
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    double an=abs(30*h-6*m+m/2.0)*pi/180.0;
    double ans=sqrt(a*a + b*b - 2*a*b*cos(an));
    //cout<<an<<"\n";
    printf("%0.12lf\n", ans);
}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif

    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 4208
/*
AuThOr GaRyMr
技巧:
1.区别对待大数据&小数据！
2.Dp难推时算贡献！
3.long long (尤其乘法)！
4.long long INF 要大
5.Dp on trees: 换根法，每次清空当前的节点和换到的子节点
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,d[100];
int main(){
cin>>n;
rb(i,1,n) cin>>d[i];
int res=0;
rb(i,1,n)
rb(j,i+1,n){
	if(i!=j){
		res+=d[i]*d[j];
	}
}
cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto s = readStr;
  auto t = readStr;

  if(s == t[0 .. $-1]){
    writeln("Yes");
  } else {
    writeln("No");
  }
}


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

struct edge {
    int to; double dist;
    edge(int _to, double _dist) {
        to = _to; dist = _dist;
    }
};

struct circle {
    double x, y, r;
    circle(double _x, double _y, double _r) {
        x = _x; y = _y; r = _r;
    };
};

double dist(circle &a, circle &b) {
    double ret = sqrt(pow(a.x-b.x, 2) + pow(a.y-b.y, 2)) - (a.r+b.r);
    return max(0.0, ret);
}

int main() {
    vector<circle> v;
    for (int i = 0; i < 2; i++) {
        double x, y; cin >> x >> y;
        v.emplace_back(x, y, 0);
    }
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        double x, y, r; cin >> x >> y >> r;
        v.emplace_back(x, y, r);
    }
    n += 2;
    vector<edge> e[n];
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            double d = dist(v[i], v[j]);
            e[i].emplace_back(j, d);
            e[j].emplace_back(i, d);
        }
    }
    vector<double> a(n, 1e32); a[0] = 0;
    priority_queue<pair<double, int>> pq;
    pq.emplace(0, 0);
    while (!pq.empty()) {
        pair<double, int> s = pq.top(); pq.pop();
        if (-s.first > a[s.second]) continue;
        int cur = s.second;
        for (int i = 0; i < e[cur].size(); i++) {
            int to = e[cur][i].to;
            if (a[to] > a[cur] + e[cur][i].dist) {
                a[to] = a[cur] + e[cur][i].dist;
                pq.emplace(-a[to], to);
            }
        }
    }
    printf("%.12f\n", a[1]);
    return 0;
}

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

#define ll      		long long int
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; 
#define endl            '\n'
#define pb push_back
#define vll vector<ll> 
#define f(i,x,y)  for(i=x;i<y;i++)
#define INF     LLONG_MAX
#define fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define p2(n,x)    cout << fixed << setprecision(x) <<n<<endl; 
#define pll    pair<ll,ll> 
#define ff first
#define ss second
#define blt(x)   __builtin_popcount(x)

void solve()
{
	ll i,j,k,n;
	string s;
	cin>>s;
	ll ans=0;
	f(i,0,3)
	{
		if(s[i]=='R')
		{
			ll c=0;
			j=i;
			while(j<3 && s[j]=='R')
			{
				c++;
				j++;
			}
			ans=max(ans,c);
			i=j-1;
		}
	}
	cout<<ans;

}

int main()
{
	
	fast
	ll t = 1;

	

	while(t--)
	solve();
	
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>

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

using namespace std;


int main(){
	
	int n,m;
	int fre[10000];
	int fre2[10000];
		
	while(1){
		scanf("%d%d",&n,&m);
		
		if(n==0){
			break;
		}
		rep(i,m){
			scanf("%d%d",&fre[i],&fre2[i]);
		}
		
		int yobu[501]={0};
		int yobu2[501]={0};
		
		yobu[1]=1;
		
		rep(p,2){
			rep(i,n+1){
				if(yobu[i]==1){
					yobu2[i]=1;
					rep(j,m){
						if(fre[j]==i){
							yobu2[fre2[j]]=1;
						}
						if(fre2[j]==i){
							yobu2[fre[j]]=1;
						}
					}
				}
			}
			
			rep(i,n+1){
				yobu[i]=yobu2[i];
			}
		}
		
		int ans=0;
		rep(i,n-1){
			ans+=yobu[i+2];
		}
		
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b, n int
	fmt.Scan(&n)
	fmt.Scan(&a)
	fmt.Scan(&b)

	nums := make([]int, 0)

	for i := 0; i <= n; i++ {
		strNum := strconv.Itoa(i)
		num := 0
		for j := 0; j < len(strNum); j++ {
			strDigit := strNum[j : j+1]
			digit, _ := strconv.Atoi(strDigit)
			num = num + digit
		}

		if num >= a && num <= b {
			nums = append(nums, i)
		}
	}
	res := 0
	for _, i := range nums {
		res = res + i
	}
	fmt.Println(res)
}


Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
PROGRAM-ID. A-BEGINNER.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP     PIC X(501).
01 IN-DATA.
   03 DT-X1 PIC X(10).
01 IN-LEN.
   03 DT-L1 PIC 9(2).
01 IN-N     PIC 9(6).
01 IN-TABLE.
   03 IN-STR-T  OCCURS 200000 DEPENDING ON IN-N.
     05 I-STR PIC X(10).
01 IN-MAX-T.
   03 I-MAX PIC X(10) OCCURS 200000.
01 W-STR    PIC X(10).
01 I        PIC 9(6).
01 J        PIC 9(6).
01 K        PIC 9(6).
01 L        PIC 9(6).
01 MAX      PIC 9(6).
01 DUP      PIC 9(6).
01 CNT-MAX  PIC 9(6).
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO DT-X1 COUNT IN DT-L1.
  MOVE DT-X1(1:DT-L1) TO IN-N.
 
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > IN-N
    ACCEPT I-STR(I)
  END-PERFORM.
 
  SORT IN-STR-T ON ASCENDING KEY I-STR.
 
  MOVE 0 TO MAX.
  MOVE 1 TO I.
  PERFORM UNTIL I > IN-N
    PERFORM VARYING J FROM I BY 1 
              UNTIL (J > IN-N) OR (I-STR(J) NOT = I-STR(I))
    END-PERFORM
    COMPUTE DUP = J - I 
    IF (DUP > MAX)
      MOVE DUP TO MAX
      MOVE 1   TO CNT-MAX
      MOVE I-STR(I) TO I-MAX(CNT-MAX)
    ELSE 
      IF (DUP = MAX)
        ADD  1 TO CNT-MAX
        MOVE I-STR(I) TO I-MAX(CNT-MAX)
      END-IF
    END-IF
    MOVE J TO I
  END-PERFORM.
 
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > CNT-MAX
    DISPLAY I-MAX(I)
  END-PERFORM.
 
MAIN-EXIT.
  STOP RUN.


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

int main() {
    int N, D, A;
    cin >> N >> D >> A;
    pair<int, int> p[N];
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(p, p + N);
    
    ll total = 0, ans = 0;
    queue<pair<ll, ll>> que;
    rep(i, N) {
        ll x = p[i].first;
        ll h = p[i].second;
        while (que.size() && x > que.front().first) {
            total -= que.front().second;
            que.pop();
        }
        h -= total;
        if (h > 0) {
            ll num = (h + A - 1) / A;
            ans += num;
            ll damage = A * num;
            total += damage;
            que.emplace(x + D * 2, damage);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	ll a ,b,c,d;
	
	cin>>a>>b>>c>>d;
	vl ans;
	ans.pb(a*c);
	ans.pb(a*d);
	ans.pb(b*c);
	ans.pb(b*d);
	sort(all(ans));
	cout<<ans[3]<<endl;
  





}



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

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

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

using namespace std;

const ll MOD = 1e9 + 7;
const int A = 0, G = 1, C = 2, T = 3;

int main() {

    int n; cin >> n;
    ll dp[n+1][4][4][4];

    rep(i, n+1) rep(j, 4) rep(k, 4) rep(l, 4) dp[i][j][k][l] = 0;

    rep(j, 4) rep(k, 4) rep(l, 4) {
        if(j == A && k == G && l == C) continue;
        if(j == A && k == C && l == G) continue;
        if(j == G && k == A && l == C) continue;
        dp[3][j][k][l] = 1;
    }

    for(int i=4; i <= n; i++) {
        rep(j, 4) rep(k, 4) rep(l, 4) rep(m, 4){
            if(j == A && k == G && l == C) continue;
            if(j == A && k == C && l == G) continue;
            if(j == G && k == A && l == C) continue;
            if(m == A && k == G && l == C) continue;
            if(m == A && j == G && l == C) continue;
            dp[i][j][k][l] += dp[i-1][m][j][k];
            dp[i][j][k][l] %= MOD;
        }
    }
    ll ans = 0;
    rep(j, 4) rep(k, 4) rep(l, 4) {
        ans += dp[n][j][k][l];
        ans %= MOD;
    }
    cout << ans << endl;
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define RREP(i, a, n) for(int i = (int)(n); i >= a; i--)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    set<char> ans;
    multiset<char> key;
    rep(i,s.size())
    {
        ans.insert(s[i]);
        key.insert(s[i]);
    }

    if( ans.size() != 2 ) cout << "No" << endl;
    else
    {
        for(set<char>::iterator itr = ans.begin(); itr != ans.end(); itr++)
        {
            if( key.count(*itr) != 2 )
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long int A,B,ans,n,i;
    scanf("%ld",&n);
    ans=n;
    for(A=1;A*A<=n;A++)
    {
        if(n%A==0)
        {
            B=n/A;
            i=0;
            while(B>0)
            {
                B=B/10;
                i++;
            }
            if(i<ans)
            {
                ans=i;
            }
        }
    }
    printf("%d\n",ans);
    return  0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

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(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};

int main(){
    int n,m;cin >> n >> m;
    vector<P> edge(m);
    rep(i,m){
        int a,b;cin >> a >> b;
        --a;--b;
        edge[i] = make_pair(a,b);
    }
    vector<ll> ans(m,0);
    UnionFind tree(100005);
    for(int i = m-1;i >= 0;i--){
        P p = edge[i];
        if(tree.same(p.first,p.second)) ans[i] = 0;
        else{
            ans[i] = ll(tree.size(p.first))*ll(tree.size(p.second));
            tree.unite(p.second,p.first);
        }
    }
    rep(i,m-1) ans[i+1] += ans[i];
    rep(i,m) cout << ans[i] <<endl;; 
    
}

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

typedef long long ll ; 
const int mod = 1e9+7 ; 
int can[30][30]  , n;
ll dp[30][(1<<21)+10];
ll calc(int idx , int col) {
	if (idx == n ){
		if (col == (1<<n)-1 )
			return 1 ; 
		return 0 ; 
	}
	ll &ret = dp[idx][col] ; 
	if (ret != -1)
		return ret ; 
	
	ret = 0 ; 
	for (int i =0 ; i<n ; ++i) {
		if (can[idx][i] && !((1<<i)&col))
			ret += calc(idx+1 , col|(1<<i))%mod ; 
	}
	return ret%mod ; 
}
int main() {
	scanf("%d" , &n) ; 
	memset(dp , -1 , sizeof dp) ; 
	for (int i =0 ; i<n ; ++i) {
		for (int j =0 ; j<n ; ++j){
			scanf("%d" , &can[i][j]) ; 
		}
	}
	
	ll ans = calc(0 , 0)%mod ;
	printf("%lld\n" , ans);
	return 0;
}

Measured memory_bytes: 491776
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
    int A,B,X;
    cin >> A >> B >>X;
    if((A<=X)&&(A+B>=X)){
      cout <<"YES";
    }else{
      cout <<"NO";
    }
    return 0;
}


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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
  if(n==1)cout<<"Hello World"<<endl;
  else{
    int a,b;cin>>a>>b;
    cout<<a+b<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 256
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInts() (int,int,int) {
  var x,y,z int
  var s []string = strings.Split(NextLine()," ")
  x,_ = strconv.Atoi(s[0])
  y,_ = strconv.Atoi(s[1])
  z,_ = strconv.Atoi(s[2])
  return x,y,z
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

const infty int = 2147483647
var n,m,r int
var route []int
var d [][]int
var used []bool
var res int

func main() {
  n,m,r = NextInts()
  route = NextIntArray()
  used = make([]bool,r)
  for i:=0;i<r;i++ { route[i]-- }
  d = make([][]int,n)
  for i:=0;i<n;i++ {
    d[i] = make([]int,n)
    for j:=0;j<n;j++ {
      d[i][j] = infty
    }
  }
  for i:=0;i<m;i++ {
    var a,b,c int = NextInts()
    a,b = a-1,b-1
    if d[a][b] > c {
      d[a][b] = c
      d[b][a] = c
    }
  }
  for k:=0;k<n;k++ {
    for i:=0;i<n;i++ {
      for j:=0;j<n;j++ {
        if d[i][j] > d[i][k]+d[k][j] {
          d[i][j] = d[i][k]+d[k][j]
        }
      }
    }
  }
  res = infty
  dfs(0,-1,0)
  fmt.Println(res)
}
func dfs(c,las,dist int) {
  if c == r {
    if res > dist { res = dist }
    return
  }
  for i:=0;i<r;i++ {
    if used[i] { continue }
    used[i] = true
    if las == -1 {
      dfs(c+1,i,0)
    } else {
      dfs(c+1,i,dist+d[route[las]][route[i]])
    }
    used[i] = false
  }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t--)
#define input1(n) ll n;cin>>n;
#define input2(a,b) ll a,b;cin>>a>>b;
#define mod 1000000007

int main()  
{  
    string a,b;
    cin>>a>>b;
    ll n=a.length(),m=b.length();
    ll dp[n+1][m+1];
    for(ll i=0;i<n+1;i++)
    {
        for(ll j=0;j<m+1;j++)
    {
        if(i==0||j==0)
        dp[i][j]=0;
    }
    }
    for(ll i=1;i<n+1;i++)
    {
        for(ll j=1;j<m+1;j++)
        {
            if(a[i-1]==b[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    // for(ll i=0;i<n+1;i++)
    // {
    //     for(ll j=0;j<m+1;j++)
    //     cout<<dp[i][j]<<" ";
    //     cout<<"\n";
    // }
    string ans="\0";
    char lcs[dp[n][m]];
    ll i=n,j=m;
    while(i>0&&j>0)
    {
           
            if(a[i-1]==b[j-1])
            {
                ans+=a[i-1];
            i--;j--;
            }
        else if(dp[i][j-1]>dp[i-1][j])
         j--;
        else
        i--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 73980
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	int n,c;
    cin >> n >> c;
    vector<int> p(c);
    int sum = 0;
    rep(i,0,c){
        cin >> p[i];
        sum += p[i];
    }
    int ans = sum/(n+1);
    if(sum%(n+1) == 0){
        cout << ans << endl;
    }else{
        cout << ans + 1 << endl;
    }
}


Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()
#define pb push_back
string a[10]={
  "1111110",
  "0110000",
  "1101101",
  "1111001",
  "0110011",
  "1011011",
  "1011111",
  "1110010",
  "1111111",
  "1111011"
};

main(){
  rep(i,10)reverse(ALL(a[i]));
  int n;
  while(cin>>n && n != -1){
    int last=0;
    string op="0000000";
    rep(tc,n){
      int now;
      string tmp;
      cin>>now;
      rep(i,op.size()){
	if(op[i] != a[now][i]){
	  tmp+="1";
	}else tmp+="0";
      }
      cout << tmp << endl;
      op=a[now];
    }

  }
  return false;
}

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

int main() {
    // int name;
    // name = 10;
    // cout << name << endl;

    // name = 5;

    // cout << name << endl;

    // int a;

    // cin >> a;
    // cout << a * 10 << endl;

    // string text;
    // double d;
    // cin >> text;
    // cin >> d;
    // cout << text << ", " << d << endl;

    // int a, b, c;
    // cin >> a >> b >> c;
    // cout << a * b * c << endl;

    // int a, b;
    // cin >> a >> b;
    // cout << a + b << endl;

    // int m;
    // cin >> m;
    // cout << 24 + 24 - m << endl;

    int r,g;
    double t;
    cin >> r >> g;
    t = g - r;
    t = t * 2;
    cout << r + t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<unsigned long long,unsigned long long> P;

struct RH {
  vector<unsigned long long> p,hash;
  void init(const string s) {
    unsigned long long m=1000000007,q=1,n=s.size();
    p.resize(n+1);hash.resize(n+1);p[0]=q;hash[0]=0;
    rep(i,n){p[i+1]=p[i]*m;hash[i+1]=s[i]+hash[i]*m;}
  }
  unsigned long long h(int i)const{return hash[i];}
  unsigned long long h(int i,int j)const{return h(j)-h(i)*p[j-i];}
};

map<P,ll> m[20];
void Main() {
  ll n;
  R n;
  string s;
  R s;
  ll ans=0;
  rep(t,1<<n) {
    string r="",r2="";
    rep(i,n) {
      if(t&(1<<i)) r+=s[i];
      else r2+=s[i];
    }
    reverse(all(r2));
    RH e,e2;
    e.init(r),e2.init(r2);
    m[__builtin_popcount(t)][P(e.h(r.size()),e2.h(r2.size()))]++;
  }
  reverse(all(s));
  rep(t,1<<n) {
    string r="",r2="";
    rep(i,n) {
      if(t&(1<<i)) r+=s[i];
      else r2+=s[i];
    }
    reverse(all(r2));
    RH e,e2;
    e.init(r),e2.init(r2);
    ans+=m[__builtin_popcount(t)][P(e.h(r.size()),e2.h(r2.size()))];
  }
  pr(ans);
}

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


Measured memory_bytes: 33152
#include <cstdio>
#include <vector>
#include <iostream>

using namespace std;

int main() {
	vector <int> orig;
	vector <char> origc;
	vector <int> list;
	vector <char> chars;
	int size = 5;
	int num = 0;
	char letter = ' ';

	scanf("%d%*c", &size);
	for (int i = 0; i < size; i++) {
		scanf("%c%d%*c", &letter, &num);
		orig.push_back(num);
		origc.push_back(letter);
	}
	list.assign(orig.begin(), orig.end());
	chars.assign(origc.begin(), origc.end());
	size = size-1;
	//bubble
	for (int i = 0; i <= size; i++) {
		for (int j = size; j > i; j--) {
			if (orig[j] < orig[j-1]) {
				num = orig[j];
				orig[j] = orig[j-1];
				orig[j-1] = num;

				letter = origc[j];
				origc[j] = origc[j-1];
				origc[j-1] = letter;
			}
		}
	}
	//selection
	for (int i = 0; i <= size; i++) {
		num = i;
		for (int j = i; j <= size; j++) {
			if (list[j] < list[num]) {
				num = j;
			}
		}
		if (i != num) {
			list[i] = list[i] + list[num];
			list[num] = list[i] - list[num];
			list[i] = list[i] - list[num];

			chars[i] = chars[i] + chars[num];
			chars[num] = chars[i] - chars[num];
			chars[i] = chars[i] - chars[num];
		}
	}
	for (int i = 0; i < size; i++) {
		printf("%c%d ", origc[i], orig[i]);
	}
	printf("%c%d\n", origc.back(), orig.back());
	printf("Stable\n");
	for (int i = 0; i < size; i++) {
		printf("%c%d ", chars[i], list[i]);
	}
	printf("%c%d\n", chars.back(), list.back());
	if (origc == chars) {
		printf("Stable\n");
	} else {
		printf("Not stable\n");
	}
}



Measured memory_bytes: 3268
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

string str,s;
int cnt,i,m,j,k;
int main()
{
	cin>>str;
	cin>>s;
	cnt=-1;
	int n=str.length();
	int m=s.length();
	for(i=0;i<n;i++)
	{
		if(str[i]=='?'||str[i]==s[0])
		{
			int flag=0;
			k=i;
			for(j=0;j<m;j++)
			{
				if(str[k]=='?'||str[k]==s[j])
				{
					k++;
				}
				else
				{
					flag=1;
					break;
				}
			}
			if(flag!=1&&k<=n)
			{
				cnt=i;
			}
		}
	}
	if(cnt==-1)
	{
		cout<<"UNRESTORABLE"<<endl;
	}
	else
	{
			k=0;
			for(i=cnt;k<m;i++)
			{
				str[i]=s[k];
				//cout<<str[i]<<" "<<i<<endl;
				k++;
			}
		for(i=0;i<n;i++)
		{
			if(str[i]=='?')
				cout<<'a';
			else
				cout<<str[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	llint i,n,D,H;cin>>n>>H>>D;
	vector<llint>dp(H+D+1);
	llint K=0,a=1;
	for(i=1;i<=n;i++){a*=i;a%=mod;K+=a;K%=mod;}
	dp[1]=a;dp[1+D]=-a;
	for(i=1;i<H;i++){
		dp[i+1]+=dp[i]*(K+1);dp[i+1]%=mod;
		dp[i+1+D]-=dp[i]*K;dp[i+1+D]%=mod;
	}
	
	cout<<(mod+dp[H])%mod<<endl;
	
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const unsigned long long h = 1e9+7;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    map<string,int> a;
    rep(i,n){
        cin >> s;
        a[s]++;
    }
    int c = 0;
    for (auto i = a.begin();i != a.end();i++){
        c++;
    }
    PRINT(c);
}    


Measured memory_bytes: 19216
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

//istream& operator>>(istream& is, const mint& a){return is >> a.x;}
//ostream& operator<<(ostream& os, const mint& a){return os << a.x;}

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

// nCa
mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

mint dp[1000005][2][2];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	dp[0][0][0] = 1;
	rep(i,n){
		dp[i+1][0][0] = dp[i][0][0] * 8;
		dp[i+1][0][1] = dp[i][0][0] + dp[i][0][1] * 9;
		dp[i+1][1][0] = dp[i][0][0] + dp[i][1][0] * 9;
		dp[i+1][1][1] = dp[i][0][1] + dp[i][1][0] + dp[i][1][1] * 10;
	}
	cout << dp[n][1][1].x << endl;
	return 0;
}

Measured memory_bytes: 34900
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define MOD 1000000000+7
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	long long t[n],a[n],m[n];
	rep(i,n)cin>>t[i];
	rep(i,n)cin>>a[i];
	long long num=1;
	long long tm=0,am=0;
	rep(i,n){
		tm=max(tm,t[i]);
		am=max(am,a[i]);
		if(i==0 || i==n-1)continue;
		if(t[i]==t[i-1] && a[i]==a[i+1]){
			num=num*((t[i]>a[i])?a[i]:t[i]);
			num%=MOD;
		}else if(t[i]!=t[i-1] && a[i]==a[i+1]){
			if(t[i]<=a[i])num*=1;
			else num*=0;
		}else if(t[i]==t[i-1] && a[i]!=a[i+1]){
			if(a[i]<=t[i])num*=1;
			else num*=0;
		}else{
			if(t[i]==a[i])num*=1;
			else num*=0;
		}
	}
	cout<<((tm==am)?num:0)<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n;
  cin >> n;
  set <ll> s;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    if (a == 0) {
      s.insert(b);
      cout << s.size() << endl;
    } else {
      cout << s.count(b) << endl;
    }
  }
}


Measured memory_bytes: 12372
# ABC129C - Typical Stairs
import sys
input = sys.stdin.readline

def main():
    N, M = tuple(map(int, input().split()))
    A = set(map(int, [input() for _ in range(M)]))
    MOD = 10 ** 9 + 7
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in A else 0
    for i in range(2, N + 1):
        if i in A:
            continue
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 18336
from sys import stdin
input = stdin.readline

x, y, a, b, c = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
a = p[:x] + q[:y] + r
a.sort(reverse=True)
print(sum(a[:x+y]))

Measured memory_bytes: 100076
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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





int main() {
    ll n, k;
    cin >> n >> k;
    
    vector<pair<ll, ll>> v(n);
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    
    sort(v.begin(), v.end());
    
    ll s = 0;
    REP(i, n){
        s += v[i].second;
        if(s >= k){
            cout << v[i].first << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    int A,B;
    int ans=0;
    int a0,a1,a3,a4;

    scanf("%d %d",&A,&B);

    for (int i=A;i<=B;i++){
	a0=i%10;
	a1=(i%100)/10;
	a3=(i%10000)/1000;
	a4=i/10000;
	if ((a0 == a4) && (a1 == a3)) ans++;
    }

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

    return 0;
}

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

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

using namespace std;
using lint=long long;

const lint INF=1LL<<61;

int main(){
	int n,m,L; cin>>n>>m>>L;
	lint d1[300][300];
	rep(u,n) rep(v,n) d1[u][v]=(u==v?0:INF);
	rep(i,m){
		int u,v,c; cin>>u>>v>>c; u--; v--;
		d1[u][v]=d1[v][u]=c;
	}

	rep(w,n) rep(u,n) rep(v,n) d1[u][v]=min(d1[u][v],d1[u][w]+d1[w][v]);

	lint d2[300][300];
	rep(u,n) rep(v,n) {
		d2[u][v]=(u==v?0:d1[u][v]<=L?1:INF);
	}
	rep(w,n) rep(u,n) rep(v,n) d2[u][v]=min(d2[u][v],d2[u][w]+d2[w][v]);

	int q; cin>>q;
	rep(_,q){
		int s,t; cin>>s>>t; s--; t--;
		cout<<(d2[s][t]<INF?d2[s][t]-1:-1)<<endl;
	}
	return 0;
}


Measured memory_bytes: 1920
n = int(input())
s = list(input())

ans = 0
for i in range(1000):
    temp = [str(i // 100), str((i // 10) % 10), str(i % 10)]
    count = 0
    for j in range(n):
        if temp[count] == s[j]:
            count += 1
        if count == 3:
            ans += 1
            break
print(ans)

Measured memory_bytes: 42860
#include<iostream>
#include<stack>
#include<cstdio>
using namespace std;
int main(){
  stack<int> train;
  int a;
   while(scanf("%d",&a)!=EOF){
    if(a==0){
    cout<<train.top()<<endl;
    train.pop();
    }
    else {
      train.push(a);
    }
  }
}

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


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

out = None
for a0, a1 in (("W", "S"), ("S", "W"), ("S","S"), ("W", "W")):
    ans = [None]*n
    ans[0] = a0
    ans[-1] = a1
    for i in range(n-1):
        v = int(s[i]=="o") + int(ans[i-1]=="S") + int(ans[i]=="S")
        if v%2==1:
            ans[i+1] = "S"
        else:
            ans[i+1] = "W"
    v = int(s[n-1]=="o") + int(ans[n-2]=="S") + int(ans[0]=="S") + int(ans[n-1]=="S")
    if ans[-1]==a1 and v%2==0:
        out = ans
if out is not None:
    write("".join(out))
else:
    print(-1)

Measured memory_bytes: 53104
class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [0 for _ in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            elif self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

from collections import defaultdict

N, K, L = map(int, input().split())

uf1 = UnionFind(N)
for i in range(K):
    p, q = map(int, input().split())
    uf1.union(p-1, q-1)

uf2 = UnionFind(N)
for i in range(L):
    r, s = map(int, input().split())
    uf2.union(r-1, s-1)

c = defaultdict(int)
for i in range(N):
    c[(uf1.find(i), uf2.find(i))] += 1

for i in range(N):
    print(c[(uf1.find(i), uf2.find(i))], end = ' ', )

Measured memory_bytes: 126796
from sys import stdin
import bisect
from itertools import groupby
 
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
 
if li[0] != 0 or 0 in li[1:]:
    print(0)
    exit()

li.sort()
lin = []

for key, value in groupby(li):
    lin.append((key,len(list(value))))
 
point = 1
for i in range(1,len(lin)):
    if lin[i-1][0]+1 != lin[i][0]:
        print(0)
        exit()
    elif lin[i][1] == 0:
        print(0)
        exit()
    point *= (lin[i-1][1]**lin[i][1])
 
print(point%998244353)

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int X; cin >> X;
  if (X == 7 || X == 5 || X == 3) {
    cout << "YES\n";
  }else {
    cout << "NO\n";
  }

  return 0;
}


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




  

    int dp[100005];

    void solve()
    {
      for(int i=0;i<100005;i++)
      {
        dp[i]=i;
      }
    }


    int sol(int index)
    {
      if(index<=-1) return -1;
      if(dp[index]==index)return index;
      else
        return dp[index]=sol(dp[index]);
    }


      int main()
      {


           ios_base::sync_with_stdio(false);
           cin.tie(NULL);
          /*#ifndef ONLINE_JUDGE
              freopen("input.txt","r",stdin);
              freopen("output.txt","w",stdout);
          #endif*/
      solve();
      int n,m;
      cin>>n>>m;
      vector<pair<int,int>>nish;

      for(int i=0;i<n;i++)
      {
        int first,second;
        cin>>first>>second;
        nish.push_back({second,first});
      }
      sort(nish.begin(),nish.end());



      long long int ans=0;
    for(int i=n-1;i>=0;i--)
    {
      int start=sol(m-nish[i].second);
     // cout<<start<<" "<<nish[i].first<<" "<<nish[i].second<<endl;
      if(start!=-1)
      {
        ans+=nish[i].first;
        dp[start]=start-1;
      }

    }

    cout<<ans<<endl;
    return 0;


    }

Measured memory_bytes: 4664
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int main() {
  int N = getZ(), K = getZ(), ans = 0;
  for(int i = 0; i < N; ++i) {
    if(getZ() >= K) ++ans;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 256