akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

#define fr(i,n) 	for(int i=0;i<n;i++)
#define frr(i,n)	for(int i=1;i<=n;i++)

#define ms(x,i)	memset(x,i,sizeof(x))
#define dbg(x)	cout << #x << " = " << x << endl
#define all(x)	x.begin(),x.end()

#define gnl cout << endl
#define olar cout << "olar" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f;
const int MOD = 1e9+7;

int main(){

	fastio;
	string s;
	getline(cin,s);

	int a,b;
	bool ok = true;
	fr(i,s.size()){
		if(s[i] == 'A' && ok){
			a = i;
			ok = false;
		}
		if(s[i] == 'Z') b = i;
	}

	cout << b - a + 1 << endl;

}


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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  reverse(c.begin(),c.end());
  string t=a;
  while(true){
    int sz=t.size()-1;
    if(t[sz]=='a'){
      if(a.size()==0){cout<<"A"; return 0;}
      t=a;
      a.pop_back();
    }
    else if(t[sz]=='b'){
      if(b.size()==0){cout<<"B"; return 0;}
      t=b;
      b.pop_back();
    }
    else if(t[sz]=='c'){
      if(c.size()==0){cout<<"C"; return 0;}
      t=c;
      c.pop_back();
    }

  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
  return 0;
}


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

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

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

const ll INF = 1e9;
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int n,w;
    cin >> n >> w;
    vector<vector<int>> dp(n+1,vector<int>(100001,INF + 7));
    dp[0][0] = 0;
    vector<int> W(n+1),V(n+1);
    for (int i = 1;i <= n;i++){
        cin >> W[i] >> V[i];
    }   

    for (int i = 1;i <= n;i++){
        for (int j = 0;j <= 100000;j++){
            if (j - V[i] >= 0){
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-V[i]] + W[i]);
            }
            else dp[i][j] = dp[i-1][j];
        }
    }

    ll ans = 100000;
    while(dp[n][ans] > w)ans--;

    cout << ans << endl;
}

Measured memory_bytes: 41848
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        
        HashSet<string> shurui = new HashSet<string> { };
        Console.ReadLine();
        long[] a = Read.longs();
        long FREEs = 0;
        long[] s = new long[a.Length];
        for (long i = 0; i < a.Length; i++)
        {
            /*  if (a[i] < 400) { s[i] = 1; }
              else if (a[i] < 800) { s[i] = 2; }
              else if (a[i] < 1200) { s[i] = 3; }
              else if (a[i] < 1600) { s[i] = 4; }
              else if (a[i] < 2000) { s[i] = 5; }
              else if (a[i] < 2400) { s[i] = 6; }
              else if (a[i] < 2800) { s[i] = 7; }
              else if (a[i] < 3200) { s[i] = 8; }
              */
            if (a[i] < 3200) { s[i] = a[i] / 400 + 1; shurui.Add(s[i].ToString()); }
            else
            {
                FREEs++;
            }
               }
        long saisho = shurui.Count();
        if (saisho == 0) { saisho = 1; }
        long saidai = (shurui.Count() + FREEs);
        Console.WriteLine(saisho+" "+saidai);Console.ReadLine();
    }


    public static Boolean uso() { return false; }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13524
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset; // order_of_key, find_by_order
int ans[1<<17];
void build(int L, int R, int A, int B, int msk) {
	if(L+2==R) {
		ans[L]=A;
		ans[L+1]=B;
		return;
	}
	int mid = (L+R)/2;
	int x = 1;
	while((A&x)==(B&x))x<<=1;
	int tA = min(A, A^x);
	int tB = min(B, B^x);
	int tC = msk^x;
	if((__builtin_popcount(tC)&1)==(__builtin_popcount(tA)&1)) tC = (tC-1)&tC;
	build(L, mid, tA, tC, msk^x);
	build(mid, R, tC, tB, msk^x);
	for(int i = ((A&x)?L:mid); i < ((A&x)?mid:R); i++)
		ans[i]^=x;
}
int main() {
	 ios::sync_with_stdio(0);
	 cin.tie(0);
	 cout.tie(0);
	 ll n, a, b;
	 cin >> n >> a >> b;
	 if((__builtin_popcount(a)&1)==(__builtin_popcount(b)&1)) return cout << "NO", 0;
	 cout << "YES\n";
	 build(0, 1<<n, a, b, (1<<n)-1);
	 for(int i = 0; i < 1<<n; i++) cout << ans[i] << " ";
}


