akhauriyash/Code-Regression huggingface dataset:
/**
*    author:  souzai32
*    created: 14.08.2020 15:16:03
**/

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

int main() {

    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++) cin >> a.at(i);
    vector<int> ans;

    for(int i=n; i>0; i--){
        if(a.at(i)%2){
            ans.push_back(i);
            for(long long j=1; j*j<=i; j++){
                if(i%j==0){
                    a.at(j)++;
                    if(j*j!=i) a.at(i/j)++;
                }
            }
        }
        // rep(j,ans.size()-1) cout << ans.at(j) << ' ';
        // cout << endl;
    }
    cout << ans.size() << endl;
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()-1) cout << ans.at(i) << ' ';
    if(ans.size()) cout << ans.at(ans.size()-1) << endl;

    return 0;
}

Measured memory_bytes: 4676
def abc():
    from math import ceil
    menus = []
    for i in range(5):
        t = int(input().rstrip())
        next = ceil(t / 10) * 10
        wait = next - t
        menus.append((t, next, wait))
    menus.sort(key=lambda x: x[2])
    progress = 0
    for i in range(4):
        progress += menus[i][1]
    progress += menus[4][0]
    print(progress)


abc()


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, k;
signed main() {
	cin >> n >> k;
	if (k == 1) {
		cout << 0 << endl;
	}
	else {
		cout << (n - k) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define MAX 100
  
struct S {
    int g, t;
    S(int g, int t) : g(g), t(t) {}
};
  
int arr[MAX];
vector<S> seat;
  
int minute(int i)
{
    return 17*(i%2) + 3*(i%3) + 19;
}
  
void make()
{
    int g = 0;
    for (int i = 0; i < 17; i++) {
	seat.push_back(S(-1, -1));
    }
    vector<S> _wait;
    for (int i = 0; i < 570; i++) {
	int size = _wait.size();
  
	if (size) {
	    for (int j = 0; j < size; j++) {
		_wait[j].t++;
	    }
	}
     
	for (int j = 0; j < 17; j++) {
	    if (seat[j].g != -1) {
		seat[j].t--;
		if (seat[j].t == 0) {
		    seat[j].g = seat[j].t = -1;
		}
	    }
	}
   
	if (size) {
	    for (int j = 0; j < size; j++) {
		int n = _wait[j].g;
		int cnt, c;
		bool flg = false;
		if (n % 5 == 1) cnt = c = 5;
		else cnt = c = 2;
		for (int k = 0; k < 17; k++) {
		    if (seat[k].g == -1) cnt--;
		    else cnt = c;
		    if (cnt == 0) {
			for (int l = k-c+1; l <= k; l++) {
			    seat[l].g = n;
			    seat[l].t = minute(n);
			}
			arr[n] = _wait[j].t;
			flg = true;
			j--;
			_wait.erase(_wait.begin());
			break;
		    }
		}
		if (!flg || !_wait.size()) break;
	    }
	    size = _wait.size();
	}
	if (g == 100) continue;
	if (i % 5 == 0) {
	    int cnt, c;
	    bool flg = false;
	    if (size) {
		_wait.push_back(S(g, 0));
		g++;
		continue;
	    }
	    if (g % 5 == 1) cnt = c = 5;
	    else cnt = c = 2;
        
	    for (int j = 0; j < 17; j++) {
		if (seat[j].g == -1) cnt--;
		else cnt = c;
		if (cnt == 0) {
		    flg = true;
		    for (int k = j-c+1; k <= j; k++) {
			seat[k].g = seat[k].g = g;
			seat[k].t = seat[k].t = minute(g);
		    }
		    arr[g] = 0;
		    break;
		}
	    }
	    if (!flg) {
		_wait.push_back(S(g,0));
	    }
	    g++;
	}
    }
}
  
int main()
{
    int N;
    make();
    while (cin >> N) {
	cout << arr[N] << endl;
    }
    return 0;
}

Measured memory_bytes: 3008
n = int(input())
a = list(map(int, input().split()))
M = max(a)
ok = [0]*(M+1)
a.sort()

for i in range(n):
    ok[a[i]] += 1
    if ok[a[i]] == 1:
        for g in range(a[i], M+1, a[i]):
            if g != a[i]:
                ok[g] += 2


print(ok.count(1))


Measured memory_bytes: 32240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int x;
ll solve(){
   ll ans=0;
   

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

    cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 2000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[2], b[2];
    cin >> a[0] >> a[1] >> b[0] >> b[1];
    int ans = -INF2;
    rep(i, 2) {
        rep(j, 2) {
            ans = max(ans, a[i] * b[j]);
        }
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;

long long char_counts[26];
int main(){
    string A;
    cin >> A;
    
    for(int i = 0; i < A.size(); i++){
        char_counts[A[i] - 'a'] ++;
    }

    long long ans = (A.size() * (A.size() - 1)) / 2 + 1;
    for(int i = 0; i < 26; i++){
        ans -= (char_counts[i] * (char_counts[i] - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
from numba import njit,prange
@njit('i8(i8)',cache=True)
def f(k):
    a = 7%k
    for i in prange(k):
        if a == 0:
            return i+1
        a = (a*10+7)%k
    else:
        return -1
k = int(input())
print(f(k))

Measured memory_bytes: 105752
#include <iostream>
using namespace std;
int main() {
        long long int n,ans=0;
        cin >> n;
        ans += 1000 * (n / 500); 
        n -= 500 * (n / 500); 
        ans += 5 * (n / 5); 
        cout << ans << endl;
        return 0;
}

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

int k, n, a[1000004];

int main() {
	cin>>k>>n;
	for(int i = 0; i < n; i++)	cin>>a[i];
	int ans = a[n-1] - a[0];
	for(int i = 1; i < n; i++)
		ans = min(ans, k-a[i] + a[i-1]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
int x;

int main(){
	cin>>x;
	ll sum=0;
	for(int i=1;i<=x;i++){
		sum+=i;
		if(sum>=x){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,k;
ll mp[3005][3005];
ll dp[3005][3005][4];
ll dfs(int i,int j,int t)
{
    if(i<1||i>n||j<1||j>m||t>3) return -1e18;
    if(dp[i][j][t]!=-1) return dp[i][j][t];
   // printf("//%d %d %d\n",i,j,t);
    if(i==n&&j==m)
    {
        if(t<3) return mp[i][j];
        return 0;
    }
    ll ans=0;
    ans=max(ans,max(dfs(i+1,j,0),dfs(i,j+1,t)));
    if(mp[i][j]) ans=max(ans,mp[i][j]+dfs(i,j+1,t+1));
    if(mp[i][j]&&t<3) ans=max(ans,mp[i][j]+dfs(i+1,j,0));
    return dp[i][j][t]=ans;
}
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    read(n),read(m),read(k);
    while(k--)
    {
        int x,y,v;
        read(x),read(y),read(v);
        mp[x][y]=v;
    }
    printf("%lld\n",dfs(1,1,0));
    return 0;
}
/*
1 4 4
1 1 1
1 2 2
1 3 3
1 4 4
*/


Measured memory_bytes: 356732
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int a, b, n;
    while(cin >> a >> b >> n){
	a %= b;
	a *= 10;
	int res = 0;
	while(n--){
	    res += a / b;
	    a %= b;
	    a *= 10;
	}
	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main() {
    int x, y;
    while(1) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) {
            return 0;
        } else {
            (x <= y) ? printf("%d %d\n", x, y) : printf("%d %d\n", y, x);
        }
    }
}


Measured memory_bytes: 1924
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,m,a,b;
set<int> l,r;

main(){
    cin>>n>>m;
    rep(i,m){
        cin>>a>>b;
        if(a==1)l.insert(b);
        if(b==n)r.insert(a);
    }
    for(auto x:l){
        if(r.count(x)){
            dump("POSSIBLE");
            return 0;
        }
    }
    dump("IMPOSSIBLE");
}




Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;

    int g[1000][2];
    for (int i = 0; i < n; i++)
        cin >> g[i][0] >> g[i][1];

    int count = 0;
    for (int i = 0; i < n; i++)
        count += g[i][1] - g[i][0] + 1;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int fun(int s){
  int a;

    if(0==s%2){
    a=s/2;
  }
  else{
    a=3*s+1;
  }

  return a;
}

int main(void){
  int cou,a,i,m=1;
  int n[1000000];

  scanf("%d",&a);

  do{

  n[m-1]=a;

  a=fun(a);

  for(i=0;i<m;i++){
    if(a==n[i]){
      printf("%d\n",m+1);
      cou++;
    }
  }


  m++;


}while(cou==0);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();

        if(k<=a){
          System.out.println(a-k+" "+ b);
        }else if(k<=a+b){
          System.out.println(0+" "+(b-(k-a)));
        }else{
          System.out.println(0+" "+0);
        } 
    }
}

Measured memory_bytes: 21844
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] *= -1
heapq.heapify(a)
for _ in range(m):
    x = heapq.heappop(a)
    heapq.heappush(a, (-x//2)*(-1))    
 
print(-sum(a))

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

int main(){
  string s; cin>>s;
  int cnt=0;
  char bef=s[0];
  for (int i=1; i<s.size(); i++){
    if (s[i]!=bef)  cnt+=1;
    bef=s[i];
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;


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

	SORT(s);
	RESORT(t);
	int k = min(s.size(), t.size());
	int c = 0;

	REP(i, k) {
		if (s[i] - 'a' < t[i] - 'a') {
			cout << "Yes" << endl;
			return 0;
		}
		if (s[i] - 'a' == t[i] - 'a') {
			c++;
		}
	}

	if ((c == s.size()) && (s.size() < t.size())) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict


def read():
    N = int(input().strip())
    XY = []
    for i in range(N):
        x, y = map(int, input().strip().split())
        XY.append((x, y))
    return N, XY


def solve(N, XY):
    if N == 1:
        return 1

    min_cost = 1000000
    for j in range(N):
        for i in range(j):
            rdict = defaultdict(list)
            x0, y0 = XY[i]
            x1, y1 = XY[j]
            p, q = x1 - x0, y1 - y0
            for k in range(N):
                x, y = XY[k]
                rdict[q * x - p * y].append((x, y))
            cost = 0
            for v in rdict.values():
                vs = list(sorted(v))
                x0, y0 = vs[0]
                for x1, y1 in vs:
                    if x1 - x0 != p or y1 - y0 != q:
                        cost += 1
                    x0, y0 = x1, y1
            min_cost = min(min_cost, cost)
    return min_cost


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


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

int main(){
  ll n, c, ans = 0;
  cin >> n;
  c = n;
  map<ll,ll> m;
  for(ll i = 2; i*i <= n; i++) while(c % i == 0) {m[i]++, c /= i;}
  if(c > 1) m[c]++;
  ll num[100] = {};
  for(int i = 1; i < 100; i++) num[i] += i + num[i-1];
  for(auto x : m) ans += (int)(upper_bound(num,num+100,x.second)-num) - 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

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


int main(){
    int N;cin >> N;
    vector<int> t(N);
    vector<int> x(N);
    vector<int> y(N);
    rep(i,N)cin >> t[i] >> x[i] >> y[i];

    int p = 0;
    int q = 0;

    vector<bool> ok(N,false);

    rep(i,N){
        int d = abs((x[i] - p) + (y[i] - q));
        if(t[i] >= d && (t[i] - d) % 2 == 0){
            ok[i] = true;
        }
    }

    bool ans = true;

    rep(i,N){
        if(!ok[i])ans = false;
    }

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

int ccw(Point a, Point b, Point c)
{
  b -= a;
  c -= a;
  if(b.det(c) > 0.0)    return  1;
  if(b.det(c) < 0.0)    return -1;
  if(b.dot(c) < 0.0)    return  2;
  if(norm(b) < norm(c)) return -2;
  return 0.0;
}


#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
enum { OUT, ON, IN };
int contains(const vector<Point>& P, const Point& p)
{
  bool in = false;
  for (int i = 0; i < P.size(); ++i) {
    Point a = curr(P,i) - p, b = next(P,i) - p;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (a.det(b) < 0) in = !in;
    if (a.det(b) == 0 && a.dot(b) <= 0) return ON;
  }
  return in ? IN : OUT;
}

double x[3], y[3], px, py;

int main()
{
  while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> px >> py){
    vector<Point> P;
    rep(i, 3) P.pb(Point(x[i], y[i]));
    puts(contains(P, Point(px, py)) != IN ? "NO" : "YES");
  }

  return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

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

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

    char cs[4];

    REP(i,4)
    {
        cs[i] = s[i];
    }

    sort(cs, cs+4);

    if(cs[0]==cs[1] && cs[2]==cs[3] && cs[0] != cs[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
        

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *r, *l, *p;
};

Node *root, *NIL;

Node *treeMinimum(Node *x){
  while(x->l != NIL) x = x->l;
  return x;
}

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}

Node *treeSuccessor(Node *x){
  if(x->r != NIL) return treeMinimum(x->r);
  Node *y = x->p;
  while(y != NIL && x == y->r){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y, *x;

  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->l != NIL){
    x = y->l;
  }
  else{
    x = y->r;
  }

  if(x != NIL){
    x->p = y->p;
  }

  if(y->p == NIL){
    root = x;
  }
  else{
    if(y == y->p->l){
      y->p->l = x;
    }
    else{
      y->p->r = x;
    }
  }

if(y != z){
  z->key = y->key;
 }
free(y);
}

void insert(int k){
  Node *x = root,*y = NIL, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else{
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}


int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    cin >> com;
    if(com[0] == 'f'){
      scanf("%d", &x);
      Node *t = find(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com == "delete"){
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }
  return 0;
}


Measured memory_bytes: 21940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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) {
            // 入力
            int n = Integer.parseInt(in.next());
            String s[] = new String[n];
            for (int i = 0; i < n; i++) {
                s[i] = in.next();
            }
            char c[] = new char[10];
            for (int i = 0; i < n; i++) {
                c = s[i].toCharArray();
                Arrays.sort(c);
                s[i] = String.valueOf(c);
            }
            long ans = 0;
            long cnt = 0;
            Arrays.sort(s);
            String tmp = s[0];

            for (int i = 1; i < n; i++) {
                if (tmp.equals(s[i])) {
                    cnt++;
                    ans += cnt;
                } else {
                    cnt = 0;
                    tmp = s[i];
                }
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 51492
#include<iostream>
using namespace std;
int main(){
    char c;
    int count[26]={0},a,i;
    while(cin>>c){
        a=c-'a';
        if(a<0){
            a+=32;
        }
        count[a]++;
    }
    for(i=0;i<26;i++){
        cout<<(char)(i+'a')<<" : "<<count[i]<<endl;
    }
    return 0;
}
        

Measured memory_bytes: 1140
import bisect
from math import factorial


n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
p_c = [i for i in range(1, n+1)]
q_c = [i for i in range(1, n+1)]
ans_p = 1
ans_q = 1
for i in range(n-1):
    p_c.pop(p_c.index(p[i]))
    q_c.pop(q_c.index(q[i]))
    ans_p += (bisect.bisect_left(p_c, p[i])) * factorial(n - i - 1)
    ans_q += (bisect.bisect_left(q_c, q[i])) * factorial(n - i - 1)
print(abs(ans_p - ans_q))


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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  x--;
  map<int, int> a;
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    if (a[tmp] == 0) { a[tmp]++; }
  }

  int cost1 = 0;
  for (int i = x - 1; i >= 0; i--) {
    if (a[i] == 1) { cost1++; }
  }
  int cost2 = 0;
  for (int i = x + 1; i < n; i++) {
    if (a[i] == 1) { cost2++; }
  }
  cout << min(cost1, cost2) << endl;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int N=2e5+5;
ll a[N];
ll pos[N];
ll dp[N];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    repA(i,1,n)
    {
        cin>>a[i];
    }
    pos[1]=a[1];
    for(ll i=3;i<=n;i+=2)
    {
        pos[i]=a[i]+pos[i-2];
    }
    repA(i,2,n)
    {
        if(i%2)
        {
            dp[i]=max(dp[i-1],a[i]+dp[i-2]);
        }
        else
        {
            dp[i]=max(pos[i-1],a[i]+dp[i-2]);
        }
    }
    cout<<dp[n]<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 8344
<?php
fscanf(STDIN,"%d%d",$n,$x);
$l_li = explode(" ",trim(fgets(STDIN)));
$dis = 0;
$c = 1;
for($i=0;$i<$n;$i++){
  if($x<($dis+$l_li[$i])){
    break;
  }
  $dis += $l_li[$i];
  $c++;
}

echo $c;

Measured memory_bytes: 16236
import heapq

INF = float('inf')

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for b, cost in G[v]:
            if dist[b] > dist[v] + cost:
                dist[b] = dist[v] + cost
                heapq.heappush(h, (dist[b], b))
    return dist

n, x, y = map(int, input().split())

g = [[] for i in range(n)]

for i in range(n-1):
    g[i].append((i+1, 1))
    g[i+1].append((i, 1))

g[x-1].append((y-1, 1))
g[y-1].append((x-1, 1))

ans = [0] * n

for i in range(n):
    for d in dijkstra(n, g, i):
        ans[d] += 1

for item in ans[1:]:
    print(item // 2)



Measured memory_bytes: 120796
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 100010;
int x[N], y[N];

int main() {
    int n, w, h;
    cin >> n >> w >> h;
    while (n--){
        int i, j, p;
        cin >> i >> j >> p;
        x[max(0,i-p)]++;
        x[min(N-1,i+p)]--;
        y[max(0,j-p)]++;
        y[min(N-1,j+p)]--;
    }
    REP(i,w) x[i+1] += x[i];
    REP(i,h) y[i+1] += y[i];
    bool f1 = 1, f2 = 1;
    REP(i,w) if (x[i] < 1) f1 = 0;
    REP(i,h) if (y[i] < 1) f2 = 0;
    cout << (f1 || f2 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3884
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50 == X:
                cnt += 1
                
print(cnt)

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

int main(){
  int a;
  cin>>a;
  
  if(a==0){
  cout<<0<<endl;
  }
  if(a==1||a==10||a==100){
  cout<<1<<endl;
  }
  if(a==11||a==101||a==110){
  cout<<2<<endl;
  }
  if(a==111){
  cout<<3<<endl;
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "math.h"


int main()
{
	double a, b, C, S, L, h, rad;
	std::cin >> a >> b >> C;
	rad = C / 180.0 * 3.14159265358979;
	S = ((a * b) * sin(rad)) / 2;
	L = a + b + sqrt((a*a) + (b*b) - (2 * a * b * cos(rad)));
	h = b * sin(rad);
	std::cout << std::fixed << S << std::endl << std::fixed << L << std::endl << std::fixed << h << std::endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

ll eval(string &s) {
	ll a=0, ret=0;
	for (char ch : s)
		if(ch=='A') a++;
		else ret+=a;
	return ret;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	deque<char> dq;
	for (char ch : s) {
		if(dq.empty()) dq.push_back(ch);
		else {
			if(ch=='C'&&dq.back()=='B') dq.pop_back(), dq.push_back('D');
			else dq.push_back(ch);
		}
	}

	string t;
	while(!dq.empty())
		t+=dq.front(), dq.pop_front();
	ll ret=0;
	for (int i=0; i<t.size(); i++)
		if(t[i]=='B'||t[i]=='C')
			t[i]=' ';
	stringstream ss(t);
	string cur;
	while(ss>>cur)
		ret+=eval(cur);
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 1300
import sys
input = sys.stdin.readline
 
def f(_pts, p, q):
    pts = set(_pts[:])
    r = 0
 
    while len(pts) > 0:
        r += 1
        x = max(pts)
        while x in pts:
            pts.remove(x)
            x = (x[0]-p, x[1]-q)
 
    return r
 
################################################################################
 
n = int(input())
pts = []
for i in range(n):
    x, y = map(int, input().split())
    pts.append((x, y))
 
res = n
for i in range(len(pts)):
    for j in range(i+1, len(pts)):
        res = min(res, f(pts, -(pts[i][0]-pts[j][0]), -(pts[i][1]-pts[j][1])))
        res = min(res, f(pts, +(pts[i][0]-pts[j][0]), -(pts[i][1]-pts[j][1])))
        res = min(res, f(pts, -(pts[i][0]-pts[j][0]), +(pts[i][1]-pts[j][1])))
        res = min(res, f(pts, +(pts[i][0]-pts[j][0]), +(pts[i][1]-pts[j][1])))
 
print(res)

Measured memory_bytes: 46172
def solve():
    cs = [c for c in input()]
    for i in range(2 ** 3):
        symbols = ["+" if b == "0" else "-" for b in list('{:03b}'.format(i))] + [""]
        formula = "".join([x[0] + x[1] for x in zip(cs, symbols)])
        result = eval(formula)
        if result == 7:
            return formula + "=7"


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


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long k = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long count=1;
		if(a<b-2 && k-a-1>=0){
			count+=(k-a-1)/2;
			System.out.println(k+1+(b-2-a)*(count));
		}else{
			System.out.println(k+1);
		}
	}
}

Measured memory_bytes: 23892
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

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

	int n, x, y;
	cin >> n >> x >> y;
	vector<int> a(n);
	int b;
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			b = min(j - i, abs(x - i) + abs(y - j) + 1);
			a[b]++;
		}
	}

	for (int i = 1; i < n; i++) cout << a[i] << endl;



	return 0;
}


Measured memory_bytes: 3668
//#define TIMER_
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
// #define int long long
using ll = long long;
using ull = unsigned long long;
const long long mod = 1000000007;
long long pw[200200] = { 1 };

signed main() {
  fastio;
	map<pair<ll, ll>, pair<ll, ll> > chk;

	for (int i = 1; i < 200200; i++) pw[i] = (pw[i - 1] * 2) % mod;

	ll z = mod - 1;
	int n; cin >> n;
  while (n--){
	  ll a, b; cin >> a >> b;
		if (a == 0 && b == 0){ z++; continue; }
    else if (a == 0) {
      chk[make_pair(0, 1)].first++;
    } 
    else if (b == 0) {
      chk[make_pair(0, 1)].second++;
    }
    else {
      ll g = __gcd(abs(a), abs(b));
      a /= g; b /= g;
      if (a * b > 0) {
        chk[make_pair(abs(a),abs(b))].first++;
      } 
      else {
        chk[make_pair(abs(b),abs(a))].second++;
      }
    }
	}

	ll r = 1;
	for (auto& p : chk) {
		r = r * (pw[p.second.first] + pw[p.second.second] - 1) % mod;
	}

	cout << (z + r) % mod << "\n";
  
  #ifdef TIMER_
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  #endif
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define TMP 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int n;
	scanf("%d", &n);
	printf("%d\n", n * 800 - n / 15 * 200);
	return 0;
} 

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 0
dict = {}
for i in a:
    if(i in dict):
        dict[i] += 1
    else:
        dict[i] = 1
dict = sorted(dict.items(), reverse = True)
for i in dict:
    if(i[1] >= 2):
        if(ans):
            print(ans*i[0])
            exit()
        else:
            ans = i[0]
        if(i[1] >= 4):
            print(ans*i[0])
            exit()
print(0)


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

const int mod = 1000000007;

int f(int n)
{
	long long res = 1;
	for (int i = 1; i <= n; i++)
		res = res * i % mod;
	return res;
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	
	if (abs(n - m) > 1)
		printf("0\n");
	else 
	{
		int ans = 1LL * f(n) * f(m) % mod;
		if (m == n)
			ans = ans * 2 % mod;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
B = lr()
answer = 0
for i in range(N):
    a, b = A[i], B[i]
    answer += min(a, b)
    if a < b:
        remain = b - a
        add = min(A[i+1], remain)
        answer += add
        A[i+1] -= add

print(answer)


Measured memory_bytes: 76416
import collections
def main():

    N = int(input())
    A = list(map(int, input().split()))
    mod = pow(10, 9) + 7

    ones = [0 for _ in range(60)]

    for i in range(N):
        for j in range(60):
            if (A[i] >> j) % 2 == 1:
                ones[j] += 1
    ans = 0
    for j in range(60):
        ans += pow(2, j) * ones[j] * (N - ones[j])
        ans %= mod

    return ans % mod


if __name__ == '__main__':
    print(main())


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

int main(){
  int a,b;
  cin >> a >> b;
  vector<int> lake(b,0),distance(b,0);
  for(int i = 0;i<b;i++){
    cin >> lake[i];
  }
  distance[b-1]=a-lake[b-1]+lake[0];
  for(int i = 0;i<b-1;i++){
    distance[i]=lake[i+1]-lake[i];
  }  
  sort(distance.begin(),distance.end());
  cout << a-distance[b-1] << endl;
}
  



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    long long int b;
    cin>>a;
    long long int c[a];
    c[0]=2;
    c[1]=1;
    if(a==1) cout<<'1'<<endl;
    if(a>1){
    for(int i=0;i<a-1;i++){
        b=c[i]+c[i+1];
        c[i+2]=b;
        }
    cout<<b<<endl;
    }
}


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

#define rep(a,b) for(int ii=a;ii<b;ii++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'

int main()
{
  fst_io;
  ll n;
  string str;
  map<string,int> vi;
  vi["AC"]=0;
  vi["WA"]=0;
  vi["TLE"]=0;
  vi["RE"]=0;
  test()
  {
    cin>>str;
    vi[str]++;
  }
  cout<<"AC x "<<vi["AC"]<<endl;
  cout<<"WA x "<<vi["WA"]<<endl;
  cout<<"TLE x "<<vi["TLE"]<<endl;
  cout<<"RE x "<<vi["RE"]<<endl;
  return 0;
}

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

int main() {
	int n, k, d[10];
	cin >> n >> k;
	rep(i, k) {
		cin >> d[i];
	}
	for (int i = n; ; i++) {
		int j;
		for (j = 0; j < k; j++) {
			if (regex_search(to_string(i), regex(to_string(d[j])))) break;
		}
		if (j == k) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val X, Y, Z = sc.nextInt
    println(((X + Y) / (Y + Z) - 1: Int))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25804
#include<stdio.h>

int main(){
    int i,w,n,sp;
    scanf("%d\n%d",&w,&n);
    int mae[n],usiro[n],data[w];
    for(i=1;i<w+1;i++)data[i]=i;
    for(i=0;i<n;i++){
        scanf("%d,%d",&mae[i],&usiro[i]);
        sp=data[mae[i]];
        data[mae[i]]=data[usiro[i]];
        data[usiro[i]]=sp;
    }
    for(i=1;i<w+1;i++)printf("%d\n",data[i]);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
const string s="abcdefghijklmnopqrstuvwxyz";
const string S="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string ss[3];
  cin>>ss[0]>>ss[1]>>ss[2];
  string ans;
  for(int i=0;i<3;i++){
    for(int j=0;j<26;j++){
      if(ss[i].at(0)==s[j]){
        ans+=S[j];
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextDouble()) {
			System.out.println(floor(sc.nextDouble()));
		}
		sc.close();
	}
	
	static int floor(double v) {
		return (int) (Math.floor(v * v / 98) + 2);
	}
}

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

int N, K, L;
int p[200000], q[200000], r[200000], s[200000], par_r[200000], par_t[200000], rank_r[200000], rank_t[200000];

void initialization() {
  for (int i = 0; i < 200000; i++) {
    par_r[i] = i;
    par_t[i] = i;
    rank_r[i] = 0;
    rank_t[i] = 0;
  }
}

int find_root_r(int x) {
  if (par_r[x] == x) {
    return x;
  }
  else {
    return find_root_r(par_r[x]);
  }
}

int find_root_t(int x) {
  if (par_t[x] == x) {
    return x;
  }
  else {
    return find_root_t(par_t[x]);
  }
}

void unite_r(int x, int y) {
  x = find_root_r(x);
  y = find_root_r(y);
  if (x != y) {
    if (rank_r[x] > rank_r[y]) {
      par_r[y] = x;
    }
    else {
      par_r[x] = y;
      if (rank_r[x] == rank_r[y]) {
        rank_r[y]++;
      }
    }
  }
}

void unite_t(int x, int y) {
  x = find_root_t(x);
  y = find_root_t(y);
  if (x != y) {
    if (rank_t[x] > rank_t[y]) {
      par_t[y] = x;
    }
    else {
      par_t[x] = y;
      if (rank_t[x] == rank_t[y]) {
        rank_t[y]++;
      }
    }
  }
}

bool check_r(int x, int y) {
  return find_root_r(x) == find_root_r(y);
}

bool check_t(int x, int y) {
  return find_root_t(x) == find_root_t(y);
}

int main() {
  cin >> N >> K >> L;
  for (int i = 0; i < K; i++) {
    cin >> p[i] >> q[i];
  }
  for (int i = 0; i < L; i++) {
    cin >> r[i] >> s[i];
  }
  initialization();
  for (int i = 0; i < K; i++) {
    unite_r(p[i]-1, q[i]-1);
  }
  for (int i = 0; i < L; i++) {
    unite_t(r[i]-1, s[i]-1);
  }
  pair<int, int> t;
  map<pair<int, int>, int> u;
  for (int i = 0; i < N; i++) {
    t.first = find_root_r(i);
    t.second = find_root_t(i);
    u[t]++;
  }
  for (int i = 0; i < N; i++) {
    t.first = find_root_r(i);
    t.second = find_root_t(i);
    cout << u[t] << ' ';
  }
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
ll k,a,b;
cin >> k >> a >> b;
if(b-a<=2){
    cout << 1+k<<endl;
}
else {
ll bb = 1;
if(k<a-1){
    cout << k+1<<endl;
    return 0;
}
bb = a;

 bb+=(b-a)*((k-(a-1))/2);
 if ((k-(a-1))%2!=0)bb++;
 cout<< bb << endl;
}
}







Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, x;
    cin >> n >> x;
    
    if (x == 1 || x == 2 * n - 1) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        if (n == x) {
            for (int i = 0; i < 2 * n - 1; i++) cout << i + 1 << endl;
        }
        else if (n < x) {
            for (int i = 0; i < 2 * n - 1; i++)
            cout << (i + x - n) % (2*n - 1) + 1 << endl;
        }
        else {
            for (int i = 0; i < 2 * n - 1; i++)
            cout << (i + (2 * n - 1) - n + x) % (2*n - 1) + 1 << endl;
        }
    }
    
    
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,c=0;
    cin>>n;
    for(int i=2;i<=sqrt(n);i++)
    {
        ll x=n;
        if(n%i==0)
        {
           while(x%i==0)
           {
              x=x/i;
           }
           if(x%i==1)
           {
               c++;
           }

           x=n;
           ll d=n/i;
           if(i!=d){
           while(x%d==0)
           {
              x=x/d;
           }
           if(x%d==1)
           {
               c++;
           }
           }
        }
    }

    for(int i=1;i<=sqrt(n-1);i++)
    {
        if((n-1)%i==0)
        {
            if(i!=(n-1)/i)
            {
                c=c+2;
            }
            else
            {
                c++;
            }
         //   cout<<i<<" "<<((n-1)/i)<<" "<<"\n";
        }
    }
    cout<<c;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	var maxA, maxB int
	for i := 0; i < N; i++ {
		a, b := ReadInt(), ReadInt()
		if a > maxA {
			maxA = a
			maxB = b
		}
	}
	fmt.Println(maxA + maxB)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main() {
  int A, B, C, x;
  cin >> A >> B >> C >> x;
  
  int ans = 0;
  for(int a = 0; a <= A; a++) {
    
    for(int b = 0; b <= B; b++) {
      
      for(int c = 0; c <= C; c++) {
         
        int total = 500 * a + 100 * b + 50 * c;
        if(total == x) ans++;
      }
    }
  }
  cout << ans << endl;
}  


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

typedef long long ll;

const ll mod = 1e9 + 7;

ll dp[100005];

ll pref[100005];

ll add(ll a, ll b)
{
    a += b;
    return a % mod;
}


ll sub(ll a, ll b)
{
    a -= b;
    if(a < 0)
        a += mod;
    return a % mod;
}

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


    dp[0] = 1;
    for(int i = 0; i < n; i++)
    {
        int a;
        scanf("%d",&a);
        pref[0] = dp[0];
        for(int j = 1; j <= k; j++)
        {
            pref[j] = add(pref[j-1], dp[j]);
            //cout << pref[j] << ' ';
        }
        for(int j = 0; j <= k; j++)
        {
            dp[j] = sub(pref[j], ( j - a - 1 < 0 ? 0 : pref[j - a -1]));
        }
    }
    printf("%lld\n",dp[k]);
    return 0;
}

Measured memory_bytes: 1792