akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

ll has(ll f, ll c) {
    while (f > 0) {
        ll h = f % 10;
        if (h == c) return true;
        f /= 10;
    }
    return false;
}

bool check(ll f) {
    vector<ll> c = {3, 5, 7};

    for (ll ci : c) {
        bool b = has(f, ci);
        if (b) continue;
        else return false;
    }
    return true;
}

int main() {

    ll n;
    cin >> n;

    queue<ll> q;
    q.push(0);

    int ans = 0;
    while (!q.empty()) {
        ll f = q.front();
        q.pop();
        if (f > n) continue;
        bool b = check(f);
        if (b) {
            ans++;
        }
        for (ll c : {3, 5, 7}) {
            q.push(f * 10 + c);
        }

    }
    cout << ans << endl;

}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<string.h>

using namespace std;

int main()
{
       
       
           string s;
           cin>>s;
           if(s.at(2)==s.at(3) && s.at(4)==s.at(5))
           cout<<"Yes"<<endl;
           else
           cout<<"No"<<endl;
           

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define endl "\n"
using namespace std;

vector< long long > ans;
long long n, s, j;

long long sum( long long x, long long base )
{
	long long ret = 0;
	while( x )
	{
		ret += x%base;
		x /= base;
	}
	return ret;	
}
int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n>>s;
	long long k = 500000;
	for( long long a = 2; a <= k; a++ )
	{
		if( sum( n, a ) == s )
		{
//			cout<<"mam"<<endl;
			cout<<a<<endl;
			return 0;
		}
	}	
	for( long long d = 1; d < k; d++ )
	{
		if( d > s )
		{
			break;	
		}
		j = s - d;
		if( ( ( n - j ) % d == 0 ) && ( ( ( n - j) / d ) > j ) && ( ( ( n - j) / d ) > 1 ) &&  ( ( ( n - j) / d ) > d ) && ( ( ( n - j) / d ) > k ) )
		{
			ans.push_back( ( ( n - j ) / d ) );	
		}
	}
	if( s == 1 )
	{
		ans.push_back( n );	
	}
	if( n == s )
	{
		ans.push_back( n+1 );
	}
	sort( ans.begin(), ans.end() );
	if( ans.size() )cout<<ans[0]<<endl;
	else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn gcd(mut a: usize, mut b: usize) -> usize {
    if a<b {
        let mut tmp = a;
        a = b;
        b = tmp;
    } 
    let mut r = a % b;
    while r!=0 {
        a = b;
        b = r;
        r = a % b;
    }
    b
}

#[fastout]
fn main() {
    input!{
        mut a: usize,
        mut b: usize,
        k: usize,
    }

    let d = gcd(a,b);
    let mut cnt = 1;
    debug!(d);
    for i in (1..d+1).rev() {
        if d%i==0 {
            if cnt==k {
                println!("{}", i);
                return;
            }
            cnt += 1;
        }
    }
}


Measured memory_bytes: 2180
s = input()

a = int(s[0:2])
b = int(s[2:])
if 1<=a <= 12 :
    if 1<=b <= 12 :
        print("AMBIGUOUS")
    else :
        print("MMYY")
else:
    if 1<=b<= 12:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
string s,ss,t;

int main(){
  cin >> s;
  cin >> t;
  int slen=s.length(),tlen=t.length();
  for(int i=slen-tlen;i>=0;i--){
    bool f=true;
    ss=s;
    for(int j=0;j<tlen;j++){
      if(ss[i+j]=='?')ss[i+j]=t[j];
      else if(ss[i+j]!=t[j]){f=false;break;}
    }
    if(f){
      for(int k=0;k<slen;k++)if(ss[k]=='?')ss[k]='a';
      cout << ss << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll M;
    cin >> M;
    cout << 24 + (24 - M) << endl;
}

Measured memory_bytes: 256
n=int(input())
l=input().split()
li=[float(i) for i in l]
#dp[i][j] denotes out of first i tosses get j heads
dp=[[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
	dp[i][0]=dp[i-1][0]*(1-li[i-1])
for j in range(1,n+1):
	dp[0][j]=0
for i in range(1,n+1):
	for j in range(1,i+1):
		dp[i][j]=(dp[i-1][j-1]*li[i-1])+dp[i-1][j]*(1-li[i-1])
prob=0
for j in range(n+1):
	if(j>n/2):
		prob+=dp[n][j]
print(prob)


Measured memory_bytes: 329224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,sum=0,ans=0,sum1=0,ans1=0;
    cin>>n;
    long long int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    sum=sum/n;
    sum1=sum+1;
    for(int i=0;i<n;i++)
    {
        ans=(arr[i]-sum)*(arr[i]-sum)+ans;
        ans1=(arr[i]-sum1)*(arr[i]-sum1)+ans1;
    }
    cout<<min(ans,ans1);
}

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

int main(){
    int n, m, a, b;
    scanf("%d %d", &n, &m);
    vector<int> v1, v2;
    rep(_, m){
        scanf("%d %d", &a, &b);
        if(a == 1){
            v1.push_back(b);
        } else if(b == n) {
            v2.push_back(a);
        }
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    int i = 0, j = 0;
    bool flag = false;
    while(i < v1.size() && j < v2.size()){
        if(v1[i] == v2[j]){
            flag = true;
            break;
        }
        else if(v1[i] < v2[j]) i++;
        else j++;
    }
    printf(flag ? "POSSIBLE\n" : "IMPOSSIBLE\n");
    return 0;
}

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

int dp[3010][3010];

int main() {
    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(p.begin(), p.end(), greater<pair<int, int>>());
    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < t; j++) {
            if (j < p[i].first) {
                dp[i][j] = dp[i + 1][j];
            } else {
                dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - p[i].first] + p[i].second);
            }
        }
        dp[i][t] = max(dp[i + 1][t], dp[i + 1][t - 1] + p[i].second);
    }
    cout << dp[0][t] << endl;
    return 0;
}

Measured memory_bytes: 35584
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;



signed main(){
	int H, W, K;
	cin >> H >> W >> K;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	--x1; --y1; --x2; --y2;
	vector<string>s(H);
	cin >> s;
	vector<vector<int>>dist(H, vector<int>(W, INF));
	dist[x1][y1] = 0;
	using T = tuple<int, int, int>;
	priority_queue<T, vector<T>, greater<T>> que;
	que.push({dist[x1][y1], x1, y1});
	while(que.size()) {
		auto[cost, i, j] = que.top();
		que.pop();
		if(dist[i][j] != cost) continue;
		vector<pair<int,int>>dir = {{1,0},{0,1},{-1,0},{0,-1}};
		for(auto[x, y]: dir) {
			FOR(k, 1, K + 1) {
				int ni = x * k + i;
				int nj = y * k + j;
				if(!IN(0, ni, H) || !IN(0, nj, W)) break;
				if(s[ni][nj] == '@') break;
				if(CHMIN(dist[ni][nj], cost + 1)) {
					que.push({dist[ni][nj], ni, nj});
				} else if(dist[ni][nj] == cost + 1) continue;
				else break;
			}
		}
	}
	if(dist[x2][y2] == INF) out(-1);
	else out(dist[x2][y2]);
}

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

class Data{
private:
	int a_point, b_point;
public:
	Data(){ a_point=0; b_point=0;}
	void Add(int a, int b);
	void Show();
};

struct DataList{
	Data dataset;
	struct DataList* next;
};

void Data::Add(int a, int b){
	a_point += a;
	b_point += b;
}

void Data::Show(){
	cout << a_point << " " << b_point << endl;
}

int main(){
	int n, a, b;
	struct DataList *datalist, *p;

	datalist = new DataList;
	p = datalist;

	datalist->next = NULL;

	while(1){
		cin >> n;
		if(n == 0) break;

		p->next = new DataList;
		p->next->next = NULL;
		p = p->next;

		while(n > 0){
			cin >> a >> b;
			if(a > b) p->dataset.Add(a+b,0);
			else if(a < b) p->dataset.Add(0,a+b);
			else p->dataset.Add(a,b);
			n -= 1;
		}
	}

	p = datalist;

	while(p->next != NULL){
		p = p->next;
		p->dataset.Show();
	}

	return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;

ll gcd(ll n, ll m) {
	if (n < m) swap(n, m);
	ll r;
	while ((r = n % m)) {
		n = m; m = r;
	}
	return m;
}

ll lcm(ll n, ll m) {
	return n * m / gcd(n, m);
}

int main() {
	ll n, m; cin >> n >> m;
	vector<ll>a(n), b(n);
	for (ll i = 0; i < n; i++)cin >> a[i], a[i] = a[i] >> 1;
	b[0] = a[0];
	for (ll i = 1; i < n; i++) {
		b[i] = lcm(b[i - 1], a[i]);
	}
	ll lcm = b[n - 1];
	if (m < lcm) {
		cout << 0 << endl;
	} else {
		for (int i = 0; i < n; i++) {
			if ((lcm / a[i]) % 2 == 0) {
				cout << 0 << endl;
				return 0;
			}
		}
		cout << ((m / lcm) + 1) / 2 << endl;
	}
}

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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

int main() {

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int h, w, n;
    cin >> h >> w >> n;

    int res = inf;

    for (int x = 0; x <= h; x++) {
        for (int y = 0; y <= w; y++) {
            int area = x * w + y * h - x * y;
            if (area >= n) {
                res = min(res, x + y);
            }
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        sc.close();

        String sum = "";
        for(int i = 0; i<K; i++){
            sum += "ACL";
        }
        System.out.println(sum);
    }
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

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

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

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

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

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

void func(long long N, long long M) {}

int main() {
  // cout << fixed << setprecision(5);

  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);

  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
  return 0;
}

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

int main(){
	int N , A , T , h;
	scanf( "%d%d%d" , &N , &T , &A );
	int Min = 1000000000;
	int Temp , index = 0;

	for( int i = 1 ; i <= N ; ++i ){
		scanf( "%d" , &h );
		Temp = abs( 1000 * A - 1000 * T + 6 * h );
		
		if( Temp < Min ){ 
			index = i;
			Min = Temp;
		}
	}

	printf( "%d\n" , index );
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,d,r;
  double f;
  scanf("%d %d",&a,&b);
  d=a/b;
  r=a%b;
  f=1.0*a/b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}
  

Measured memory_bytes: 636
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<vector<int>> c(10,vector<int>(10));
    for (int i = 1; i <= n; i++) {
        int h = i; int l = i; int tmp = i;
        l = tmp % 10;
        tmp /= 10;
        while(tmp) {
            h = tmp;
            tmp /= 10;
        }
        c[h][l]++;
    }
    int ans = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            ans += c[i][j] * c[j][i];
        }
    }
    cout << ans << "\n";
}

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