Measured memory_bytes: 1536
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll       long long
#define ull       unsigned long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100000
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000

int a[maxn],b[maxn];

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		char a;
		cin >> a;
		if (a=='A') cout << 'T' << endl;
		else if (a=='T') cout << 'A' << endl;
		else if (a=='G') cout << 'C' << endl;
		else if (a=='C') cout << 'G' << endl;
		return 0;
}


Measured memory_bytes: 3608
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

#====BitIndexedTree====
class BitIndexedTree
    attr_accessor:bit,:n
    def initialize(n,init_array=nil)
      @n=n
      @bit=Array.new(@n+1){0}
      unless init_array.nil?
        @n.times do|i|
            add(i+1,init_array[i])
        end
      end
    end

    def add(i,x)
        while i<=@n
            @bit[i]+=x
            i+=i&-i
        end
    end

    def sum(i)
        ret_sum=0
        while i>0
          ret_sum+=@bit[i]
          i-=i&-i
        end
        return ret_sum
    end

    def get_sum(l,r)
        return sum(r)-sum(l-1)
    end
end


N,Q=get_i
A=get_i
bit=BitIndexedTree.new(N,A)
Q.times do|i|
    t,a,b=get_i
    a+=1
    if t.zero?
        bit.add(a,b)
    else
        puts bit.get_sum(a,b)
    end
end

Measured memory_bytes: 62124
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer count = sc.nextInt();
		ArrayList<Integer> mochiList = new ArrayList<Integer>();
		for(int i = 0; i < count; i++){
			Integer target = sc.nextInt();
			boolean duplicateFlag = false;
			for(int j = 0; j < mochiList.size(); j++){
				Integer tmp = mochiList.get(j);
				if(tmp.equals(target)){
					duplicateFlag = true;
				}
			}
			if(!duplicateFlag){
				mochiList.add(target);
			}
		}
		System.out.println(mochiList.size());
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

map<string, ll> sz;
map<pair<string, ll>, ll> val;
string in[1001], s;
char buf[90];
int p;

ll expr(){
	if(isdigit(s[p])){
		ll res = 0;
		while(isdigit(s[p])) res *= 10, res += s[p++] - '0';
		return res;
	}
	string name;
	while(isalpha(s[p])) name += s[p++];
	p++;
	ll d = expr();
	p++;
	if(d < 0 || d >= sz[name] || !val.count(mp(name, d))) throw "error";
	return val[mp(name, d)];
}

int main(){
	while(cin >> in[0], in[0] != "."){
		int n = 1;
		while(cin >> in[n], in[n] != ".") n++;
		sz.clear(); val.clear();
		rep(i, n){
			try{
				int pos = in[i].find("=");
				ll d, d2;
				if(pos == in[i].npos){
					rep(j, in[i].size()) if(in[i][j] == '[' ||
						in[i][j] == ']') in[i][j] = ' ';
					sscanf(in[i].c_str(), "%s%lld", buf, &d);
					sz[buf] = d;
				}
				else{
					s = in[i].substr(pos + 1);
					in[i] = in[i].substr(0, pos);
					p = 0;
					d = expr();
					pos = in[i].find("[");
					string name = in[i].substr(0, pos);
					s = in[i].substr(pos + 1, in[i].rfind("]") - pos - 1);
					p = 0;
					d2 = expr();
					if(d2 < 0 || d2 >= sz[name]) throw "error";
					val[mp(name, d2)] = d;
				}
			}catch(const char *e){
				cout << i + 1 << endl;
				goto END;
			}
		}
		cout << 0 << endl;
		END:;
	}
	return 0;
}

