akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

#define LL long long
#define Lowbit(X) (X&(-X))
#define Lson (X<<1)
#define Rson (X<<1|1)
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(int i=A;i<=B;i++)
#define BOR(i,A,B) for(int i=A;i>=B;i--)
#define FOR_SIDE(i,A) for(int i=Head[A];i;i=Next[i])
#define INF 0x7fffffff
using namespace std;
const int MAXN=2e3+10;

int DP[MAXN][MAXN];
bool Vis[MAXN][MAXN];
int Row,Line,Stax,Stay,Endx,Endy,New,A,B;
char Map[MAXN][MAXN];
int Dx[5]={0,0,-1,0,1},Dy[5]={0,1,0,-1,0};
int Dx5[21]={0,-1,-1,1,1,0,-1,-2,-2,-2,-2,-2,-1,0,1,2,2,2,2,2,1};
int Dy5[21]={0,1,-1,-1,1,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1,0,1,2,2};
inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}
struct Node { int E,F; };
queue<Node>Mine;

inline void DFS(int X,int Y,int Time) {
    Vis[X][Y]=true;
    DP[X][Y]=Time;
    FOR(i,1,4) {
        int Nx=X+Dx[i],Ny=Y+Dy[i];
        if(Nx>Row || Nx<1 || Ny>Line || Ny<1 || Vis[Nx][Ny]) continue;
        DFS(Nx,Ny,Time);
    }
    FOR(i,1,20) {
        int Nx=X+Dx5[i],Ny=Y+Dy5[i];
        if(Nx<=Row && Nx>=1 && Ny<=Line && Ny>=1 && !Vis[Nx][Ny]) {
            Mine.push(Node{ Nx,Ny }); 
			if(DP[Nx][Ny]) DP[Nx][Ny]=min(Time+1,DP[Nx][Ny]);
			else DP[Nx][Ny]=Time+1;
        }
    }
}

int main() {
    //File();
    scanf("%d %d",&Row,&Line);
    scanf("%d %d",&Stax,&Stay);
    scanf("%d %d",&Endx,&Endy);
    FOR(i,1,Row) { 
		scanf("%s",Map[i]+1); 
		FOR(j,1,Line) if(Map[i][j]=='#') Vis[i][j]=true;
	}
	Mine.push(Node{ Stax,Stay });
	while(!Mine.empty()) {
		int W=Mine.front().E,S=Mine.front().F;
		if(Vis[W][S]) { Mine.pop(); continue; }
        DFS(W,S,DP[W][S]);
		Mine.pop();
    }
    if(!Vis[Endx][Endy]) { printf("-1\n"); }
    else { printf("%d\n",DP[Endx][Endy]); }
    //fclose(stdin); fclose(stdout);
    system("pause");
    return 0;
}

