akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 310;
int N,M, A[maxn][maxn];

bool P(const int x)
{
    map< int,set<int> > game;
    VI J(N+1,1), vis(N+1,false), canuse(M+1,true);
    while (true) {
        FOR(i,1,N+1) if (!vis[i]) {
            const int j = J[i];
            if (j >= M)
                return false;
            const int g = A[i][j];
            if (canuse[g]) {
                game[g].insert(i);
                vis[i] = true;
                if (game[g].size() > x) {
                    canuse[g] = false; 
                    FOR_ALL(p,game[g]) {
                        vis[*p] = false; J[*p]++;
                    }
                }
            }
            else
                J[i]++;
        }
        int cnt = 0;
        FOR(i,1,N+1) if (vis[i])
            cnt++;
        if (cnt == N)
            break;
    }
    return true;
}

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    while (cin >> N >> M) {
        FOR(i,1,N+1) FOR(j,1,M+1)
            cin >> A[i][j];
        int lo = 1, hi = N;
        while (lo < hi) {
            const int mid = (hi+lo)/2;
            if (P(mid))
                hi = mid;
            else
                lo = mid+1;
        }
        cout << lo << endl;
    }
    return 0;
}


Measured memory_bytes: 4864
#include<stdio.h>

int main()

{

  int a, b, res;
  char ch;
  scanf ("%d ",&a);
 scanf("%c", &ch);
 scanf("%d", &b);


  if (ch=='+')
  {
    res=a+b;
    printf("%d",res);
  }

  else
  {
    res=a-b;
    printf("%d",res);
  }


  return 0;

}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int n, m, a[100001], b[100001];

int lower_bound(int key) {
    int l = -1, r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (a[mid] >= key) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> m;
    int ans = 0;
    for (int i = 0; i < m; i++) {
        cin >> b[i];
        int index = lower_bound(b[i]);
        ans += (a[index] == b[i] ? 1 : 0);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s;
  cin >> s;
  if(s<="2019/04/30")cout << "Heisei" << endl;
  else cout << "TBD" << endl;

}

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

const int INF=100000010;

int main(){
	string s,t;
	cin>>s>>t;
	int ans=INF;
	for(int i=0;i<s.size()-t.size()+1;i++){
		int count=0;
		for(int j=0;j<t.size();j++){
			if(s.at(i+j)!=t.at(j)){
				count++;
			}
		}
		ans=min(ans,count);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3604
n=int(input())
p=list(map(float,input().split()))
dp=[[0]*-~n for _ in range(n)]
dp[0][1]=p[0]
dp[0][0]=1-p[0]
for i in range(1,n):
  dp[i][0]=dp[i-1][0]*(1-p[i])
  for j in range(1,n+1):
    dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i])
print(sum(dp[-1][-~n//2:]))

Measured memory_bytes: 259720
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        string str;
        while ((str = Console.ReadLine()) != "-1 -1 -1")
        {
            string[] str2 = str.Split(' ');
            int a = int.Parse(str2[0]);
            int b = int.Parse(str2[1]);
            int c = int.Parse(str2[2]);
            if (a == -1 || b == -1)
            {
                Console.WriteLine("F");
            }
            else if (a + b >= 80)
            {
                Console.WriteLine("A");
            }
            else if (a + b >= 65)
            {
                Console.WriteLine("B");
            }
            else if (a + b >= 50)
            {
                Console.WriteLine("C");
            }
            else if (a + b >= 30)
            {
                if (c >= 50)
                {
                    Console.WriteLine("C");
                }
                else
                {
                    Console.WriteLine("D");
                }
            }
            else
            {
                Console.WriteLine("F");
            }
        }
    }
}


Measured memory_bytes: 5296
#include<cstdio>
#include<iostream>
int main(){
    int ap,bp,A=0,B=0;
    for(int i=0;i<4;i++){
        scanf("%d",&ap);
        A+=ap;
    }

    for(int i=0;i<4;i++){
        scanf("%d",&bp);
        B+=bp;
    }
    if(A>B)
        printf("%d\n",A);
    else
        printf("%d\n",B);
    return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int n, m; cin >> n >> m;
    int mi = 1, ma = 100000;
    rep(i, m) {
        int l, r; cin >> l >> r;
        chmax(mi, l);
        chmin(ma, r);
    }
    cout << max(0, ma - mi + 1) << endl;
}

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

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

using namespace std;

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

	priority_queue<pair<int,int>> Q;
	rep(i,n){
		int a,b; scanf("%d%d",&a,&b);
		Q.emplace(a,0);
		Q.emplace(b,1);
	}

	int ans=0;
	while(h>0){
		auto x=Q.top();
		if(x.second==0){
			ans+=(h+x.first-1)/x.first;
			h=0;
		}
		else{
			ans++;
			h-=x.first;
			Q.pop();
		}
	}
	printf("%d\n",ans);

	return 0;
}


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

paths = set()
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        paths.add((i, j))

if n % 2 == 0:
    for i in range(1, n + 1):
        path = (min(i, n - i + 1), max(i, n - i + 1))
        paths.discard(path)
else:
    for i in range(1, n + 1):
        path = (min(i, n - i), max(i, n - i))
        paths.discard(path)

print(len(paths))
for path in paths:
    print('{0} {1}'.format(path[0], path[1]))

Measured memory_bytes: 42472
N = int(input())
A, B = map(int, input().split(" "))
P = list(map(int, input().split(" ")))

q_counts = [0, 0, 0]
for p in P:
    if p <= A:
        q_counts[0] += 1
    elif A+1 <= p <= B:
        q_counts[1] += 1
    elif B+1 <= p:
        q_counts[2] += 1

print(min(q_counts))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N,Q;
    cin >> N >> Q;
    string str; 
    cin >> str;

    vector<int> s(N+1,0);
    for(int i=0; i<N; i++){
        if(i+1<N && str.at(i)=='A' && str.at(i+1)=='C') s[i+1]=s[i]+1;
        else s[i+1]=s[i];
    }
    vector<int> ans;
    for(int q=0; q<Q; q++){
        int l,r; cin >> l >> r;
        l--;r--;
        ans.push_back(s[r]-s[l]);
    }
    int n = ans.size();
    for(int i=0; i<n; i++){
        cout << ans.at(i) << endl;
    }
}

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