Measured memory_bytes: 1560
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define scanf(...) scanf(__VA_ARGS__)?:0
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <PII, int> PPI;
typedef pair <ll, ll> PLL;
typedef pair <PLL, PLL> PP;
typedef unsigned int ui;
const int inf = 1e9+9;
const int mod = 1e9+7;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
#define maxn 1000003
int n, m, k, a, b, c;

int s1[maxn], s2[maxn];
int A[maxn], B[maxn];
int tab[maxn];

int main()
{
	boost;
	cin >> n;
	FOR(i, 1, n) cin >> A[i];
	FOR(i, 1, n) cin >> B[i];
	
	FOR(i, 1, n)
	  if (A[i] > A[i-1]) s1[i] = A[i];
	for (int i=n; i>0; --i)
	  if (B[i] > B[i+1]) s2[i] = B[i];
	
	FOR(i, 1, n)
	  if (s1[i] != 0 && s2[i] != 0 && s2[i] != s1[i]) OUT(0);
	
	FOR(i, 1, n) {
	  if (s1[i] > 0 && s2[i] == 0) {
		  if (A[i] > B[i]) OUT(0);
	  }
	  else if (s2[i] > 0 && s1[i] == 0) {
		  if (B[i] > A[i]) OUT(0);
	  }
	  tab[i] = max(s1[i], s2[i]);
  }
	  
	
	ll wyn = 1;
	FOR(i, 1, n)
	  if (tab[i] == 0) {
		  wyn = (wyn * (ll)min(A[i], B[i]))%mod;
	  }
	cout << wyn % mod;
	
}


Measured memory_bytes: 1792
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vd heads = vd();
	heads.pb(-1);
	rep(i, n){
		double p; cin >> p;
		heads.pb(p);
	}
	// dp[i][j] = prob of getting j heads with first i coins
	// dp[i][j] = P(ith coin heads and j-1 heads with i-1 coins) + 
	//            P(ith coin tails and j heads with i-1 coins)
	vvd dp = vvd(n+1, vd(n+1, 0));
	dp[1][0] = 1 - heads[1];
	dp[1][1] = heads[1];
	for(int i = 2; i < n + 1; i++){
		for(int j = 0; j <= i; j++){
			if (j > 0){
				dp[i][j] += heads[i]*dp[i-1][j-1];				
			}
			dp[i][j] += (1-heads[i])*dp[i-1][j];
		}
	}
	double ans = 0;
	int mid = n/2;
	for(int j = 0; j <= n; j++){
		if (j > mid){
			ans += dp[n][j];
		}
	}
	cout << fixed << setprecision(10) << ans;
}

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