Measured memory_bytes: 15652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int p[n+1]={};
  int ma=0;
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>p[i];
    sum+=p[i];
    ma=max(ma,p[i]);
  }
  cout<<sum-ma/2<<endl;

  return 0;
}


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

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

	string A, B, C;
	cin >> A >> B >> C;
	if (A[A.length() - 1] == B[0]) {
		if (B[B.length() - 1] == C[0]) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstring>
#include<list>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MAX_V 1000

using namespace std;

typedef complex<double> P;

const int dim = 2;
double dot(P x,P y){return real(conj(x)*y);}

struct min_ball{
  P center,v[dim+1],c[dim+1];
  double radius2,z[dim+1],r[dim+1];
  list<P> ps;
  list<P>::iterator sup;
  int m;

  void compile(vector<P> v){
    m = 0;
    center = P(0,0);
    radius2 = -1;
    ps.clear();
    for(int i=0;i<v.size();i++)ps.push_back(v[i]);
    make_ball(ps.end());
  }

  void push(const P& p){
    if(!m){
      c[0] = p; r[0] = 0;
    }else{
      double e = dot(p-c[m-1],p-c[m-1]) - r[m-1];
      P d = v[m] = p - c[0];
      for (int i = 1; i < m; ++i)v[m] -= v[i] * dot(v[i], d) / z[i];
      z[m] = dot(v[m], v[m]);
      c[m] = c[m-1] + e*v[m]*(1.0/z[m]/2.0);
      r[m] = r[m-1] + e*e/z[m]/4.0;
    }
    center  = c[m];
    radius2 = r[m]; ++m;
  }
  void make_ball(list<P>::iterator i){
    sup = ps.begin();
    if(m == dim + 1)return;
    for(list<P>::iterator k = ps.begin(); k != i; ){
      list<P>::iterator j = k++;
      if(dot(*j-center,*j-center) > radius2){
        push(*j);
	make_ball(j);
	--m;
	if(sup == j)++sup;
	ps.splice (ps.begin(), ps, j);
      }
    }
  }
};

int n,m,p;
int r[110];
double d[110];
int use1[110],use2[110];
vector<P> ver;

int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> r[i];
    r[i] = r[i]*r[i];
  }

  for(int i=0;i<m;i++){
    cin >> p;
    ver.resize(p);
    for(int j=0;j<p;j++)cin >> ver[j].real() >> ver[j].imag();
    min_ball ball;
    ball.compile(ver);
    d[i] = ball.radius2;
  }

  for(int i=0;i<n;i++)use1[i] = false;

  for(int i=0;i<m;i++){
    int j;
    for(j=0;j<n;j++){
      if(!use1[j] && d[i] < r[j]+EPS){
	use1[j] = true;
	bool f = true;
	for(int k=0;k<n;k++)use2[k] = use1[k];
	for(int k=i+1;k<m;k++){
	  int id = -1;
	  for(int l=0;l<n;l++){
	    if(!use2[l] && d[k] < r[l]+EPS)
	      if( id<0 || r[l] < r[id] )id = l;
	  }
	  if(id<0){
	    f = false;
	    break;
	  }else use2[id] = true;
	}
	if(f){
	  cout << j+1 << endl;
	  break;
	}else use1[j] = false;
      }
    }
    if(j==n){
      cout << "NG\n";
      return 0;
    }
  }
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include<cmath>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> vec(k);
    for(int i=0;i<k;i++){
        int x;
        cin >> x;
        vec[i]=x;
    }
    int reg=n;
    while(1){
        bool hantei=1;
        int keta=1;
        int k_reg = reg;
        while(1){
            int a=pow(10,keta);
            for(int j=0;j<vec.size();j++){
                
            //    cout<<"ここまではいってるやろ"<<" "<<k_reg % a<<endl;
                if(k_reg % a==vec[j]*pow(10,keta-1)){
          //          cout<<"ジャッジ"<<endl;
                    hantei=0;
                    break;
                }
            }
            k_reg -= k_reg % a;
        //    cout<<"引いた？"<<endl;
            keta++;
            if(hantei==0){
               // cout<<"reg1つ終わり"<<endl;
                break;
            }
            if(pow(10,keta-1)>reg)break;
        }
        if(hantei){
            cout<<reg<<endl;
            break;
        }else{
            reg++;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	char c; std::cin >> c;
	std::cout << static_cast<char>(c + 1) << std::endl;
}

Measured memory_bytes: 888
from collections import Counter
from itertools import count

M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = 1
  try:
    for i in count(1):
      x = c.get(i)
      r = r * pow(p, x, M) % M
      p = x; n -= p
  except:
    pass
print((r, 0)[n > 1])

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

int main() {

    char a, b;
    cin >> a >> b;

    string s = "", t = "";
    for (int i = 0; i < (int)(a-'0'); i++) {
        s += b;
    }
    for (int i = 0; i < (int)(b-'0'); i++) {
        t += a;
    }

    if (s < t) cout << s << endl;
    else cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
int n,ans;
char s[1010][1010],a[1010][1010];
int pd(int x){
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)a[i][j]=s[i][(j+x)%n];
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)if (a[i][j]!=a[j][i])return 0;
	return 1;
} 
signed main(){
	n=read();for (int i=0;i<n;i++)scanf("%s",s[i]);
	for (int l=0;l<n;l++)if (pd(l))ans+=n;
	writeln(ans);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli h(n), e(110, 0);
  rep(i, 0, n)
  {
    cin >> h[i];
  }
  rep(i, 0, n - 1)
  {
    if (h[i] > h[i + 1])
      ans += h[i] - h[i + 1];
  }
  ans += h[n - 1];
  cout << ans << endl;
}

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

public class Main {
    static long INF = 5_000_000_000_000_000L;
    static long westNear(long[] facility, long point){
        int N = facility.length;
        if(point < facility[0]) return -INF;
        if(facility[N-1] <= point) return facility[N-1];
        int w=0, e=N-1;
        while(w+1<e){
            int m = (w+e)/2;
            if(facility[m] == point) return point;
            if(facility[m] < point) w=m;
            if(point < facility[m]) e=m;
        }
        return facility[w];
    }
    static long eastNear(long[] facility, long point){
        int N = facility.length;
        if(facility[N-1] < point) return INF;
        if(point <= facility[0]) return facility[0];
        int w=0, e=N-1;
        while(w+1<e){
            int m = (w+e)/2;
            if(facility[m] == point) return point;
            if(facility[m] < point) w=m;
            if(point < facility[m]) e=m;
        }
        return facility[e];
    }
    static long near(long[] facility, long point){
        long west = westNear(facility, point);
        long east = eastNear(facility, point);
        if(point-west > east-point) return east;
        else return west;
    }