int main(){
 int x,y,z,c=1;
 
  cin >> x >> y;
  if(y==1){
    cout << 0 << endl;
     return 0;
 }
    z=x-1;
  while(x<y){
      x+=z;
      c++;
  }
  cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,r=1,i,a[100010],b[100010],x,y;
  scanf("%d %d",&n,&m);
  x=(m+1)/2;
  y=m-x;
  for(i=0;i<x;i++)a[i]=r++;
  for(i=0;i<x;i++)b[x-i-1]=r++;
  for(i=0;i<y;i++)a[i+x]=r++;
  r++;
  for(i=0;i<y;i++)b[m-i-1]=r++;
  for(i=0;i<m;i++)printf("%d %d\n",a[i],b[i]);
  return 0;
}


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

using namespace std;

using ll = long long;

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

    int r, g, b;

    cin >> r >> g >> b;
    int n = 100 * r + 10 * g + b;

    if (n % 4 == 0) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


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

class Point
{
public:
	double m_X;
	double m_Y;
	Point(double x, double y)
		: m_X(x)
		, m_Y(y)
	{}
};

class LineSegment
{
private:
	Point m_Start;
	Point m_End;
public:
	LineSegment(Point start, Point end)
		: m_Start(start)
		, m_End(end)
	{}
	double Distance()
	{
		return(std::sqrt(std::pow(m_End.m_X - m_Start.m_X, 2.0) + std::pow(m_End.m_Y - m_Start.m_Y, 2.0)));
	}
	double CalcSlope()
	{
		if (m_End.m_Y == m_Start.m_Y)
		{
			return 0.0;
		}

		if (m_End.m_X == m_Start.m_X)
		{
			return 9999999999.0;
		}

		return((m_End.m_Y - m_Start.m_Y) / (m_End.m_X - m_Start.m_X));
	}
};