int main()
{
    int A,B;
    cin >> A >> B;
    
    if((A+B)%2 == 0){
        cout << (A+B)/2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

int main() {
	int N;
	cin >> N;
	int odd = 0, even = 0, a;
	REP(i, N) {
		cin >> a;
		if (a % 2) {
			odd++;
		}
		else {
			even++;
		}
	}
	
	if (odd % 2) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
 
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <map>
#include <utility>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    vector<ll> a(n);
    vector<ll> s(n+1);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    s[0] = 0;
    for (int i = 0; i < n; i++) {
        s[i+1] = s[i]+a[i];
    }
    sort(s.begin(), s.end());
    map<ll, ll> m;
    for (ll i = 0; i < n; i++) {
        if (s[i] == s[i+1]) {
            m[s[i]]++;
        }
    }
    ll ans = 0;
    for(auto x : m) {
        ans += (x.second+1)*x.second/2;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, m, x;
  cin >> n >> m >> x;
  ll c1 = 0, c2 = 0;
  REP(i, m) {
    ll a;
    cin >> a;
    if (a > x) c1++;
    else
      c2++;
  }
  cout << min(c1, c2) << endl;

  return 0;
}


Measured memory_bytes: 3600
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let k = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(k));
}

fn solve(k: i32) -> i32 {
    let a = k / 2;
    let b = k - a;
    a * b
}

#[test]
fn example1() {
    assert_eq!(2, solve(3))
}

#[test]
fn example2() {
    assert_eq!(9, solve(6))
}

#[test]
fn example3() {
    assert_eq!(30, solve(11))
}

#[test]
fn example4() {
    assert_eq!(625, solve(50))
}


Measured memory_bytes: 4352
N=int(input())
t=[0]*N
x=[0]*N
y=[0]*N
for i in range(N):
    t[i],x[i],y[i]=map(int,input().split())
t.insert(0,0)
x.insert(0,0)
y.insert(0,0)
flag=True
for i in range(1,N+1):
    distance=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    dt=t[i]-t[i-1]
    if distance>dt:
        flag=False
        break
    elif t[i]%2==0:
        if (x[i]+y[i])%2!=0:
            flag=False
    elif t[i]%2==1:
        if (x[i]+y[i])%2!=1:
            flag=False
if flag==True:
    print("Yes")
else:
    print("No")
    

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  ll r,d,x;
  cin>>r>>d>>x;
  
  REP(i,10){
    x=r*x-d;
    cout<<x<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a=0;
  cin >> a;
  if(a%9 == 3){
    cout << 3 << endl;
  }
  else if(a%9 == 2){
    cout << 2 << endl;
  }
  else if(a%9==1){
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

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

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    readint();
    auto ss = assumeSorted(readints());
    readint();
    auto ts = readints();

    ulong ans = ts.count!(e => ss.contains(e));
    writeln(ans);
}

Measured memory_bytes: 6780
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
ll sizes[100001];
ll arr[100001];
ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000];
void era(){
    memset(prime,true,sizeof prime);
    for(ll p=2;p*p<=10000;p++){
        if(prime[p]){
            for(ll q=p*p;q<=10000;q+=p){
                prime[q]=false;
            }
        }
    }

    return;
}
int main(){
    IO
    int N;
    cin>>N;
    ll dp[N+1][4][4][4];

    memset(dp,0,sizeof dp);
    //A=0 T=1 C=2 G=3
    for(int a=0;a<4;a++)
        for(int b=0;b<4;b++)
        for(int c=0;c<4;c++){

        if(a==0 && b==3 && c==2) continue;
        if(a==0 && b==2 && c==3) continue;
        if(a==3 && b==0 && c==2) continue;
        dp[3][a][b][c]++;
        }
    for(int i=4;i<=N;i++){
        for(int a=0;a<4;a++){
            for(int b=0;b<4;b++){
                for(int c=0;c<4;c++){
                    if(a==0 && b==3 && c==2) continue;
                    if(a==0 && b==2 && c==3) continue;
                    if(a==3 && b==0 && c==2) continue;
                    for(int d=0;d<4;d++){
                        if(d==0 && a==3 && c==2) continue;
                        if(d==0 && b==3 && c==2) continue;
                        dp[i][a][b][c]+=(dp[i-1][d][a][b])%MAX;

                    }
                }
            }
        }
    }

    ll cnt=0;
    for(int a=0;a<4;a++)
        for(int b=0;b<4;b++)
        for(int c=0;c<4;c++)
        cnt+=(dp[N][a][b][c])%MAX;
        cout<<cnt%MAX;
    return(0);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    k = II()
    S = input()

    n = len(S)
    if n <= k:
        print(S)
    else:
        print(S[:k] + '...')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9220
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i< N; i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, m;
  cin >> n >> m;
  vi x(n+1), y(m+1);
  cin >> x[0] >> y[0];
  rep(i,n) cin >> x[i+1];
  rep(i,m) cin >> y[i+1];
  int xmax = *max_element(rng(x));
  int ymin = *min_element(rng(y));
  if (xmax < ymin) puts("No War");
  else puts("War");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using ll = unsigned long long;
using namespace std;

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

    int* score = new int[s.size()];
    for(int i = 0; i < s.size(); ++i) {
        score[i] = 0;
    }

    int lstreak = 0;
    int lodd = 0, leven = 0;
    int rodd = 0, reven = 0;
    int rstreak = 0;

    // check r
    for ( int i = 0; i < s.size()-1 ; ++i) {
        if(s[i] == 'R' && s[i+1] == 'L') { 
            if (i&1) {
                score[i] += rodd;
                score[i+1] += reven;
            } else {
                score[i] += reven;
                score[i+1] += rodd;
            }
            score[i] += 1;
            rodd = 0;
            reven = 0;

        } else {
            if (i&1) {
                if (s[i] == 'R') {
                    rodd++;
                } else {
                    // lodd++;
                }

            } else {
                if (s[i] == 'R') {
                    reven++;
                } else {
                    // leven++;
                }
            }
        }
    }
    if (rodd > 0 || reven > 0) {
        score[s.size()-1] += rodd + reven + 1;
    }

    //check l
    for (int i = s.size()-1; i >= 1; --i) {
        // cout << "i:" << i <<", lodd:" << lodd << ", leven:" << leven << endl;
        if(s[i] == 'L' && s[i-1] == 'R') { 
            if (i&1) {
                score[i] += lodd;
                score[i-1] += leven;

            } else {
                score[i] += leven;
                score[i-1] += lodd;
            }
            score[i] += 1;
            lodd = 0;
            leven = 0;
            // cout << "cleared" << endl;

        } else {
            if (i&1) {
                if (s[i] == 'L') {
                    lodd++;
                } else {
                    // lodd++;
                }

            } else {
                if (s[i] == 'L') {
                    leven++;
                } else {
                    // leven++;
                }
            }
        }
    }

    if (lodd > 0 || leven > 0) {
        score[0] += lodd + leven + 1;
    }

    for (int i = 0; i < s.size(); ++i) {
        cout << score[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1024
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let a: usize = scan(tokens);
    let b: usize = scan(tokens);
    let ps = prime_factors(a);
    let qs = prime_factors(b);
    let mut ans = 1;
    let mut i = 0;
    let mut j = 0;
    while i < ps.len() && j < qs.len() {
        if ps[i] == qs[j] {
            ans += 1;
            i += 1;
            j += 1;
        } else if ps[i] < qs[j] {
            i += 1;
        } else {
            j += 1;
        }
    }
    println!("{}", ans);
}

fn prime_factors(mut n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for d in 2.. {
        if n == 1 {
            break;
        } else if n < d * d {
            res.push(n);
            break;
        }
        if n % d == 0 {
            res.push(d);
            while {
                n /= d;
                n % d == 0
            } {}
        }
    }
    res
}


Measured memory_bytes: 4352
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, r; cin >> n >> r;
	if(n < 10) {
		println(r+100*(10-n));
	}
	else {
		println(r);
	}
}


Measured memory_bytes: 256
def main():
    mod = 10**9+7
    fact = [1]*200001
    for i in range(1, 200001):
        fact[i] = fact[i-1]*i % mod

    def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)
    def nCr(n, r, mod=10**9 +
            7): return inv_n(fact[n-r]*fact[r] % mod, mod)*fact[n] % mod
    n, a, b, c = map(int, input().split())
    pan = pow(a, n, mod)
    pbn = pow(b, n, mod)
    ivab = 100*inv_n(a+b) % mod
    ans = 0
    for i in range(n, 2*n):
        ans = (ans + i*ivab*nCr(i-1, n-1)*(pan*pow(b, i-n, mod) +
                                           pow(a, i-n, mod)*pbn)*inv_n(pow(a+b, i, mod))) % mod
    print(ans)


main()


Measured memory_bytes: 10868
using System;

class Program {

    public static int max(int a, int b) {
        if (a > b) {
            return a;
        }
        else {
            return b;
        }

    }

    public static int max3(int a, int b, int c) {
        int x = max(b, c);
        if (a > x) {
            return a;
        }
        else {
            return x;
        }
    }

    static void Main(string[] args){

        int n = int.Parse(Console.ReadLine());

        int[,] f = new int[n, 3];

        for (int i = 0; i < n; i++) {
            string[] aux = Console.ReadLine().Split(' ');
            for (int j = 0; j < 3; j++) {
                f[i, j] = int.Parse(aux[j]);
            }
        }

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                if (j == 0) {
                    f[i, 0] += max(f[i-1, 1], f[i-1, 2]);
                }
                else if (j == 1) {
                    f[i, 1] += max(f[i-1, 0], f[i-1, 2]);
                }
                else if (j == 2) {
                    f[i, 2] += max(f[i-1, 0], f[i-1, 1]);
                }
            }
        }

        Console.WriteLine(max3(f[n - 1, 0], f[n - 1, 1], f[n - 1, 2]));

    }
}