int main(){
   int N;
   cin >> N;
   long int ans=0;
   
   for(int i=1;i<=N;i++){
       if(i%3==0&&i%5==0){
       }
       else if(i%3==0){
       }
       else if(i%5==0){
       }else{
        ans+=i;
        }
   }

   cout << ans << endl;

    return 0;
}

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

bool Judge(string s){
  int len = s.size();
  for (int i=0; i<len; i++){
    if (s[i] != s[len-1-i]) return false;
  }
  return true;
}

int main(){
  string s;
  cin>>s;
  string s1 = s.substr(0,(s.size()-1)/2);
  string s2 = s.substr((s.size()+1)/2, (s.size()-1)/2);
  //cout << s1 << endl;
  //cout << s2 << endl;
  if (Judge(s1)==true && Judge(s2)==true && Judge(s)) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3612
n = int(input())
h = {}
max_num = 0
for _ in range(n):
    s = input()
    if s not in h:
        h[s] = 0
    h[s] += 1
    if h[s] > max_num:
        max_num = h[s]

answer = []
for k in h.keys():
    if h[k] == max_num:
        answer.append(k)

answer.sort()
for a in answer:
    print(a)


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

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

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

    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        if ((i % 3 != 0) && (i % 5 != 0) && (i % 15 != 0)) ans += i;
    }
    cout << ans << endl;

}



Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int N, c = 0, ns;
	string n, s;
	cin >> N >> n;
	ns = n.length();
	while (N--){
		string s;
		cin >> s;
		if ([&](){
			for (int i = 0; i < s.length(); i++)
				if (s[i] == n[0])
					for (int p = 1;; p++){
						if (i + p*(ns - 1) >= s.length()) break;
						for (int h = 1; h < ns; h++)
							if (s[i + p * h] != n[h]) break;
							else if (h == ns - 1) return true;
					}
			return false;
		}()
			) c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1208
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	word := s
	for i := 0; i < len(s); i++ {
		fst := word[:1]
		str := word[1:]
		word = str + fst
		if word == t {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

using namespace std;
using ll = long long;

int main()
{
    int L,R,d;
    cin >> L >> R >> d;
    int res = 0;
  	for(int i=L; i<=R; i++){
      if(i%d==0)res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if(a==0){
		cout << "1" << endl;
	}
	if(b==0){
		cout << "2" << endl;
	}
	if(c==0){
		cout << "3" << endl;
	}
	if(d==0){
		cout << "4" << endl;
	}
	if(e==0){
		cout << "5" << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const line_one = input[0].split(" ");
  const line_two = input[1].split(" ");

  for (const i in line_two) {
    line_two[i] = parseInt(line_two[i]);
  }

  let ans = 0;
  line_two.sort(f);
  for (let i = 0; i < line_one[1]; i++) {
    ans = ans + line_two[i];
  }
  console.log(ans);
}
var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 30088
require 'pp'

# 入力値を文字列で返却する
def gets_s()
  gets.chomp.chars
end

sa_list = gets_s
sb_list = gets_s
sc_list = gets_s

card = sa_list.shift
while true
  case card
  when "a"
    if sa_list.empty?
      puts "A"
      exit
    end
    card = sa_list.shift
  when "b"
    if sb_list.empty?
      puts "B"
      exit
    end
    card = sb_list.shift
  when "c"
    if sc_list.empty?
      puts "C"
      exit
    end
    card = sc_list.shift
  end

end

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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)
#define IN(i,a,b) (a<=i&&i<=b)

const ll mod = 998244353;

ll modpow(ll a, ll b) {
	return b?modpow(a*a%mod,b/2) * (b&1?a:1) % mod:1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; ll a,b; ll K;
	cin>>n>>a>>b>>K;
	ll fac[n+1], inv[n+1];
	f(i,0,n+1) fac[i] = i?fac[i-1]*i%mod:1;
	inv[n] = modpow(fac[n],mod-2);
	fr(i,0,n) inv[i] = inv[i+1]*(i+1)%mod;
	function<ll(int)> ncr = [&](int r) {
		if (r<0||r>n) return 0;
		return int(fac[n]*inv[r]%mod*inv[n-r]%mod);
	};
	ll ans = 0;
	f(k,0,n+1) if (a*k<=K){
		ll kp = (K-a*k)/b;
		if (a*k+b*kp != K)
			continue;
		ans = (ans+1LL*ncr(k)*ncr(kp)%mod)%mod;
	}
	cout << ans << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 4992
import math

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    A = list(mi())
    Q = ii()
    BC = [map(int, input().split()) for _ in range(Q)]
    B, C = [list(i) for i in zip(*BC)]
    ans = sum(A)

    dic = {i+1: 0 for i in range(10**5)}
    for v in A:
        dic[v] += 1
    for i in range(Q):
        k = dic[B[i]]
        ans += k*(C[i]-B[i])
        dic[B[i]] -= k
        dic[C[i]] += k

        print(ans)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 126548
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from itertools import combinations

N = ii()
A = li()
cnt = 0

for c in combinations(A, 3):
    c = sorted(c)
    if c[0] != c[1] and c[1] != c[2]:
        if c[0] + c[1] > c[2]:
            cnt += 1

print(cnt)

Measured memory_bytes: 9232
from itertools import combinations_with_replacement as combi

N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
l = [i+1 for i in range(M)]
point = 0

for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

for v in combi(l, N):
    tmp = 0
    for j in range(Q):
        if v[b[j]-1] - v[a[j]-1] == c[j]:
            tmp += d[j]
    point = max(point, tmp)

print(point)

Measured memory_bytes: 9208
#include <iostream>
using namespace std;
int main()
{
	int n, a, c = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		if ((i % 2 == 1) & (a % 2 == 1))
			c++;
	}
	cout << c << endl;
	return 0;
}

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

const int N = 222;

string adj[N];

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> adj[i];
    int ans = -1;
    for(int i = 0; i < n; i++) {
        vector<int> mark(n);
        vector<int> nodes;
        nodes.push_back(i);
        mark[i] = 1;
        int lvl = 1;
        while(!nodes.empty()) {
            ++lvl;
            vector<int> new_nodes;
            for(int u : nodes) {
                for(int v = 0; v < n; v++) {
                    if(adj[u][v] == '1' && !mark[v]) {
                        new_nodes.push_back(v);
                        mark[v] = lvl;
                    }
                }
            }
            nodes = new_nodes;
        }
//        for(int u = 0; u < n; u++) {
//            cout << u << " -> " << mark[u] << endl;
//        }
//        cout << "------------" << endl;
//        cout << "level---> " << lvl << endl;
        bool good = true;
        for(int u = 0; u < n; u++) {
            for(int v = 0; v < n; v++) {
                if(adj[u][v] == '1') {
                    if(abs(mark[u]-mark[v]) != 1) good = false;
                }
            }
        }
        if(good) ans = max(ans, lvl-1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int x, a; cin >> x >> a;
	cout << (x < a ? 0 : 10) << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define INF 30000000000000000ll
#define fi first
#define sec second
#define pb push_back
ll dist[100100];
ll ava[100100];
vector<P> vec;
int N,M;
ll C;
struct edge
{
	int to;
	ll cost;
	edge(int to,ll cost):to(to),cost(cost){}
};
vector<edge> g[100100];
void dijkstra()
{
	for(int i=0;i<N;i++)dist[i]=INF;
	dist[0]=0;
	priority_queue<P,vector<P>,greater<P> > q;
	q.push(P(0ll,0));
	while(!q.empty())
	{
		P a = q.top();
		q.pop();
		int v = a.sec;
		for(int i=0;i<g[v].size();i++)
		{
			edge e = g[v][i];
			if(dist[e.to]>dist[v]+e.cost)
			{
				dist[e.to]=dist[v]+e.cost;
				q.push(P(dist[e.to],e.to));
			}
		}
	}
	return;
}
int main()
{
	ll sum = 0ll;
	scanf("%d %d %lld",&N,&M,&C);
	for(int i=0;i<M;i++)
	{
		int a,b;
		ll c;
		scanf("%d %d %lld",&a,&b,&c);
		a--;b--;
		sum+=c;
		g[a].pb(edge(b,c));
		g[b].pb(edge(a,c));
	}
	dijkstra();
	for(int i=0;i<N;i++)vec.pb(P(dist[i],i));
	sort(vec.begin(),vec.end());
	ll ans = INF;
	for(int i=0;i<N;i++)
	{
		int v = vec[i].sec;
		//cout << v << endl;
		sum -= ava[v];
		ans = min(C*vec[i].fi+sum,ans);
		//cout << C*vec[i].fi << ' ' << sum << endl;
		for(int j=0;j<g[v].size();j++)
		{
			edge e = g[v][j];
			ava[e.to]+=e.cost;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 17432
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let x : i32 = get_one();
    println!("{}", if x < 1200 {"ABC"} else {"ARC"});
}


Measured memory_bytes: 4352
from bisect import bisect
L=[0]*1112
y=[pow(i,3) for i in range(1,1111)]
for z in range(1,1112):
    z3=pow(z,3)
    maxInt=0
    for x in range(1,z):
        x3=pow(x,3)
        diff=z3-x3
        y3=y[bisect(y,diff)-1]
        maxInt=max(maxInt,x3+y3)
    L[z]=z3-maxInt
while True:
    z=input()
    if z==0:break
    print L[z]

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

int main()
{
    int group_a[] = {1, 3, 5, 7, 8, 10, 12};
    int group_b[] = {4, 6, 9, 11};
    int group_c[] = {2};

    int x, y;
    cin >> x >> y;

    int xs[] = {
        (bool)count(begin(group_a), end(group_a), x),
        (bool)count(begin(group_b), end(group_b), x),
        (bool)count(begin(group_c), end(group_c), x)};
    int ys[] = {
        (bool)count(begin(group_a), end(group_a), y),
        (bool)count(begin(group_b), end(group_b), y),
        (bool)count(begin(group_c), end(group_c), y)};

    for (int i = 0; i < 3; i++)
    {
        if (xs[i] && ys[i])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if((a+b)%3==0||a%3==0||b%3==0) 
    cout<<"Possible"<<endl;
    else 
    cout<<"Impossible"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
Aodd = True
Bodd = True
Codd = True
if A%2 == 0:
  Aodd = False
if B%2 == 0:
  Bodd = False
if C%2 == 0:
  Codd = False
if Aodd and Bodd and Codd == True:
  print(min(A*B,B*C,C*A))
else:
  print(0)
  

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

const int MAX_N = 8;
int N,A,B,C;
vector<int> l(MAX_N);

int dfs(int Ts, int a, int b, int c){
  if(Ts == N){
    if(a == 0 || b == 0 || c == 0) return 99999999;
    return abs(a - A) + abs(b - B) + abs(c - C) - 30;
  } else {
    // Cost計算
    int notUse = dfs(Ts +1,a,b,c);
    int useForA = dfs(Ts +1,a+l[Ts],b,c) + 10;
    int useForB = dfs(Ts +1,a,b+l[Ts],c) + 10;
    int useForC = dfs(Ts +1,a,b,c+l[Ts]) + 10;
    return min({notUse,useForA,useForB,useForC});
  }
}

int main(){
  cin >> N >> A >> B >> C;
  for(int i=0;i<N;i++) cin >> l[i];
  cout << dfs(0,0,0,0) << endl;;
}

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

li = []

for i,n in enumerate(range(a)):
    c,d = map(int,input().split())
    if b >= d:
        if li != []:
            if li[0] > c:
                li = [c,d]
        else:
            li = [c,d]

if li == []:print("TLE")
else:print(li[0])


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 62;

lli d;
lli b[e3];
lli b_[e3];
lli sub[10][10];
lli cnt[10];
lli cnt_[10];
lli ans;

lli solve(lli x){
  lli ret = 1;
  for(lli r = x-1,l = 0;r >= l;r--,l++){
    if(b_[r] != (b_[l]*(-1))) return 0;
    if(r == x-1) ret *= cnt_[abs(b_[r])];
    else ret *= cnt[abs(b_[r])];
  }
  // for(lli i = 0;i < x;i++) cerr << b_[i] << " ";
  // cerr << endl;
  return ret;
}

int main(){
  for(lli i = 0;i < 10;i++){
    for(lli j = i;j < 10;j++){
      cnt[j-i]++;
    }
  }
  for(lli i = 1;i < 10;i++){
    for(lli j = i;j < 10;j++){
      cnt_[j-i]++;
    }
  }
  cin >> d;
  lli d_;
  lli x = 0;
  d_ = d;
  while(d_ > 0){
    b[x] = d_%10;
    d_ /= 10;
    x++;
  }
  for(lli i = x;i <= 20;i++){
    for(lli bit = 0;bit < (1 << i);bit++){
      lli down = 0;
      for(lli j = i-1;j >= 0;j--){
        if((bit&(1<<j)) != 0){
          b_[j] = 1+b[j]-down;
          down = 10;
        }else{
          b_[j] = b[j]-down;
          down = 0;
        }
      }
      if(down == 10) continue;
      ans += solve(i);
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll c[100] = {};
	ll t[100] = {};
	ll N, T; cin >> N >> T;
	ll minV = 1e10;
	rep(i, 0, N) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			minV = min(minV, c[i]);
		}
	}
	if (minV == 1e10) {
		cout << "TLE" << endl;
		return 0;
	}
	cout << minV << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int i, j, a, b,count=0;

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

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

typedef long long int lli;

const lli maxn = lli(1e5)+5, MOD = lli(1e9)+7;

lli a[maxn], fac[maxn], invfac[maxn], loc[maxn];

lli modpow(lli a, lli b)
{
	if(b == 0) return 1;
	else if(b == 1) return a;
	else
	{
		lli res = modpow(a, b/2)%MOD;
		res *= res;
		res %= MOD;
		if(b%2) res *= a;
		return res;
	}
}

lli c(lli n, lli k)
{
	if(k > n) return 0;
	return ((fac[n]*invfac[k])%MOD*invfac[n-k])%MOD;
}

int main(void)
{
	lli n, d;
	scanf("%lld", &n);

	fac[0] = 1, invfac[0] = modpow(1, MOD-2)%MOD;
	for(lli i = 1;i <= n+5;i++)
	{
		fac[i] = (i*fac[i-1])%MOD;
		invfac[i] = modpow(fac[i], MOD-2)%MOD;
	}

	for(lli i = 1;i <= n+1;i++) scanf("%lld", &a[i]);

	for(lli i = 1;i <= n+1;i++)
	{
		if(loc[a[i]] != 0)
		{
			d = i-loc[a[i]]+1;
			break;
		}
		loc[a[i]] = i;
	}


	for(lli k = 1;k <= n+1;k++)
	{
		lli res = c(n+1, k)%MOD;
		//cout << res << "\n";
		res -= c(n+1-d, k-1)%MOD;
		res = (res%MOD+MOD)%MOD;
		printf("%lld\n", res);
	}
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define ASC_ORDER		(1)
#define DES_ORDER		(0)

#define MAX_ARRAY_NUM	(9)

void sort(char *array, int op);
void swap(char *a, char *b);
int my_atoi(char *val);

int main(void)
{
	int n;
	char input[MAX_ARRAY_NUM], min[MAX_ARRAY_NUM], max[MAX_ARRAY_NUM];
	
	scanf("%d", &n);
	
	while (n--){
		scanf("%s", input);
		
		memcpy(min, input, sizeof(input));
		memcpy(max, input, sizeof(input));
		
		sort(min, ASC_ORDER);
		sort(max, DES_ORDER);
		
		printf("%d\n", my_atoi(max) - my_atoi(min));
	}
	
	return (0);
}

void sort(char *array, int op)
{
	int i, j;
	
	swap((array + 0), (array + 1));
	
	for (i = 0; i < MAX_ARRAY_NUM - 1; i++){
		for (j = MAX_ARRAY_NUM - 2; j > 0; j--){
			
			switch (op){
				case ASC_ORDER:
					if (*(array + j) < *(array + j - 1)){
						swap((array + j), (array + j - 1));
					}
					break;
				
				case DES_ORDER:
					if (*(array + j) > *(array + j - 1)){
						swap((array + j), (array + j - 1));
					}
					break;
				
				default:
					//do nothing
					break;
			}
			
		}
	}
}

void swap(char *a, char *b)
{
	char tmp;
	
	tmp = *a;
	*a = *b;
	*b = tmp;

}

int my_atoi(char *val)
{
	int ret;
	int digit;
	int i;
	
	ret = 0;
	for (i = MAX_ARRAY_NUM - 2, digit = 1; i >= 0; i--, digit *= 10){
		ret += (*(val + i) - '0') * digit;
	}
	
	return (ret);
}


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

int main() {
  int x, legs, crane, turtle, sum;
  string result;
  
  cin >> x;
  cin >> legs;
  
  result = "No";
  
  for(int i=1;i<x+1;i++) {
    crane = i;
    turtle = x-i;
    sum = crane * 2 + turtle * 4;
    if(sum == legs) {
		result = "Yes";
     	break;
    }
    turtle = i;
    
    crane = x-i;
        sum = crane * 2 + turtle * 4;
    if(sum == legs) {
		result = "Yes";
     	break;
    }
  }
  
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		int a, b, c, t;
		Scanner input = new Scanner(System.in);
		a = input.nextInt();
		b = input.nextInt();
		c = input.nextInt();
		if(a > b){
			t = a;
			a = b;
			b = t;
		}
		if(b > c){
			t=b;
			b=c;
			c=t;
		}
		if(a > b){
			t = a;
			a = b;
			b = t;
		}
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 26244
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
void solve()
{
	string str;
	cin>>str;
	string tmp=str;
	reverse(ALL(str));
	ll fg=0;
	ll n=SZ(str);
	if(str==tmp)
	{
		str=tmp;
		string s1;
		s1=str.substr(0,(n-1)/2);
		tmp=s1;
		//cout<<s1<<endl;
		reverse(ALL(s1));
		if(s1==tmp)
		{
			s1=str.substr((n+3)/2-1,n);
			//cout<<s1<<"yo"<<endl;
			tmp=s1;
			reverse(ALL(s1));
			if(s1==tmp)
				fg=1;
		}
	}
	if(fg==1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return;
}
int main()
{
	
	ll t=1;
	//rl(t);

	//cin>>t;
	//scanf()
	while(t--)
	{
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    ll n,d,x,y,count=0;
    scanf("%lli %lli",&n,&d);
    fr(i,0,n) {
        scanf("%lli %lli",&x,&y);
        ll XY = x*x+y*y;
        ll D = d*d;
        if (XY <= D) {
            count++;
        }
    }
    printf("%lli",count);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n,ans = 1;
  cin >> n;

  int ma = 0;
  for(int i = 1; i <= n; i++) {
    int cnt = 0;
    int t = i;
    for(int j = 0; j < n; j++) {
      if(t % 2 == 0) {
        cnt++;
        t /= 2;
      }
      else break;
    }
    if(ma < cnt) {
      ma = cnt;
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cstdint>
#include <climits>

using namespace std;

int main(void)
{
  int W, H, N;
  cin >> W >> H >> N;
  int le = 0, ri = W, lo = 0, up = H;

  int x, y, a;
  for(int i = 0; i < N; i++){
    cin >> x >> y >> a;
    switch(a){
      case 1:
        le = max(le, x);
        break;

      case 2:
        ri = min(ri, x);
        break;

      case 3:
        lo = max(lo, y);
        break;

      case 4:
        up = min(up, y);
        break;
    }
  }
  int w = (ri - le) > 0 ? (ri - le) : 0;
  int h = (up - lo) > 0 ? (up - lo) : 0;
  cout << w*h << endl;



  return 0;
}
  

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

using namespace std;

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

    for (long long i = 1; i < 100000; ++i) {
        if (i * i > n) {
            cout << (i - 1) * (i - 1) << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int D, G;
    cin >> D >> G;
    vector<int> pi(D, 0);
    vector<int> ci(D, 0);
    int max_score = 0;
    for(int i = 0; i < D; i++) {
        cin >> pi[i] >> ci[i];
        max_score += (i+1) * pi[i];
        ci[i] /= 100;
        max_score += ci[i];
    }
    // cout << max_score << endl;
    vector<int> dp(max_score+1, 1e8);
    dp[0] = 0;
    for(int i = 0; i < D; i++) {
        for(int j = max_score; j >= 0; j--) {
            for(int k = 1; k < pi[i]; k++) {
                if (j - (i+1)*k >= 0)
                    dp[j] = min(dp[j], dp[j-(i+1)*k] + k);
                else
                    break;
            }
            if (j - (i+1)*pi[i]-ci[i] >= 0)
                dp[j] = min(dp[j], dp[j-(i+1)*pi[i]-ci[i]]+pi[i]);
        }
    }
    for(int i = max_score-1; i >= 0; i--) {
        dp[i] = min(dp[i], dp[i+1]);
        // cout << "i = " << i << ", # = " <<dp[i] << endl;
    }
    cout << dp[G/100] << endl;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int r,c,sum,total;
    cin>>r>>c;
    total=0;
    int lst[r][c];
    for (int a=0;a<r;a++){
        sum=0;
        for (int b=0;b<c;b++){
            int num;
            cin>>num;
            lst[a][b]=num;
            cout<<num<<" ";
            sum=sum+num;
        }
        cout<<sum<<endl;
    }for(int d=0;d<c;d++){
        sum=0;
        for (int e=0;e<r;e++){
            sum=sum+lst[e][d];
            total=total+lst[e][d];
        }cout<<sum<<" ";
    }cout<<total<<endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n;
  cin >> n;
  set<int> num;
  int a;
  REP(i, n)
  {
    cin >> a;
    num.insert(a);
  }
  int k = (int)num.size();
  cout << ((k % 2 == 0) ? k - 1 : k) << endl;
  return 0;
}


Measured memory_bytes: 4992
from itertools import permutations

S = input()

def is_passed(s, ws):
    for w in ws:
        s = ''.join(s.split(w))
        if len(s) == 0:
            return True
    return False

def main():
    l = ['dreamer', 'eraser', 'dream', 'erase']
    pm = permutations(l, len(l))
    passed = False
    for ws in pm:
        passed = is_passed(S, ws)
        if passed:
            break
    print('YNEOS'[not passed::2])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3680
#pragma warning(disable:4996)
#include <stdio.h>
#include <math.h>
int d[1001000];
int main()
{
	int n;
	scanf("%d", &n);
	d[1] = 1;
	for (int i = 2; i <= 1000000; i++)
	{
		if (d[i]) continue;
		for (int j = 1; j * i <= 1000000; j++) d[i * j] = i;
	}
	int ans = 0;
	for (int i = 1; i <= n-1; i++)
	{
		int tmp = 1;
		int c = i;
		while (d[c] != c)
		{
			int p = d[c];
			int cnt = 0;
			while (c % p == 0) c /= p, cnt++;
			tmp *= (cnt + 1);
		}
		if (c == 1);
		else tmp *= 2;
		ans += tmp;
	}
	printf("%d", ans);
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)2e5 + 9;
vector<pii> T[N];
int d[N];
int c[N];
int b[N];
vector<int> R[N];

void dfs(int u){
  for(auto x : R[u]){
    if(b[x] == -1){
      b[x]=1-b[u];
      dfs(x);
    }
  }
}

int main(){
  fastIO;
  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= n; i ++ ){
    cin >> d[i];
    b[i]=-1;
    c[i]=0;
  }
  int u, v;
  for(int i = 1; i <= m; i ++ ){
    cin >> u >> v;
    T[u].push_back(mp(v,i));
    T[v].push_back(mp(u,i));
  }
  int id, ed;
  for(int i = 1; i <= n; i ++ ){
    id = -1,ed=-1;
    for(auto x : T[i]){
      if(id == -1 || d[x.fi] < d[id]){
        id = x.fi;
        ed = x.se;
      }
    }
    if(d[id] > d[i]){
      cout << -1;
      return 0;
    }
    c[ed] = d[i];
    R[i].push_back(id);
    R[id].push_back(i);
  }
  for(int i = 1; i <= n; i ++ ){
    if(b[i]==-1){
      b[i]=0;
      dfs(i);
    }
  }
  for(int i = 1; i <= n; i ++ ){
    if(b[i]==0){
      cout << "W";
    }
    else{
      cout << "B";
    }
  }
  cout << "\n";
  for(int i = 1; i <= m ; i ++ ){
    if(c[i]==0) c[i]=(int)1e9;
    cout << c[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 23040
N=int(input())
x=[input().split() for _ in range(N)]
count=0
#print(N,x)
for i in range(N):
    x[i][0]=float(x[i][0])

for i in range(N):
    if x[i][1]=="BTC":
        count=count+380000.0*x[i][0]
    else:
        count = count + x[i][0]
print(count)

Measured memory_bytes: 38704
N = int(input())
X = list(map(int, input().split()))

min_P = 0
min_cost = float('inf')
for P in range(1, 101):
    cost = 0
    for Xi in X:
        cost += (Xi-P)**2
    if min_cost > cost:
        min_cost = cost
        min_P = P
print(min_cost)

Measured memory_bytes: 3060
# n blue card
n = int(input())
s = [input() for _ in range(n)]

# m red card
m = int(input())
t = [input() for _ in range(m)]

best = -200

for w in set(s + t):
    r = sum([1 for _ in s if _ == w]) - sum([1 for _ in t if _ == w])
    if r > best:
        best = r

if best < 0:
    best = 0
    
print(best)


Measured memory_bytes: 3060
#include <cstdio>
#include <set>

bool valid(int N, const std::set<int>& D) {
  for (int i = N; i; i /= 10)
    if (D.count(i % 10)) return false;

  return true;
}

int main() {
  int N, K;
  scanf("%d %d", &N, &K);

  std::set<int> D;
  for (int i = 0; i < K; ++i) {
    int d;
    scanf("%d", &d);
    D.insert(d);
  }

  while (!valid(N, D)) ++N;
  printf("%d\n", N);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,ans=0;
	cin>>n;
	char s[n+1];
	cin>>s;
	for(int i=0; i<=n-3; i++){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

#include <iostream>

int main()
{
	int A, B, T;
	cin >> A >> B >> T;

	int ans = (T/A)*B;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
	using namespace std;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
	const int N = 1 << 20;
	const int MOD = 1e9 + 7;
	typedef long long int ll;
	priority_queue< pair< int, int > > pq;
	vector< pair<int,int> >vp;
	#define f(a, n) for(int i = a; i  < n ; i++) 
	//#define endl "\n" 
	//#define sort(v) sort(v.begin() , v.end())
	#define print(v) for(int i = 0 ; i < v.size() ; i++) cout << v[i] << ' '  
	map< int, int > mp, mpp;
	vector< int>v;
	int visit[N] ;
	//push_back
	//insert 
	#define TRACE
	#ifdef TRACE
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
	  cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
	  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);
	}
	#else
	#define trace(...)
	#endif
	int main () 
	{ 
	   int n ;
	   cin >> n ; 
	   ll a[n + 1] ;  
	   ll sum = 0 ; 
	   map < ll , ll > mp; 
	   for(int i = 1 ; i <= n ; i++) {
	   	cin >> a[i];
	   	sum += a[i] ;
	   	mp[a[i]]++ ;  
	   }
	   int q ; 
	   cin >> q ; 
	   while(q--){
	   	ll a , b ; 	
	   	cin >> a >> b ; 
	   	ll yo = mp[a] ; 
	   	sum -= a * yo ; 
	   	sum += b * yo ; 
	   	mp[b] += yo ; 
	   	mp[a] = 0 ; 
	   	cout << sum << endl ;
	   }
	}
	/*






	*/


Measured memory_bytes: 10344
//
//  main.cpp
//  ABC086A_oddeven
//
//  Created by 岡本 朋大 on 2019/05/28.
//  Copyright © 2019年 岡本　朋大. All rights reserved.
//
#include <iostream>
#include <fstream>
using namespace std;

int main(){
    
    int a,b,c;
    cin >> a >> b;
    c = a * b;
    if (c%2 == 0){
        cout << "Even" << endl;
    }
    else {
        cout <<"Odd" << endl;
    }
}


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

using namespace std;

template<class T>
void copy(vector<T> from, vector<T> to) {
  copy(from.begin(), from.end(), back_inserter(to));
}

template<class T>
void sort(vector<T> a) {
  sort(a.begin(), a.end());
}

template<class T>
void input_to(vector<T> a) {
  T a_i;
  cin >> a_i;
  a.push_back(a_i);
}

int main() {
  int a, b;
   cin >> a >> b;

   if (a + b >= 10) {
     cout << "error" << endl;
   } else {
     cout << a + b << endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define fast()                        \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
#define PI 3.14159265358979323846
#define ff first
#define pb push_back
#define ss second
#define un unordered
#define for0(i, n) for (i = 0; i < n; i++)
#define for1(j, n) for (j = 1; j <= n; j++)
#define ll long long int
#define all(v) v.begin(), v.end()
#define t6 2000010
#define t5 200005
using namespace std;
#define mod 1000000007

ll mult(ll a,ll b){
 	return ((a%mod)*(b%mod))%mod;
}
ll power(ll x,ll y,ll p)
{
  ll res = 1; 
  x = x % p;  
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void solve(){

	ll n;
	cin>>n;
	string s;
	cin>>s;
	map<char,ll> mp[n+1];
	for(int i=0;i<s.length();i++){
		mp[i+1]=mp[i];
		mp[i+1][s[i]]++;
	}
	ll res=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ll red=mp[n]['R']-mp[j]['R'];
			ll blue=mp[n]['B']-mp[j]['B'];
			ll green=mp[n]['G']-mp[j]['G'];
			if((s[i]=='R' && s[j]=='G')|| (s[i]=='G' && s[j]=='R') ){
				res+=blue;
				if(2*j-i<n && s[2*j-i]=='B'){
					res--;
				}
			}
			if((s[i]=='B' && s[j]=='G')||(s[i]=='G' && s[j]=='B')){
				res+=red;
				if(2*j-i<n && s[2*j-i]=='R'){
					res--;
				}
			}
			if((s[i]=='R' && s[j]=='B')||(s[i]=='B' && s[j]=='R')){
				res+=green;
				if(2*j-i<n && s[2*j-i]=='G'){
					res--;
				}
			}
		}
	}
	cout<<res<<endl;


}

int main()
{
	fast()
	ll t = 1;
	//cin >> t;
	for (ll i = 0; i < t; i++)
	{   //cout<<"Case #"<<i+1<<": ";
		solve();
	}   
	
	return 0;
}

Measured memory_bytes: 4568
/**
 * @Author:      H S-J
 * @DateTime:    2017-08-20 19:59:46
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
const int maxn = 55;
const int modd = 1000000007;
LL dp[maxn];
char s1[maxn << 1], s2[maxn << 1];
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	int n; cin >> n;
	cin >> s1 >> s2;
	int i, j;
	int flag;
	// 0 same, 1diff
	if (s1[0] == s2[0]) {
		dp[0] = 3;
		i = 1;
		flag = 0;
	}
	else {
		dp[0] = dp[1] = 6;
		i = 2;
		flag = 1;
	}
	while (i != n) {
		if (s1[i] == s2[i]) {
			if (flag) {
				dp[i] = dp[i - 1] % modd;
			}
			else {
				dp[i] = (dp[i - 1] % modd) * 2;
			}
			++i; flag = 0;
		}
		else {
			if (flag) {
				dp[i] = (dp[i - 1] % modd) * 3;
			}
			else {
				dp[i] = (dp[i - 1] % modd) * 2;
			}
			dp[i + 1] = dp[i] % modd;
			i += 2; flag = 1;
		}
	}
	cout << dp[n - 1] % modd << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int a,b,c,x,y;
cin >> a>> b >> c >> x >> y;
ll ans;
c*=2;
ans = max(x,y)*c;
for(ll i =0;i<=min(x,y);i++){
 ll che =a*(x-i)+b*(y-i)+c*i;
 ans = min(che,ans);
}
cout << ans << endl;
}


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

#define MAX_N 105
int N,M;


bool can(int x){
    int m = M;
    m -= x;
    while(m > 0 && m/x){
        m -= (m/x * x);
    }
    return m == 0;
}

int main(){
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0); cin.tie(0);
    while(cin >> N >> M){
        for(int ans = M/N; ans >= 1; --ans){
            if(can(ans)) {
                cout << ans << endl;
                break;
            }
        }
    }
	return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> Nums;
  int now = 1;
  int cnt = 0;
  
  for(int i=0;i<N;i++){
    if(S[i]==(char)('0'+now)) cnt++;
    else{
      Nums.push_back(cnt);
      now=1-now;
      cnt=1;
    }
  }
  if(cnt!=0) Nums.push_back(cnt);
  if(Nums.size()%2==0) Nums.push_back(0);
  int Add=2*K+1;
  int ans=0;
  int left=0;
  int right=0;
  for(int i=0;i<Nums.size();i+=2){
    int tmp=0;
    int left=i;
    int right=min(i+Add,(int)Nums.size());    
    for(int j=left;j<right;j++){
      tmp+=Nums[j];
    }
    ans=max(ans,tmp);
  }
	cout <<ans<<endl;
}


Measured memory_bytes: 1020