int main()
{
	int n = 0;
	std::cin >> n;

	while (n--)
	{
		double x1, y1, r1, x2, y2, r2;
		std::cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;

		Point p1{ x1, y1 };
		Point p2{ x2, y2 };
		LineSegment line{ p1, p2 };
		double dist_center = line.Distance();

		if ((r1 + r2) < dist_center)
		{
			std::cout << 0 << std::endl;
			continue;
		}

		if ((r1 + r2) >= dist_center)
		{
			if (dist_center + r1 < r2)
			{
				std::cout << -2 << std::endl;
				continue;
			}
			if (dist_center + r2 < r1)
			{
				std::cout << 2 << std::endl;
				continue;
			}
			std::cout << 1 << std::endl;
			continue;
		}
	}

	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  if (n == 3 || n == 7 || n == 5) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = (1e+9) + 1;
const int mod = 1000000007;
const double pi = 3.141592653589;
vector<int> a;
int n, k;
/* function */
bool check(int p) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        // d = a[i]を全てp以下にするには何等分
        //   = a[i] / pの切り上げ
        int d = (a[i] + p-1) / p;
        // d等分を達成するには木を d - 1回切る必要がある
        sum += d - 1;
    }
    if(sum <= k) return true;
    return false;
}
/* main */
int main(){
    cin >> n >> k;
    int ok = MAX, ng = 0;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    // 達成できる最大値 を２分探索
    // (ng ,..., ok]
    // (1 ~ 1e+9]
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << '\n';

}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;
  cout << "ABC" + s << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int W,H,i,j;

    while(1){
        scanf("%d %d",&H ,&W);
        if(W==0 && H==0){
                break;
        }
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split(' ');
            if (r.GroupBy(x => x).Count() == 2)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 13280
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

N,M = map(int,input().split())
a = list(map(lambda a: int(a)//2, input().split()))
g = lcm(*a)
if any([g // item % 2 == 0 for item in a]):
    print(0)
else:
    ans = M//g
    ans = max(math.ceil(ans/2),0)   
    print(ans)

Measured memory_bytes: 20940
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

N, A, B = map(int, input().split())
V = list(map(int, input().split()))
MOD = 10 ** 100 + 7

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
def comb(n, r, mod):
  if r < 0 or r > n:
    return 0
  r = min(r, n - r)
  return g1[n] * g2[r] * g2[n - r] % mod
 
for i in range(2, 50 + 1):
  g1.append((g1[-1] * i) % MOD)
  inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)
  g2.append((g2[-1] * inverse[-1]) % MOD)

V = sorted(V)[::-1]
counter = defaultdict(int)

answer_ave = sum(V[:A]) / A
print(answer_ave)

for v in V:
  if v >= V[A]:
    counter[v] += 1
  else:
    break
counter = list(counter.items())
counter = sorted(counter)[::-1]
 
if len(counter) == 1:
  answer = 0
  for i in range(A, min(B + 1, counter[0][1] + 1)):
    answer += comb(counter[0][1], i, MOD)
  print(answer)
else:
  take = 0
  for i in range(len(counter) - 1):
    take += counter[i][1]
  answer = comb(counter[-1][1], A - take, MOD)
  print(answer)

Measured memory_bytes: 3316
def main():
    N, A, B, C = map(int, input().split())
    l = []
    ll = [A, B, C]
    for _ in range(N):
        l.append(int(input()))
    r = 3000
    for i in range(4 ** N):
        t = [[],[],[]]
        for k in reversed(range(N)):
            if i // (4 ** k) == 0:
                t[0].append(l[k])
            elif i // (4 ** k) == 1:
                t[1].append(l[k])
            elif i // (4 ** k) == 2:
                t[2].append(l[k])
            i %= (4 ** k)
        if len(t[0]) == 0 or len(t[1]) == 0 or len(t[2]) == 0:
            continue
        r = min(r, sum(abs(sum(t[k]) - ll[k]) + 10 * (len(t[k]) - 1)for k in range(3)))
    print(r)
main()


Measured memory_bytes: 49244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  if(N%2==0) cout << 0.5 << endl;
  else cout << (double) (N+1)/2/N << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min,max};

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input!{
        a:usize,
        b:usize,
        c:usize
    }
    println!("{}",a*b/2);
}


Measured memory_bytes: 4352
// ~/BAU/ACM-ICPC/Teams/Rampage/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 301;
const ll MOD = 1e9+7;
const double eps = 1e-9;

int main() {
	int n;
	scanf("%d",&n);
	for(int i=0; i<=n; i++) {
		for(int j=0; j<=n; j++) {
			if(i*4+j*7==n) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
 	return 0;
} 

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

int main () {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    for (int i = 0; i < H; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H; i++) {
        cout << "#" << a.at(i) << "#" << endl;
    }
    for (int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO cin.tie(0),ios::sync_with_stdio(0);
#define ff first
#define ss second
#define eb emplace_back
#define iter(v) v.begin() ,v.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define print(v) for(auto x: v) cout<<x<<' ';
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vec;
int main()
{
    int n,k;
    cin>>n>>k;
    vec h(n);
    rep(i,n)cin>>h[i];
    sort(iter(h));
    ll sum=0;
    for(int i=0;i<n-k;i++)sum+=h[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int n,d;
    scanf("%d %d",&n,&d);
    if(n%((d*2+1))==0){printf("%d",n/(2*d+1));}
    else {printf("%d",n/(d*2+1)+1);}
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int x = 0;
		String a = "No";
		

for(int i=2;i > 0;i--)
{
x=n%10;
if (x == 9) {
	a = "Yes";
}

n=n/10;

}
		System.out.println(a);
		
	}
}

Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
import collections

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

dc = collections.Counter(d)
tc = collections.Counter(t)
s = [0 for i in range(len(tc))]
for i,index in enumerate(tc):
    s[i] = dc[index]-tc[index]
    

print('YES' if all(list(map(lambda x : x >= 0 , s))) else 'NO')



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

int count(int ban){
    int sum = 0;
    bitset<20>b(ban);
    for (int i = 0; i < 20; i++){
        if (b.test(i)) sum += 1;
    }
    return sum;
}
int main() {
    int N,ans = 0;
    cin >> N;
    int shougensuu[20];
    int banmenohito[20][20];
    int shougen[20][20];
    for (int i = 1; i <= N; i++){
        cin >> shougensuu[i];
        for (int j = 1; j <= shougensuu[i]; j++){
            cin >> banmenohito[i][j] >> shougen[i][j];
        }
    }
    for (int ban = 1; ban < (1 << N); ban++){
        bool ok = true;
        for (int i = 1; i <= 20; i++){
            if (!(ban & (1 << i-1))) continue;
            for (int j = 1; j <= shougensuu[i]; j++){
                if (((ban >> banmenohito[i][j]-1) & 1)^shougen[i][j]) ok = false;
            }
        }
        if (ok){
            ans = max(ans,count(ban));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,k,h[100000],mn,x,i;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++)	scanf("%d",&h[i]);
	sort(h,h+n);
	mn=h[k-1]-h[0];
	for(i=1;i<n-k+1;i++)	mn=min(mn,h[i+k-1]-h[i]);
	printf("%d\n",mn);
	return 0;
}

Measured memory_bytes: 512
import sys

def S(): return sys.stdin.readline().rstrip()

A,B = map(int,S().split())

def f(n):  # 0からnまでのxor
    res = 0
    while n % 4 != 3:
        res ^= n
        n -= 1
    return res

print(f(B) ^ f(A-1))

Measured memory_bytes: 61756
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MAXX 1000000000000000000

int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,i,j,x,y,k,f[105]={0};
	cin >> n >> k;

	while(k--)
	{
		cin >> x;
		while(x--)
		{
			cin >> y;
			f[y]++;
		}
	}
	
	int ans=0;
	for(i=1;i<=n;i++)
	{
		if(!f[i])
		{
			ans ++ ;
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a+b<c)
	{
		cout<<"No";
	}
	else
	{
		cout<<"Yes";
	}
}


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

#define ll long long

int main() {
	int n, m;
	int x, y;
	int i, j;
	int q;
	int count = 0;

	cin >> n >> m;
	vector<vector<int>> a(n + 1,vector<int>(0));
	vector<int>b;
	vector<int>c;
	vector<int>h(n + 1);
	for (i = 0; i <= n; i++)h[i] = 0;
	for (i = 1; i <= m; i++) {
		cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (i = 0; i < a[1].size(); i++) {
		c.push_back(a[1][i]);
		if (h[a[1][i]] == 0) {
			h[a[1][i]] = 1;
			count++;
		}
	}
	h[0] = 1;
	h[1] = 1;
	while (count<n-1){
		//cout << count << '\n';
		if (c.size() == 0 )break;
		for (q = 0; q < c.size(); q++) {
			i = c[q];
			for (j = 0; j < a[i].size(); j++) {
				//cout << j << '\n';
				if (h[a[i][j]] != 0)continue;
				b.push_back(a[i][j]);
			    h[a[i][j]] = i;
			    count++;
				//cout << a[i][j] << ':' << count << '\n';
			}
		}
		c.clear();
		for (j = 0; j < b.size(); j++)c.push_back(b[j]);
		b.clear();
	}
	if (count == n-1) {
		cout << "Yes"<<'\n';
		for (i = 2; i <= n; i++)cout << h[i] << '\n';
	}
	else {
		cout << "No";
	}
	
	return 0;

}

Measured memory_bytes: 10436
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;

int main(){
    int N;
	double W,H;
	while(~scanf("%d,%lf,%lf",&N,&W,&H)){
		if(W/(H*H)>=25) printf("%d\n",N);
	}
    return 0;
}

Measured memory_bytes: 1216
//問題URL
//

//解き方メモ
//
    
#include<iostream>
#include<queue>
#include<utility>
#include<vector>
using namespace std;

int main(){
  int h,w;
  int c[10][10];
  int a[201][201];
  int cnt[10] = {0,0,0,0,0,0,0,0,0,0};
  int cost = 0;

  cin >> h >> w;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      if(a[i][j] != -1){
	cnt[ a[i][j] ]++;
      }
    }
  }

  for (int i = 0; i < 10; i++) {
    if(i!=1 && cnt[i]>0){
      priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
      for (int j = 0; j < 10; j++) {
	//cost i -> j
	if(i != j){
	  //cout << c[i][j] << ":" << j << endl;
	  q.push(make_pair(c[i][j],j));
	}
      }
      while(true){
	pair<int,int> p = q.top();
	q.pop();
	//cout << p.first << ":" << p.second << ",";

	if(p.second == 1){
	  cost += cnt[i] * p.first;
	  break;
	} else {
	  for (int k = 0; k < 10; k++) {
	    if(k != p.second){
	      q.push(make_pair(p.first+c[p.second][k],k));
	    }
	  }
	}
      }
    }
  }

  cout << cost << endl;
  
  return 0;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    cin >> a[0];
    int MIN=a[0];
    int MAX=a[0];
    int max_p=0;
    int min_p=0;
    for(int i=1;i<n;i++){
        cin >> a[i];
        if(a[i]<MIN){
            min_p=i;
            MIN=a[i];
        }
        if(MAX<a[i]){
            max_p=i;
            MAX=a[i];
        }
    }
    if(MIN>=0){
        cout << n-1 << endl;
        for(int i=1;i<n;i++)cout << i << " " << i+1 << endl;
        return 0;
    }
    else if(MAX<=0){
        cout << n-1 << endl;
        for(int i=n;i>1;i--)cout << i << " " << i-1 << endl;
        return 0;
    }
    else if(abs(MAX)>=abs(MIN)){
        cout << 2*n-2 << endl;
        for(int i=0;i<n;i++)if(i!=max_p)cout << max_p+1 << " " << i+1 << endl;
        for(int i=1;i<n;i++)cout << i << " " << i+1 << endl;
        return 0;
    }
    else{
        cout << 2*n-2 << endl;
        for(int i=0;i<n;i++)if(i!=min_p)cout << min_p+1 << " " << i+1 << endl;
        for(int i=n;i>1;i--)cout << i << " " << i-1 << endl;
    }
}

Measured memory_bytes: 3636
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int nums[n];
    int result = 1;
    for (int i = 0; i < n; i++) {
        scanf("%d", &nums[i]);
    }

    for (int i = 0; i < n - 1; i++) {
        if (i == 0) {
            if (nums[i] - nums[i + 1] > 1) {
                result = 0;
                break;
            };
        } else {
            if (nums[i] - nums[i + 1] > 1) {
                result = 0;
                break;
            }
            else if (nums[i] - nums[i + 1] == 1) {
                nums[i]--;
                if (nums[i] < nums[i - 1]) {
                    result = 0;
                    break;
                }
            }
            else if (nums[i] <= nums[i + 1]) {
                if (nums[i] > nums[i - 1]) {
                    nums[i]--;
                }
            }
        }
    }

    printf((result) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 512
n,m = map(int,input().split())
lamp_ls = [list(map(int, input().split())) for _ in range(m)]
p_ls = list(map(int, input().split()))

num_patterns = 2 ** n
ans = 0
for pattern in range(num_patterns):
    switches = []
    for j in range(n):
        if ((pattern >> j) & 1):
            switches.append(1)
        else:
            switches.append(0)
    # そのぱたーんで、各電球がつくか判定
    count = 0
    for i, lamp in enumerate(lamp_ls):
        # それぞれの電球につながってるスイッチの状況をリストにまとめる
        s_for_lamp = []
        for s in lamp[1:]:
            if switches[s-1] == 1:
                s_for_lamp.append(1)
            else:
                s_for_lamp.append(0)
        if s_for_lamp.count(1) % 2 == p_ls[i]:
            count += 1
    if count == m:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>


using namespace std;

#define B

int main(void)
{
	int n, k, in;
	int sum = 0;
	cin >> n >> k;
	for (size_t i = 0; i < n; i++)
	{
		cin >> in;
		in = (in > k - in) ? k - in : in;
		sum += in + in;
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

  int helth, n, sum = 0, val;
  cin >> helth >> n;
  for(int i = 1;i <= n;i++){
    cin >> val;
    sum += val;
  }
  if(helth > sum){
    cout << "No";
  }else{
    cout << "Yes";
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    string s[a];
    for(i=0;i<a;i++)
        cin>>s[i];
    for(i=0;i<a;i++)
        {
            cout<<s[i]<<endl<<s[i]<<endl;
        }

    return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    int h,m,h1,m1,k;
    cin >> h >> m >> h1 >> m1 >> k;
    int ans = abs((h*60+m)-(h1*60+m1)) - k;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int n,d[1000];
main()
{
	cin>>n;
	bool flag=0;
	for(int i=0;i<n;i++)
	{
		cin>>d[i];
		flag|=!d[i];
	}
	if(!flag)
	{
		cout<<0<<endl;
		return 0;
	}
	for(int f=1;;f++)
	{
		bool ok=0;
		for(int i=0;i<n;i++)
		{
			int now=0;
			for(int j=0;now<f&&i+j<n;j++)
			{
				now=now*10+d[i+j];
			}
			ok|=f==now;
		}
		if(!ok)
		{
			cout<<f<<endl;
			return 0;
		}
	}
}



Measured memory_bytes: 3120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n[4],i;
	for(i=0; i<4; ++i){
		cin >> n[i];
	}
	sort(n,n+4);
	cout << ((n[0]*1000+n[1]*100+n[2]*10+n[3]==1479)?"YES":"NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
const int N = 1e5 + 5;
char s[N];
inline void rror() {
	puts("No");
	exit(0);
}
int main() {
	scanf("%s",s+1);	
	n = strlen(s+1);
	for(int i = 1;i <= n/2;++i)
		if(s[i] != s[1+n-i]) rror();
	m = n/2;
	for(int i = 1;i <= m/2;++i)
		if(s[i] != s[m+1-i] || s[m+1+i] != s[n+1-i]) rror();
	puts("Yes");
	return 0;
}



Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 普通に計算して通ってしまったが、恐らく想定の解き方ではない

func main() {
	N := nextInt()
	Ln := make([]int, N)
	for i := range Ln {
		Ln[i] = nextInt()
	}
	sort.Ints(Ln)
	var ans int
	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			cnt := sort.Search(len(Ln), func(k int) bool {
				a, b, c := Ln[i], Ln[j], Ln[k]
				// c >= a+b となる場所を求めたい。
				// これでsort.SearchIntの挙動と同じになる
				// a<= b <= cのとき、b<c+a ⇔ b-c < aは a >0 のため必ず成り立つので、
				// c < a+bだけ考えればいい
				return c-b >= a
			})
			ans += cnt - (j + 1)
		}
	}
	fmt.Println(ans)
}

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

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1920
import collections as col
 
s = list(input())
t = list(input())
 
c1 = col.Counter(s)
c2 = col.Counter(t)
 
cv1 = sorted(c1.values())
cv2 = sorted(c2.values())
 
if cv1 == cv2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6960
def solve():
    n = int(input())
    p = list(map(int, input().split()))
    irregular = []
    for i in range(n):
        if p[i] != i + 1:
            irregular.append([i + 1, p[i]])
    if len(irregular) == 0 or (len(irregular) == 2 and irregular[0][1] == irregular[1][0] and irregular[0][1] == irregular[1][0]):
        return "YES"
    else:
        return "NO"


if __name__ == "__main__":
    print(solve())


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;
const int MAX_N = 1e6;

typedef pair<int, int>P;
typedef pair<int, P>mp;
struct edge { P to; int cost; };
int N;
map<P,vector<edge>>G;	//頂点(駅,路線)から出るedge
map<P,int>d;	//頂点までのコスト
void dijkstra(P s) {
	priority_queue<mp, vector<mp>, greater<mp>>que;
	d[s] = 0;
	que.push(mp(0, s));

	while (!que.empty()) {
		mp p = que.top();
		que.pop();
		P v = p.second;
		if (d[v] < p.first)continue;
		for (auto e:G[v]){
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(mp(d[e.to], e.to));
			}
		}
	}
}
int main() {
	cin.sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int p, q, c;
		cin >> p >> q >> c;
		p--; q--;
		edge e1,e2;
		e1.to = P(p, c); e1.cost = 0;
		e2.to = P(q, c); e2.cost = 0;
		G[P(q, c)].push_back(e1);
		G[P(p, c)].push_back(e2);
		e1.to = P(p, 0); e1.cost = 0;
		e2.to = P(q, 0); e2.cost = 0;
		G[P(q, c)].push_back(e1);
		G[P(p, c)].push_back(e2);
		e1.to = P(p, c); e1.cost = 1;
		e2.to = P(q, c); e2.cost = 1;
		G[P(q, 0)].push_back(e1);
		G[P(p, 0)].push_back(e2);

		d[P(p, c)] = INF;d[P(q, c)] = INF;
		d[P(p, 0)] = INF; d[P(q, 0)] = INF;
	}
	dijkstra(P(0, 0));
	int ans = d[P(N - 1, 0)];
	cout << (ans == INF||ans==0 ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 92152
n, s = map(int, input().split())
a = list(map(int, input().split()))
modval = 998244353

def update(newval, length_elems):
  # sequences made up of only the new value
  if newval<= s:
    new_state[newval][0] = length_elems
    new_state[newval][1] = length_elems
  # appending to existing sequences
  for j in range(1, s+1):
    new_state[j][0] = (new_state[j][0] + old_state[j][0])%modval
    new_state[j][1] = (new_state[j][1] + old_state[j][0] + old_state[j][1])%modval
    if newval+j <= s:
      new_state[newval+j][0] = (new_state[newval+j][0] + old_state[j][0])%modval
      new_state[newval+j][1] = (new_state[newval+j][1] + old_state[j][0])%modval

# [[combos without R, combos with R] that add to a given target]
old_state = [[0, 0] for _ in range(s+1)]
for i, newval in enumerate(a, 1):
  # reset the new state to zeros
  new_state = [[0, 0] for _ in range(s+1)]
  # create new state from old state
  update(newval, i)
  # old state now point to new state
  old_state = new_state
print(new_state[s][1]%modval)

Measured memory_bytes: 128016
n=gets.to_i
que = []
(1..9).each {|i| que.push(i)}
x=0
n.times do
    x = que.shift
    que.push(10*x+x%10-1) if x%10!=0
    que.push(10*x+x%10)
    que.push(10*x+x%10+1) if x%10!=9
end

p x

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

using namespace std;

#define int long long
#define PB push_back
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;

constexpr int INF = 1LL<<60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 1005;
constexpr int MAX_M = 100005;
constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

int n, m, h, k, s[MAX_N], goal[MAX_N], a[MAX_M], in[MAX_M][2];
vector<pii> tempa;


int Goal(int st) {
    int pos = st;
    for (int i = 0; i < m; ++i) {
        if (a[i] == pos) {
            in[i][0] = st;
            pos = a[i] + 1;
        } else if (a[i] + 1 == pos) {
            in[i][1] = st;
            pos = a[i];
        }
    }

    return pos;
}

bool Solve() {
    cin >> n >> m >> h >> k;
    if (!n) return false;

    tempa.clear();

    for (int i = 1; i <= n; ++i) cin >> s[i];

    for (int i = 0; i < m; ++i) {
        int p, d;
        cin >> p >> d;
        tempa.PB({d, p});
    }
    sort(ALL(tempa));

    for (int i = 0; i < m; ++i) a[i] = tempa[i].second;

    for (int i = 1; i <= n; ++i) {
        goal[i] = Goal(i);
    }

    int sum = 0;
    for (int i = 1; i <= k; ++i) {
        sum += s[goal[i]];
    }

    int ans = sum;
    for (int i = 0; i < m; ++i) {
        int temp = 0;
        for (int j = 0; j < 2; ++j) {
            if (k < in[i][j]) continue;
            temp += s[goal[in[i][(j + 1) % 2]]] - s[goal[in[i][j]]];
        }
        ans = min(ans, sum + temp);
    }

    cout << ans << endl;

    return true;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    while (Solve());
}

Measured memory_bytes: 6800