Measured memory_bytes: 17312
#include <bits/stdc++.h>
#include <numeric>
#define M 1000000007
#define pb push_back
#define forz(i,s,n) for(lli i=s;i<n;i++)

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

typedef long long int lli;
//typedef pair<long long int, long long int> pll;
typedef unsigned long long int ull;
using namespace std;

lli recpow(lli x, lli n)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x) % M, n / 2);
    else //n is odd
        return (x * recpow((x * x) % M, (n - 1) / 2)) % M;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.second < b.second);
}

bool comp(pair<lli, lli> a, pair<lli, lli> b)
{
    if(a.first==b.first)
        return a.second<b.second;
    else
        return a.first<b.first;
}

void multiply(lli f[2][2], lli m[2][2])
{
    lli x = (f[0][0] % M * m[0][0] % M) % M + (f[0][1] % M * m[1][0] % M) % M;
    lli y = (f[0][0] % M * m[0][1] % M) % M + (f[0][1] % M * m[1][1] % M) % M;
    lli z = (f[1][0] % M * m[0][0] % M) % M + (f[1][1] % M * m[1][0] % M) % M;
    lli w = (f[1][0] % M * m[0][1] % M) % M + (f[1][1] % M * m[1][1] % M) % M;
    f[0][0] = x % M;
    f[0][1] = y % M;
    f[1][0] = z % M;
    f[1][1] = w % M;
}