    static long solve(long[] shrines, long[] temples, long x){
        long ans = INF;
        // west shrine -> temple
        long wShrine = westNear(shrines, x);
        //System.err.printf("%11d ", x-wShrine + Math.abs(near(temples, wShrine)-wShrine));
        ans = Math.min(ans, x-wShrine + Math.abs(near(temples, wShrine)-wShrine));

        // east shrine -> temple
        long eShrine = eastNear(shrines, x);
        //System.err.printf("%11d ", eShrine-x + Math.abs(near(temples, eShrine)-eShrine));
        ans = Math.min(ans, eShrine-x + Math.abs(near(temples, eShrine)-eShrine));

        // west temple -> shrine
        long wTemple = westNear(temples, x);
        //System.err.printf("%11d ", x-wTemple + Math.abs(near(shrines, wTemple)-wTemple));
        ans = Math.min(ans, x-wTemple + Math.abs(near(shrines, wTemple)-wTemple));

        // east shrine -> temple
        long eTemple = eastNear(temples, x);
        //System.err.printf("%11d\n", eTemple-x + Math.abs(near(shrines, eTemple)-eTemple));
        ans = Math.min(ans, eTemple-x + Math.abs(near(shrines, eTemple)-eTemple));

        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();
        long[] shrines = new long[A];
        long[] temples = new long[B];
        for(int a=0; a<A; a++) shrines[a] = sc.nextLong();
        for(int b=0; b<B; b++) temples[b] = sc.nextLong();
        for(int q=0; q<Q; q++){
            long x = sc.nextLong();
            System.out.println(solve(shrines, temples, x));
        }
    }
}

Measured memory_bytes: 95548
#include <stdio.h>
#include <algorithm>

int main() {
	char s[6] = { 0 };
	scanf("%s", s);

	bool res = false;
	for (int i = 0; i < 4; i++)
		res |= s[i] == 'A' && s[i + 1] == 'C';

	printf("%s\n", res ? "Yes" : "No");
}