lli u[2][2] = {{1, 1}, {1, 0}};

void power(lli f[2][2], lli n)
{
    if (n == 0 || n == 1)
        return;
    power(f, n / 2);
    multiply(f, f);
    if (n % 2 != 0)
        multiply(f, u);
}

lli fib(lli n)
{
    if (n == 1)
        return 2;
    else if (n == 2)
        return 3;
    else
    {
        lli h[2][2] = {{1, 1}, {1, 0}};
        power(h, n + 1);
        return h[0][0];
    }
}

//code begins here
int main()
{
    fast_io;
    lli n;
    cin>>n;
    lli h[n];
    forz(i,0,n)
    cin>>h[i];
    lli dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    forz(i,1,n)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  sort(S.begin(),S.end());
  vector<ll> alp(30,0);
  char C,c; int cnt=1,CNT=0;
  for(int i=0;i<N;i++){
    c=S.at(i);
    if(i==0){
      C=c;continue;
    }
    if(c==C){
      cnt++;
    }else{
      C=c;
      alp.at(CNT)=cnt;
      cnt=1; CNT++;
    }
  }
  alp.at(CNT)=cnt;
  ll ans=1;
  for(int i=0;i<30;i++){
    ans*=(alp.at(i)+1);
    ans%=1000000007;
  }
  ans+=1000000006;
  ans%=1000000007;
  cout << ans;
}

Measured memory_bytes: 512
import java.util.Scanner;   
public class Main{ 
         public static void main(String... args){ 
                  Scanner sc = new Scanner(System.in); 
                  int a = sc.nextInt(); 
                  int b = sc.nextInt(); 
                  if((a * b % 2) == 0) System.out.println("Even"); 
                  else System.out.println("Odd"); 
          } 
 } 


Measured memory_bytes: 23124
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,d=gets.chomp.split(' ').map{|n| n.to_i}
H = {}
gets.chomp.split(" ").map{|i| i.to_i}.each{|i|
	H[i].nil? ? H[i]=1 : H[i]+=1
}
T = H.to_a.select{|k,v| v>1}.sort{|(k1,v1),(k2,v2)| k2 <=> k1}
if(T.size < 2)
	puts 0
elsif(T[0][1]>=4)
	puts T[0][0]**2
else
	puts T[0][0]*T[1][0]
end


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

int main() {
    int n; cin >> n; --n;
    int c[n], s[n], f[n];
    for (int i = 0; i < n; ++i) cin >> c[i] >> s[i] >> f[i];   
    
    for (int i = 0; i < n; i++) {
        int cur_time = 0;
        for (int j = i; j < n; j++) {
            // for waiting
            if (cur_time < s[j])
                cur_time += s[j] - cur_time;
            if (cur_time % f[j] != 0)
                cur_time += f[j] - (cur_time % f[j]);
            
            // for moving
            cur_time += c[j];
        }
        cout << cur_time << "\n";
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n,k = map(int,input().split())

ans = 0
for i in range(k,n+2):
    i %= MOD
    add = -i**2 + i*(n+1) + 1
    add %= MOD
    ans += add

ans %= MOD
print(ans)



Measured memory_bytes: 79760
package main

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

func main() {
	sc := NewScanner()

	x := sc.ReadInt()
	y := sc.ReadInt()

	possible := false
	if y%2 == 0 {
		if 2*x <= y && y <= 4*x {
			possible = true
		}
	}

	if possible {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1756
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(10)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main() {
	vector<lint>abc{ in(),in(),in() };
	sort(ALL(abc));
	cout << abc[2] * 10 + abc[1] + abc[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h, n;
  cin >> h >> n;
  int a[n];
  for(int i = 0; i < n ; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    h -= a[i];
  }

  if(h <= 0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var nab = Console.ReadLine().Split(' ');
            var n = nab[0].ToInt();
            var a = nab[1].ToInt();
            var b = nab[2].ToInt();
            var s = Console.ReadLine().ToArray();
            var cnta = 0;
            var cntb = 0;
            var output = new string[s.Length];
            for (var i = 0; i < n; ++i)
            {
                if (s[i] == 'a')
                {
                    if (cnta + cntb < a + b)
                    {
                        ++cnta;
                        Console.WriteLine("Yes");
                    }
                    else Console.WriteLine("No");
                }
                else if (s[i] == 'b')
                {
                    if (cnta + cntb < a + b && cntb < b)
                    {
                        ++cntb;
                        Console.WriteLine("Yes");
                    }
                    else Console.WriteLine("No");
                }
                else Console.WriteLine("No");
            }
        }
    }

    static class Ex
    {
        public static int ToInt(this string str)
        {
            return int.Parse(str);
        }
    }
}


Measured memory_bytes: 8920
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

int main(){

    int n,k;
    cin >> n >> k;
    vector<bool> d(10);
    int tmp;
    REP(i,k){
        cin >> tmp;
        d[tmp] = true;
    }
    
    bool flag = true;
    while(flag){
        bool exist = true;;
        vector<int> a(10,0);
        string s = to_string(n);
        //含まれる数字の数え上げ
        REP(i,s.length()){
            a[s[i]-'0']++;
        }
        
        //満たしているか
        REP(i,10){
            if(d[i] == true && a[i] > 0){
                /*これは不適*/
                exist = false;
            }
        }

        if(exist){
            flag = false;
        }else{
            n++;
        }       
    }
    cout << n << endl;
    return 0;
}

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

int main(){
  vector<int> x(3);
  cin >> x.at(0) >> x.at(1) >> x.at(2);
  sort(x.begin(),x.end());
  if(x.at(0)<x.at(1)&&x.at(1)<x.at(2)){
    cout << "No" << endl;
  }else if(x.at(0)==x.at(1)&&x.at(1)==x.at(2)){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long N = in.nextLong();
            long move = N - 1;
            long max = (long) Math.sqrt(N);
            for (long i = 2; i <= max; i++) {
                long temp = i + N / i - 2;
                if (N % i == 0 && temp < move) {
                    move = temp;
                }
            }
            out.println(move);
        }

    }
}



Measured memory_bytes: 23764
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
ll deg(ll n){
    ll count = 0;
    while(n!= 0){
        n/=10;
        count++;
    }
    return count;
}
int main(){
    int n;
    cin >> n;
    int h[n+2];
    int tail = 1;
    int head = n+1;
    int dmin = 100000;
    for(int i = 1;i < n+1;i++) cin >> h[i];
    bool st = false;
    for(int i = tail;i < n+1;i++) {
       if(h[tail] == 0){
                st = true;
            }
            if(st && h[i] != 0){
                tail = i;
                st = false;
            }

            if(h[i] != 0 && head == n+1 && !st) dmin = min(dmin, h[i]);

            if(!st && h[i] == 0){
                head = i;
                break;
            }

    }
    int count = dmin;

    while(true){
        bool z = true;
        for(int i = tail;i < head;i++){
            h[i] -= dmin;  
        }
       
        head = n+1;
        dmin = 100000;
        bool st = false;
        for(int i = tail;i < n+1;i++){
            if(h[tail] == 0){
                st = true;
            }
            if(st && h[i] != 0){
                tail = i;
                st = false;
            }

            if(h[i] != 0 && head == n+1 && !st) dmin = min(dmin, h[i]);

            if(!st && h[i] == 0){
                head = i;
                break;
            }
           

        }

        for(int i = 1;i < n+1;i++){
            if(h[i] != 0) z = false;
        }
        
        if(z) break;
        count += dmin;
    }
    cout << count << endl;
    
}

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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  ll n;
  cin >> n;

  int di = 1;
  while (n > pow(26, di)) {
    n -= pow(26, di);
    ++di;
  }

  --n;

  vector<int> r(di);
  for (int i = 0; i < di; ++i) {
    r[i] = n % 26;
    n /= 26;
  }

  for (int i = di - 1; i >= 0; --i) {
    cout << (r[i] == 0 ? 'a' : (char)('a' + r[i]));
  }

  cout << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};



int main(){

  int H,W,h,w;
  cin >> H >> W >> h >> w;
  cout << H*W - h*W - w*H+ h*w << endl;

  return 0;
}


Measured memory_bytes: 384
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int A, P;
	cin >> A >> P;
	int B = A * 3 + P;
	cout << B / 2 << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
//
// Created by 李青坪 on 2018/10/7.
//

#include "cstdio"

using namespace std;

int a[20];

int findSolution(int target, int sum, int low, int high){
    if (low > high) return 999999999;
    if (a[low] + sum == target) return target;
    for (int i = low; i <= high; ++i) {
        int temp = sum + a[i];
        if (temp == target) return temp;
        if (temp > target) continue;
        temp = findSolution(target, temp, i+1, high);
        if (temp == target) return temp;
    }
    return 999999999;
}

void search(int m[], int n, int q){
    for (int i = 0; i < q; ++i) {
        bool found = false;
        for (int j = 0; j < n; ++j) {
            if (a[j] == m[i]){
                found = true;
                printf("yes\n");
                break;
            }
            if (a[j] > m[i]) {
                continue;
            }
            int sum = findSolution(m[i], a[j], j+1, n-1);
            if (sum == m[i]){
                found = true;
                printf("yes\n");
                break;
            }
        }
        if (!found)
            printf("no\n");
    }
}

int main(){
    int n,q;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    scanf("%d", &q);
    int m[q];
    for (int j = 0; j < q; ++j) {
        scanf("%d", &m[j]);
    }
    search(m, n, q);
}

/*
5
1 5 7 10 21
8
2 4 17 8 22 21 100 35

 */


Measured memory_bytes: 2628