Measured memory_bytes: 128
#include<iostream>
#define ll long long
using namespace std;
int main()
{
    int n,w;
    cin>>n>>w;
    pair<int,int> arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i].first>>arr[i].second;
    }
    int max_val=n*1000;
    ll dp[n+1][max_val+1];
    for(int i=0;i<=max_val;i++)
    {
        dp[1][i]=1000000001;
    }
    dp[1][0]=0;
    dp[1][arr[1].second]=arr[1].first;
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=max_val;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(arr[i].second>j)
                continue;
            dp[i][j]=min(arr[i].first+dp[i-1][j-arr[i].second],dp[i][j]);
        }
    }
    int ans=0;
    for(int x=0;x<=max_val;x++)
    {
        if(dp[n][x]<=w)
        {
            ans=x;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 81764
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n; cin >> n;
  vector<vector<int>> G(n);
  queue<int> q;
  int cnt[n] = {};
  for (int i = 0; i < n - 1; ++i) {
    int a, b; cin >> a >> b;
    --a; --b;
    G[a].push_back(b); G[b].push_back(a);
    ++cnt[a]; ++cnt[b];
  }
  vector<int> c(n);

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

  sort(all(c));

  int ans[n];

  for (int i = 0; i < n; ++i) {
    if (cnt[i] == 1) {
      q.push(i);
    }
  }

  for (int i = 0; i < n; ++i) {
    int cur = q.front(); q.pop();
    ans[cur] = c[i];
    for (int j = 0; j < (int) G[cur].size(); ++j) {
      --cnt[G[cur][j]];
      if (cnt[G[cur][j]] == 1) q.push(G[cur][j]);
    }
  }
  
  cout << accumulate(all(c), int()) - *max_element(all(c)) << '\n';
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }

  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>

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

using namespace std;

int main(){
	int n,k; scanf("%d%d",&n,&k);

	if(n/2<k){ puts("-1"); return 0; }

	int u[10000],v[10000];
	rep(i,n/2){
		u[i]=i+1;
		u[i+n/2]=i+2;
		v[i]=v[i+n/2]=(n-i)%n;
	}

	rep(i,k){
		rep(j,n-1){
			printf("%d %d\n",u[j]+1,v[j]+1);
			u[j]=(u[j]+1)%n;
			v[j]=(v[j]+1)%n;
		}
		putchar('\n');
	}

	return 0;
}

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

const ll MOD = 1e9+7;

int main() {

    int N, K;
    cin >> N >> K;

    vector<double> A(N);

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

    ll ans = 0;
    ll L = 0;
    ll R = 1e9;
    ll med, tmp;

    while (R-L > 1) {
        med = (L + R) / 2;
        tmp = 0;
        rep(i, N) {
            tmp += (ceil(1.0 * A[i] / med) - 1);
        }
        if (tmp > K) L = med;
        else R = med;
    }

    cout << R << endl;

    return 0;
}


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


	cin >>n;
	vector<int>a(n);
	rep(i,n){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	ans="YES";
	rep(i,n-1){
		if (a[i]==a[i+1]){
			ans="NO";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

// N次元バーガーを文字列で表す
// fn burger(level: u32) -> String {
//     if level == 0 {
//         return String::from("P");
//     }

//     let mut ans = String::from("B");
//     ans += &burger(level - 1);
//     ans += "P";
//     ans += &burger(level - 1);
//     ans += "B";

//     return ans;
// }

fn burger_size(level: usize) -> i64 {
    return 4 * 2_i64.pow(level as u32) - 3;
}


fn paty_size(level: usize) -> i64 {
    return 2 * 2_i64.pow(level as u32) - 1;
}

fn solve(N: usize, X: i64) -> i64 {
    // 食べてない
    if X == 0 {
        return 0;
    }

    // ベースケース
    if N == 0 && X == 1 {
        return 1;
    }

    if N == 0 && X > 1 {
        panic!("Someting wrong, N = 0, X = {}", X);
    }

    // N > 0 なので最下はパン
    if X == 1 {
        return 0;
    }

    let minus_1_all = burger_size(N - 1);
    let minus_1_p = paty_size(N - 1);

    // (level - 1) の途中で止まる
    if 1 < X && X < minus_1_all + 1 {
        // 最下のBだけ食べた
        return solve(N - 1, X - 1);
    }

    // ぴったりlevel-1
    if X == minus_1_all + 1 {
        return minus_1_p;
    }

    // level-1 + P
    if X == minus_1_all + 1 + 1 {
        return minus_1_p + 1;
    }

    // 2個目の(level - 1)の途中で止まる
    if X < 2 * minus_1_all + 2 {
        // 最下のBと1個目の(level-1)とPを食べた
        return minus_1_p + 1 + solve(N - 1, X - minus_1_all - 2);
    }

    return minus_1_p * 2 + 1;
}

fn main() {
    input! {
        N: usize,
        X: i64,
    }

    let ans = solve(N, X);
    println!("{}", ans);
}


Measured memory_bytes: 2140
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 1e5+9;

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n;
    if(n>=30)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x[3],y[2];
	for(int i=0;i<3;i++)
		cin>>x[i];
	for(int i=0;i<2;i++)
		cin>>y[i];
	cout<<min(min(x[0],x[1]),x[2])+min(y[0],y[1])-50<<endl;
return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> dp(100001, 1e8);
    dp[0] = 0;
    for ( int i = 1; i <= n; ++i ) {
        dp[i] = dp[i-1] + 1;
        for ( int j = 6; j <= i; j *= 6 ) {
            dp[i] = min(dp[i], dp[i-j] + 1);
        }
        for ( int j = 9; j <= i; j *= 9 ) {
            dp[i] = min(dp[i], dp[i-j] + 1 );
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
class Student:
	def __init__(self, index, qtd):
		self.index = index
		self.qtd = qtd
	def __lt__(self, other):
		return self.qtd < other.qtd


n = int(input())
register = [Student(index+1, qtd) for index, qtd in enumerate(list(map(int, input().split())))]
register.sort()

[print(x.index, end=' ') for x in register]
print()

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n, a[maxn];

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

  int ans = 1e9;
  cin>>n;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }

  for (int x=-100; x<=100; x++) {
    int cur = 0;
    for (int i=0; i<n; i++) {
      cur += abs(a[i]-x)*abs(a[i]-x);
    }
    ans = min(ans, cur);
  }
  
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
drinks = N.times.map { gets.split.map(&:to_i) }
drinks.sort_by! { |a, b| a }

ans = 0
cnt = 0

drinks.each do |a, b|
  if cnt + b < M
    ans += a * b
    cnt += b
  else
    remain = M - cnt
    ans += a * remain
    break
  end
end

puts ans


Measured memory_bytes: 12664
import sys
n = int(input())
l = list(map(int,input().split()))
maxs=l[0]
for i in range(1,n):
    if l[i]<maxs-1:
        print("No")
        sys.exit()
    elif l[i]>=maxs:
        maxs=l[i]
    
print("Yes")

Measured memory_bytes: 20828
#include<bits/stdc++.h>
using namespace std;
int shibaku(int p , int money){
  //2種類(1000円共通)
  for(int j=0;money-5000*j>=0;j++){
 	 if(p==j+(money-5000*j)/1000){
     	cout<<0<<" "<<j<<" "<<p-j<<endl;
       	return 0;
 	 }else if(p==j+(money-10000*j)/1000 && money-10000*j>=0){
       cout<<j<<" "<<0<<" "<<p-j<<endl;
       	return 0;
     }
  }
  return 1;
}
void check(int money,int p){
  int a=p-2,b=1,c=1;
  bool bl=true;
  while(bl){
    int y=10000*a+5000*b+1000*c;
    if(y==money){
    	cout<<a<<" "<<b<<" "<<c<<endl;
    	bl=false;
    } else if(a==1){
       cout<<-1<<" "<<-1<<" "<<-1<<endl;;
       bl=false;
    }else if(b==1){
      a--;
      c=1;
      b=p-a-1;
    }else if(b!=1){
      b--;
      c++;
    }
   
  }
}
  
	

int main(){
  int n,y;//n：お札の枚数y:申告金額
  cin>>n>>y;
  if(y%1000!=0){//yは1000の倍数
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }else if(n>y/1000){
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
  }else if(y%1000==0 &&n==y/1000){
      cout<<0<<" "<<0<<" "<<n<<endl;
  }else if(y%5000==0&&n==y/5000){
      cout<<0<<" "<<n<<" "<<0<<endl;
  }else if(y%10000==0&&n==y/10000){
      cout<<n<<" "<<0<<" "<<0<<endl;
  }else{
    int num=shibaku(n,y);

    if(num!=0){
      check(y,n);
    }
  }
}
    
    
    
  

Measured memory_bytes: 3620
import sys
s=input()
if(len(s)==1):
  print(s)
  sys.exit()
su=0
for i in range(2**(len(s)-1)):
  b=bin(i)[2:].zfill(len(s)-1)
  calcs=s[0]
  for j in range(len(b)):
    if(b[j]=="0"):calcs+=s[j+1]
    else:calcs+="+"+s[j+1]
  su+=eval(calcs)
print(su)

Measured memory_bytes: 3064
class PriorityQueue
  attr_accessor(:node)
  
  def initialize(src = [])
    @node = []
    src.each do |e|
      push(e)
    end
  end

  def push(x)
    @node << x
    bottom_up
  end

  def pop
    res = @node.first
    top_down
    return res
  end
  
  def bottom_up
    i = @node.size - 1
    v = @node[i]
    while i > 0
      parent = (i - 1) >> 1
      break if @node[parent] <= v
      
      @node[parent], @node[i] = @node[i], @node[parent]
      i = parent
    end
    
    @node[i] = v
  end

  def top_down
    i = 0
    tmp = @node.pop
    while (i << 1) + 1 < @node.size
      lhs = (i << 1) + 1
      rhs = (i << 1) + 2
      m = lhs
      
      if rhs < @node.size && @node[lhs] > @node[rhs]
        m = rhs
      end
      
      break if @node[m] >= tmp
      @node[i] = @node[m]
      i = m
    end
    
    @node[i] = tmp unless @node.empty?
  end
end

n = $stdin.readline.to_i
v = $stdin.readline.chomp.split.map(&:to_f)
pq = PriorityQueue.new(v)

while pq.node.size > 1
  x = pq.pop
  y = pq.pop
  pq.push((x + y) / 2.0)
end
puts "%.6f" % [pq.pop]

Measured memory_bytes: 14184
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
// mod. m での a の逆元 a^{-1} を計算する
const long long MOD = 1000000007;
ll souwa (ll first,ll second){
  ll a = (first*(first+1));
  ll b = (second*(second+1));
  return (b/2 - a/2);
} 
void solve(long long N, long long K){
  ll ans = 0;
  for (int i = K; i <= N+1; i++) {
    ans = ans%MOD + (souwa(N-i,N) - souwa(0,i-1) + 1)%MOD;
  }
  cout << ans << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
	long long K;
	scanf("%lld",&K);
    solve(N, K);
}


Measured memory_bytes: 3712
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9+7;

console.log(main());
function main(){
  var n = o.a();
  var a = o.a();
  var b = o.a();
  var p = o.l();
  var set = new Set();
  set.add(0);
  var dp = Array(n+1).fill(9e99);
  dp[0] = 0;
  for(var i = 0; i < n; i++){
    for(var x of set){
      if(x < p[i]){
        if(dp[x] < dp[p[i]])dp[p[i]] = dp[x];
        dp[x] += a;
      }else{
        dp[x] += b;
      }
    }
    set.add(p[i]);
  }
  return Math.min(...dp);
}

Measured memory_bytes: 14896
#include<cstdio>
#include<string>
#include<cctype>
#include<iostream>
#include<algorithm>

using namespace std;

typedef string::const_iterator State;

int expr(State &begin);
int term(State &begin);
int number(State &begin);
int factor(State &begin);

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=(*begin)-'0';
		begin++;
	}
	return ret;
}

int term(State &begin){
	int ret=factor(begin);
	for(;;){
		if(*begin=='*'){
			begin++;
			ret*=factor(begin);
		}else if(*begin=='/'){
			begin++;
			ret/=factor(begin);
		}else break;
	}
	return ret;
}

int expr(State &begin){
	int ret=term(begin);
	for(;;){
		if(*begin=='+'){
			begin++;
			ret+=term(begin);
		}else if(*begin=='-'){
			begin++;
			ret-=term(begin);
		}else{
			break;
		}
	}
	return ret;
}

int factor(State &begin){
	if(*begin=='('){
		begin++;
		int ret=expr(begin);
		begin++;
		return ret;
	}else{
		return number(begin);
	}
}

int main(){
	int N;
	cin>>N;
	cin.ignore();
	for(int i=0;i<N;i++){
		string str;
		getline(cin,str);
		State begin=str.begin();
		int ans=expr(begin);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, k;
    cin >> n >> k;

    if(2*k > n+1) {
        cout << -1 << endl;
        return 0;
    }

    REP(i, (n+1)/2) cout << k+i << " " << n+k+n/2+i << " " << 2*n+k+2*i << endl;
    FOR(i, (n+1)/2, n) cout << k+i << " " << n+k-(n+1)/2+i << " " << 2*n+k+2*(i-(n+1)/2)+1 << endl;

    return 0;
}

Measured memory_bytes: 2304
n, y = map(int,input().split())

for i in range(n+1):
  for j in range(n+1-i):
    k = n-i-j
    if y == i*10000+j*5000+k*1000:
        print("{} {} {}".format(i,j,k))
        exit(0)

print("-1 -1 -1")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
int children[L], comp[L], parent[L];
int component(int x)
{
	if(parent[x] == x)return x;
	return parent[x] = component(parent[x]);
}
void merge(int a, int b)
{
	int pa = component(a);
	int pb = component(b);
	if(children[pa] > children[pb])
	{
		children[pb] += children[pa];
		parent[pa] = pb;
	}
	else
	{
		children[pa] += children[pb];
		parent[pb] = pa;
	}
	return;
}
std::map<int, ll> co;
void fff()
{
	int n, m, a, b;
	cin >> n >> m;	
	FOR(i,0,n+1)parent[i] = i, children[i] = 1;
	while(m--)
	{
		cin >> a >> b;
		merge(a, b);
	}
	FOR(i,1,n+1)co[component(i)]++;
	ll ans = 1;
	trace(co, x)ans = max(ans, x.S);
	cout << ans << ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 17640
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    string a;
    int c = 0;
    cin >> a;
    if (a[0] != 'A') {
        cout << "WA";
        return 0;
    }
    for (int i = 2; i < a.length()-1; ++i) {
        if('a'<= a[i] && a[i] <= 'z') continue;
        if(a[i] == 'C') c++;
    }
    if(a[1] < 'a'  || 'z' < a[1]) {c = 114514;}
    if(a[a.length()-1] < 'a'  || 'z' < a[a.length()-1]) {c = 114514;}
    if (c == 1) cout << "AC";
    else cout << "WA";
    return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

count = 0
while a > 0 and c > 0:
    if count == 0:
        c = c-b
        count = 1
    else:
        a = a-d
        count = 0
if a > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9120
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define ll long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;


//変数
int T;
vector<vector<ll>> rows;






//サブ関数
//入力
void input()
{
	cin >> T;
	rows.resize(T, vector<ll>(4));
	REP(i, T) REP(j, 4)cin >> rows[i][j];
}

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

ll binary_searchm(ll start, ll step, ll border)
{
	ll l = 0;
	ll r = pow(10, 18) / step;

	while (l + 3 < r) {
		ll mid = (l + r) / 2;
		if (start + step * mid > border) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	
	l = max(l - 5, 0ll);
	while (true) {
		if (start + step * l <= border &&
			start + step * (l + 1) > border)return l + 1;
		l++;
	}
}

//計算
bool calc(vector<ll> row)
{
	ll A = row[0];
	ll B = row[1];
	ll C = row[2];
	ll D = row[3];

	//exception
	ll alpha = A - C;
	alpha = (alpha / B) + (alpha%B != 0 ? 1 : 0);
	alpha = max(alpha, 1ll);
	ll Z = A - B * alpha;
	if (Z < 0)return false;
	if (A < B)return false;
	if (B > D)return false;
	if (B <= C)return true;
	ll G = GCD(B, D);
	ll gamma = binary_searchm(Z, G, C);
	if (Z + G * gamma >= B)return true;
	else return false;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	for (auto row : rows) {
		cout << (calc(row) ? "Yes" : "No") << endl;
	}
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
 
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
const double EPS=1e-8;
 
const int N_MAX=3;
bool Gauss_Jordan(int n,const double A[N_MAX][N_MAX],const double *b,double *x){
    static double B[N_MAX][N_MAX+1];
    rep(i,n){
        rep(j,n) B[i][j]=A[i][j];
        B[i][n]=b[i];
    }
 
    rep(i,n){
        int piv=i;
        for(int j=i;j<n;j++) if(abs(B[j][i])>abs(B[piv][i])) piv=j;
        rep(j,n+1) swap(B[i][j],B[piv][j]);
 
        if(abs(B[i][i])<EPS) return false;
 
        for(int j=i+1;j<=n;j++) B[i][j]/=B[i][i];
        rep(j,n) if(i!=j) for(int k=i+1;k<=n;k++) B[j][k]-=B[j][i]*B[i][k];
    }
 
    rep(i,n) x[i]=B[i][n];
    return true;
}
 
int main(){
    int n; scanf("%d",&n);
    double sx=0,sy=0,sxx=0,sxy=0,syy=0,sxxx=0,sxxy=0,sxyy=0,syyy=0;
    rep(i,n){
        int x,y; scanf("%d%d",&x,&y);
        sx+=x;
        sy+=y;
        sxx+=x*x;
        sxy+=x*y;
        syy+=y*y;
        sxxx+=x*x*x;
        sxxy+=x*x*y;
        sxyy+=x*y*y;
        syyy+=y*y*y;
    }
 
double A[3][3]={
	{sxx,sxy,sx},
	{sxy,syy,sy},
	{sx,sy,double(n)}
};
    double b[3]={-sxxx-sxyy,-sxxy-syyy,-sxx-syy},x[3];
 
    Gauss_Jordan(3,A,b,x);
 
    printf("%.9f %.9f %.9f\n",x[0],x[1],x[2]);
    return 0;
}

Measured memory_bytes: 1052
n=int(input())
l1=list(map(int,input().split()))
n=int(input())
l2=list(map(int,input().split()))
l1.sort()
l2.sort()
le=len(l1)
ind=0
for i in l2:
  while True:
    if ind+1>le:
      print('NO')
      exit()
    if ind+1<=le and i==l1[ind]:
      ind+=1
      break
    else:
      ind+=1
print('YES')

Measured memory_bytes: 34768
'''
Created on 2020/09/07

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  S=pin()[:-1]
  r=0
  g=0
  b=0
  cnt=0
  for i in range(N):
    if S[i]=="R":
      r+=1
    elif S[i]=="G":
      g+=1
    elif S[i]=="B":
      b+=1
    for j in range(i+1,N):
      k=2*j-i
      if k>=N:
        continue 
      if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
        cnt+=1
  print(r*g*b-cnt)
  return 
main()

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
// #define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
typedef vector<int> vi;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };
const ll MOD = 1000000007;
#define PI 3.14159265358979323846264338327950L


signed main() {
  int a,b,h,m;
  cin >> a>>b>>h>>m;
  ld theta, d;
  theta = (
    ((ld)h+(ld)m/60.0)/12.0 - (ld)m/60.0)*2*PI;
  d = (ld)(a*a+b*b)-(ld)(2*a*b)*cosl(theta);
  printf("%20.20Lf\n", sqrtl(d));
  return 0;
}

Measured memory_bytes: 4156
N = int(input())
h = list(map(int,input().split()))
a = [0]*N
ans = 0
for i in range(N):
  while a[i]<h[i]:
    ans += 1
    for j in range(i,N):
      if a[j]==h[j]:
        break
      a[j] += 1
print(ans)

Measured memory_bytes: 80308
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int d, t, s;
    cin >> d >> t >> s;
    if (s*t >= d) cout << "Yes\n";
    else cout << "No\n";
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

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


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    int d[k];
    for (int i = 0; i < k; i++) {
        scanf("%d", d + i);
    }
    
    bool used[10];
    for (int i = 0; i < 10; i++) {
        used[i] = true;
    }
    for (int i = 0; i < k; i++) {
        used[d[i]] = false;
    }
    
    for (int i = n; ; i++) {
        string s = to_string(i);
        bool ok = true;
        for (int j = 0; j < s.size(); j++) {
            if (!used[s[j] - '0']) {
                ok = false;
            }
        }
        if (ok) {
            printf("%d\n", i);
            break;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
import numpy as np
i8 = np.int64

maxnum = 110000
X = int(input())
a = np.zeros(maxnum, i8)

for i in range(2, 400):
    if a[i] == 0:
        j = i * 2
        while j < maxnum:
            a[j] = 1
            j += i
for i in range(X, maxnum):
    if a[i] == 0:
        print(i)
        exit(0)

Measured memory_bytes: 13300
n = int(input())

chr = [str(input()) for i in range (n)]
#print(chr)

first = [chr[x][:1] for x in range(n)]
#print(first)

last = [chr[y][-1] for y in range(n)]
#print(last)

same = 1
for z in range (n-1):
  if last[z] == first[z+1]:
    same = 0
  else:
    same = 1
    break

dbl = 0
for i in range (n):
  for j in range (i+1, n):
    if chr[i] == chr[j]:
      dbl = 1
    else:
      continue

#print(same, dbl)
if same == 0 and dbl == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
string s, t, x="UNRESTORABLE";
int main() {
	int i, j;
	cin>>s>>t;
	for(i=s.size()-t.size(); i>=0; i--) {
		for(j=0; j<t.size(); j++) {
			if(s[i+j]!='?' && s[i+j]!=t[j]) break;
		}
		if(j==t.size()) {
			x = s;
			for(j=0; j<t.size(); j++) x[i+j] = t[j];
			for(j=0; j<s.size(); j++) if(x[j]=='?') x[j] = 'a';
			break;
		}
	}
	cout<<x;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int T,card[16];

bool is_same_number( int a, int b, int c){
  return a==b && b==c;
}

bool is_sequence( int a, int b, int c){
  return a+2==b+1&&b+1==c;
}

bool is_good_set(int a,int b,int c){
  return is_same_number(a, b, c) || is_sequence(a, b, c);
}

bool is_all_good_set(){
  return is_good_set(card[0],card[1],card[2]) && is_good_set(card[3],card[4],card[5]) && is_good_set(card[6],card[7],card[8]);
}

int win() {
  sort(card,card+9);
  do {
    if (is_all_good_set()) return 1;
  } while( next_permutation(card, card+9) );
  return 0;
}

int main(){
  cin >> T;
  for (int t=0; t<T; ++t) {
    for (int i=0; i<9; ++i){
      cin >> card[i];
    }
    string color;
    for (int i=0; i<9; ++i){
      cin >> color;
      if(color == "G")card[i] += 10;
      else if (color == "B") card[i] +=20;
    }
    cout << win()  << endl;
  }
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n,a,b;
    scanf("%d%d%d", &n, &a, &b);

    if(n>(ll)a*b || n<a+b-1) {
        printf("-1\n"); return 0;
    }
    if(b==1) {
        int i;
        for(i=0; i<n; i++) {
            printf("%d ", i+1);
        }
        printf("\n");
        return 0;
    }

    int m=n-a;
    int q=m/(b-1);
    int r=m%(b-1);
    vector<ll> aa(a), sa(a+1);
    int i;
    for(i=0; i<a; i++) {
        if(i<q) aa[i]=b;
        else if(i==q) aa[i]=1+r;
        else aa[i]=1;
    }
    for(i=0; i<a; i++) {
        sa[i+1]=sa[i]+aa[i];
    }
    for(i=0; i<a; i++) {
        int curr=sa[i+1];
        int j;
        for(j=0; j<aa[i]; j++) {
            printf("%d ", curr);
            curr--;
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int k,n;
     cin>>k>>n;
     vector<int>v;
     int temp=0;
     int last=0,first=0;
     for(int i=0;i<n;i++){
		 int x;
		 cin>>x;
		 if(i==n-1)
		 last=x;
		 if(i==0)
		 first=x;
		 v.push_back(x-temp);
		 temp=x;
	 }
	 int l=k-last+first;
	 v.push_back(l);
	 sort(v.begin(),v.end(),greater<int>());
	 cout<<k-v[0]<<endl;
	 
 }
    


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

struct Node {
  vl adj;
  ll w = 1;
  ll b = 1;
};

vector<Node> V(100009);

void dfs(ll x, ll p) { //V[x].w と V[x].b を埋める
  for (ll y : V[x].adj) {
    if (y == p) continue;
    dfs(y, x);
    V[x].b *= V[y].w;
    V[x].b %= MOD;
    V[x].w *= (V[y].w + V[y].b) % MOD;
    V[x].w %= MOD;
    
  }
}

int main(void){
  
  IN(N);
  FOR(i, 1, N) {
    ll x, y;
    IN(x);
    IN(y);
    V[x].adj.pb(y);
    V[y].adj.pb(x);
  }

  dfs(1, -1);

  PRINT((V[1].w + V[1].b) % MOD);

}


Measured memory_bytes: 14208
#include<stdio.h>
int w,n,i;

int main(void)
{
        scanf("%d",&w);
        scanf("%d",&n);
        int data[w];

        for(i=0;i<w;i++) data[i] = i+1;

        for(i=0;i<n;i++)
        {
                int data1,data2;
                scanf("%d,%d",&data1,&data2);
                int temp = data[data1-1];
                data[data1-1] = data[data2-1];
                data[data2-1] = temp;
        }

        for(i=0;i<w;i++) printf("%d\n",data[i]);
        return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<int> num(n, -1);

    for (int i = 0; i < m; i++) {
        int s, c;
        std::cin >> s >> c;

        if (num[n - s] == -1 || num[n - s] == c) {
            num[n - s] = c;
        } else {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    if (n == 1 && num[0] == -1) {
        std::cout << 0 << std::endl;
        return 0;
    }

    if (num[n - 1] == -1) {
        num[n - 1] = 1;
    }

    for (int i = 0; i < n; i++) {
        if (num[i] == -1) {
            num[i] = 0;
        }
    }

    if (n > 1 && num[n - 1] == 0) {
        std::cout << -1 << std::endl;
        return 0;
    }

    for (int i = n - 1; i >= 0; i--) {
        std::cout << num[i];
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256