akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N;
string S;
VL m_sum;// Mの累積和
VL c_sum;//Cより前のMの数の累積和
VL d_sum;//Dより前のMの数の累積和
VL c_cnt;//Cの数の累積和

LL calc(int K) {
    // cerr << "d_sum: ";REP(i, N + 1) cerr << d_sum[i] << " ";cerr<<endl;
    // cerr << "m_sum: ";REP(i, N + 1) cerr << m_sum[i] << " ";cerr<<endl;
    // cerr << "c_sum: ";REP(i, N + 1) cerr << c_sum[i] << " ";cerr<<endl;
    // cerr << "c_cnt: ";REP(i, N + 1) cerr << c_cnt[i] << " ";cerr<<endl;
    LL ans = 0;
    REP(i, N) {
        if (S[i] == 'D') {
            LL add = c_sum[min(i + K, (int)c_sum.size() - 1)] - c_sum[i + 1] - m_sum[i + 1] * (c_cnt[min(i + K, (int)c_cnt.size() - 1)] - c_cnt[i + 1]);
            ans += add;
            //DEBUG(ans)
        }
    }
    return ans;
}

int main(void) {
    cin >> N;
    cin >> S;
    m_sum.resize(N + 1);
    c_sum.resize(N + 1);
    d_sum.resize(N + 1);
    c_cnt.resize(N + 1);
    {
        REP(i, N) {
            m_sum[i + 1] = m_sum[i] + (S[i] == 'M');
        }
        REP(i, N) {
            if (S[i] == 'C') {
                c_sum[i + 1] = m_sum[i + 1];
                c_cnt[i + 1] = 1;
            }
            c_sum[i + 1] += c_sum[i];
            c_cnt[i + 1] += c_cnt[i];
            if (S[i] == 'D') {
                d_sum[i + 1] = m_sum[i + 1];
            }
            d_sum[i + 1] += d_sum[i];
        }
    }
    int Q;
    cin >> Q;
    REP(i, Q) {
        int K;
        cin >> K;
        cout << calc(K) << endl;
    }
}


Measured memory_bytes: 34692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
 int main() {
 	ll n,d;
 	cin >>n>>d;
 	ll count=0;
 	vector < vector<ll> > arr(n,vector<ll>(d));
 	for (int x=0;x<n;x++){
 		for (int y=0;y<d;y++){
 			cin >> arr[x][y];
 		}
 	}
 	ld ans=0;
 	for (int x=0;x<n-1;x++){
		for (int y=x+1;y<n;y++){
			for (int z=0;z<d;z++){
				ans=ans+((arr[x][z]-arr[y][z])*(arr[x][z]-arr[y][z]));
			}
			ans=sqrt(ans);
			if (floor(ans)==ceil(ans)){
				count+=1;
			}
			ans=0;
		}
 	}
 	cout << count;
 }


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

#define vint vector<int>
#define vvint vector<vint>
#define sint stack<int>
#define qint queue<int>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
#define ld long double
#define ll long long
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}

bool IsOver(ll ans, ll a){
#if 0
    ll x = c * b;
    if(x /b != c){
        return true;
    }else{
        return false;
    }
#else
    if(a > pow(10,18)/ans){
        return true;
    }else{
        return false;
    }
#endif
}
void Main(){
    ll limit = pow(10,18);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i<n;i++){
        cin >> a[i];
        if(a[i] == 0){
            ct(0);
            return;
        }
    }
    ll ans = 1;
    for(ll i = 0; i<n;i++){
        if(IsOver(ans,a[i])){
            ct(-1);
            return;
        }else {
            ans *= a[i];
        }
    }
    if ( ans > limit ){
        ct(-1);
    }else{
        ct(ans);
    }
    return;
}

int main() {
    Main();
}

/*
 *  int a,b;
    cin >> a >> b;
    ct(a*b);
int main() {
    ll maxv = pow(10,18);
    int n;
    cin >> n;
    ll ans;
    bool over = false;
    bool zero = false;
    cin >> ans;
    if(ans == 0){
        zero = true;
    }
    rep(i,n-1){
        ll a;
        cin >> a;
        if(a == 0){
            zero = true;
            break;
        }else if(!over) {
            ll c = ans * a;
            ll d = c / ans;
            if (a != d) {
                over = true;
            }

            ans *= a;
            if (ans > maxv) {
                over = true;
            }
        }
    }
    if(zero) {
        ct(0);
    }else if(over){
        ct(-1);
    }else{
        ct(ans);
    }
}

 * */

Measured memory_bytes: 3996
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String x = scan.next();
        String y = scan.next();
        long X = Long.parseLong(x);
        long Y = Long.parseLong(y);
        long ans = 0;
        long i = X;
        while(i <= Y){
            //System.out.println(i);
            ans++;
            i = i*2;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22100
#pragma GCC optimize("Ofast")

//#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x%N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x)%N;
		y = y >> 1;
		x = (x * x)%N;
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b;
	cin >> a >> b;
	if (a >= 1 && a < 10 &&b>0 && b < 10)
		cout << a * b;
	else
		cout << "-1";
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque

N = int(input())
adj = [[0]*N for _ in range(N)]
unsearched = set(range(1, N))
result = {n:-1 for n in range(N)}

for n in range(N):
    inp = list(map(int, input().split()))
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = 1

que = deque([[0, 0]]) # edge distance


while len(que):
    q = que.pop()
    result[q[0]] = q[1]
    next_ = [[i, q[1] + 1] for i, a in enumerate(adj[q[0]]) if (a==1) & (i in unsearched)]
    unsearched = unsearched.difference([i[0] for i in next_])
    que.extendleft(next_)

for n in range(N):
    print("{} {}".format(n+1, result[n]))

Measured memory_bytes: 8112
import numpy as np

abcd = input()
#a,b,c,d = [s for s in abcd]

for i in range(2**3):
    ops = ["-","-","-",""]
    for j in range(3):
        if i>>j&1: ops[j] = "+"
    equa = ""
    for s,op in zip(abcd,ops): equa += (s+op)
    if eval(equa) == 7 : break

ans = equa + "=7"
print(ans)


Measured memory_bytes: 12504
n, m = map(int, input().split())

ans = [-1 for _ in range(n)]
for i in range(m):
  s, c = map(int, input().split())
  if ans[s-1] != c and ans[s-1] != -1:
    print(-1)
    exit()
  else:
    ans[s-1] = c
    
if n==1:
  if ans[0]==-1:
    ans[0] = 0
  print(*ans, sep='')
  exit()
    
if ans[0]==0:
  print(-1)
  exit()
  
if ans[0]==-1:
  ans[0] = 1

for i in range(1,n):
  if ans[i]==-1:
    ans[i] = 0
  
print(*ans, sep='')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, k, c = 0;
	cin >> a >> b >> k;
	for(int i = a; i >= 0; i--){
		if(a % i == 0 && b % i == 0)
			c ++;
		if(k == c)
			return cout << i, 0;
	}
}

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

int main() {
  int N; scanf("%d",&N);
  int X[N], L[N]; pair<int,int> endstart[N];
  for(int i=0; i<N; i++) {
    scanf("%d %d",&X[i],&L[i]);
    endstart[i].first=X[i]+L[i];
    endstart[i].second=X[i]-L[i];
  }
  sort(endstart,endstart+N);
  int ans=1, t=endstart[0].first;
  for(int i=1; i<N; i++) {
    if (t<=endstart[i].second) {
      ans++;t=endstart[i].first;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 5400
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

ll _x[4] = {0, 1, 0, -1};
ll _y[4] = {-1, 0, 1, 0};

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<pair<ll, pair<ll,ll> > > v;
    for (ll i = 0; i < n; i++)
    {
        ll t, x, y;
        cin >> t >> x >> y;
        v.push_back(make_pair(t, make_pair(x, y)));
    }

    ll X = 0, Y = 0;
    ll now_t = 0;

    for (ll i = 0; i < n; i++)
    {   
        bool ok = false;
        if (abs(X - v[i].second.first) + abs(Y - v[i].second.second) == v[i].first - now_t)
        {
            ok = true;
            now_t = v[i].first;
            X = v[i].second.first;
            Y = v[i].second.second;
        }
        else if (abs(X - v[i].second.first) + abs(Y - v[i].second.second) < v[i].first - now_t)
        {
            if ((abs(X - v[i].second.first) + abs(Y - v[i].second.second) - v[i].first - now_t) % 2 == 0)
            {
                ok = true;
                now_t = v[i].first;
                X = v[i].second.first;
                Y = v[i].second.second;
            }
        }

        if (!ok)
        {
            cout << "No" << endl;
            exit(0);
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 4980
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(ll i = 0;i < n;i++)
#define FOR(i,a,b) for(ll i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

using namespace std;

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

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

struct edge { ll from, to, cost; };

int main() {
	IOS;
	ll INF = LMAX;
	ll n, m;
	cin >> n >> m;
	vector<ll> d(n + 1, INF);
	vector<edge> e(m);
	REP(i, m) {
		cin >> e[i].from >> e[i].to >> e[i].cost;
		e[i].cost *= -1;
	}
	d[1] = 0;
	REP(i,2 * n) {
		REP(j, m) {
			edge tmp = e[j];
			if (d[tmp.from] != INF && d[tmp.to] > d[tmp.from] + tmp.cost) {
				d[tmp.to] = d[tmp.from] + tmp.cost;
				if (i >= n - 1 && tmp.to == n) { dump("inf"); return 0; }
			}
		}
	}
	dump(-d[n]);
}



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

typedef long long int ll;
const int M = 1e9 + 7;

ll mod(ll a){
    return (a%M + M)%M;
}

ll mul(ll a, ll b){
    return mod(mod(a)*mod(b));
}

ll add(ll a, ll b){
    return mod(mod(a)+mod(b));
}
void solve(){
    
    //ifstream myfile;
    //myfile.open("sample.txt");

    int n;
    cin  >> n;

    vector<ll> a(n);
    vector<ll> prefSum(n+1);

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

    for(int i=n-1; i>=0; i--){
        
        prefSum[i] = a[i] + prefSum[i+1];
    }

    ll sum = 0;
    for(int i=0; i<n-1; i++)
    {
        sum = add(sum,mul(a[i],prefSum[i+1]));
    }
    cout << sum;

    return;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 6352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class UnionFindNode
    {
        internal UnionFindNode parent;
        internal int rank;
    }

    class UnionFind
    {
        Dictionary<object, UnionFindNode> _dict;

        public UnionFind()
        {
            _dict = new Dictionary<object, UnionFindNode>();
        }

        public void Unite(IComparable x, IComparable y)
        {
            var xRoot = Root(x);
            var yRoot = Root(y);

            if (xRoot == yRoot) return;

            if (xRoot.rank < yRoot.rank)
            {
                xRoot.parent = yRoot;
            }
            else
            {
                yRoot.parent = xRoot;

                if (xRoot.rank == yRoot.rank) xRoot.rank++;
            }
        }

        public bool IsSame(IComparable x, IComparable y)
        {
            return Root(x) == Root(y);
        }

        UnionFindNode Root(object obj)
        {
            if (!_dict.ContainsKey(obj))
            {
                var node = new UnionFindNode();
                _dict.Add(obj, node);
                return node;
            }
            else
            {
                var node = _dict[obj];
                return Find(node);
            }
        }

        UnionFindNode Find(UnionFindNode node)
        {
            if (node.parent == null) return node;

            return node.parent = Find(node.parent);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int m = int.Parse(input[1]);

            UnionFind uf = new UnionFind();

            for(int i = 0; i < m; i++)
            {
                input = Console.ReadLine().Split(' ');
                int x = int.Parse(input[0]);
                int y = int.Parse(input[1]);

                uf.Unite(x, y);
            }

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

            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < q; i++)
            {
                input = Console.ReadLine().Split(' ');
                int x = int.Parse(input[0]);
                int y = int.Parse(input[1]);

                sb.AppendLine(uf.IsSame(x, y) ? "yes" : "no");
            }
            Console.Write(sb);
        }
    }
}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int n, k;
int dp[55][55][3300];
int mod = 1e9 + 7;
signed main() {
    cin >> n >> k;
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int p = 0; p <= k; p++) {
                (dp[i + 1][j][p + 2 * j] += (2 * j + 1) * dp[i][j][p]) %= mod;
                (dp[i + 1][j + 1][p + 2 * j] += dp[i][j][p]) %= mod;
                if (j != 0) { (dp[i + 1][j - 1][p + 2 * j] += (j * j) * dp[i][j][p]) %= mod; }
            }
        }
    }
    cout << dp[n][0][k] << endl;
}

Measured memory_bytes: 72448
fn main() {
    let n: u32 = read();
    let mut p = 1;
    while p <= n {
        p *= 2;
    }
    println!("{}", p/2);
}

// 以下関数


use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 1_000_000_007;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

pub fn factorial(n: u32) -> u32 {
    if n == 0 {
        return 1
    }
    let mut r = n;
    for i in 0..n-1{
        r *= n-i-1;
    }
    r
}

pub fn combination(n: u32, m: u32) -> u32 {
    factorial(n) / factorial(m) / factorial(n-m)
}

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


int main(){
    ll x;cin>>x;
    ll m=100;
    rep(i,0,4000){
        if(m>=x){
            cout<<i<<endl;
            return 0;
        }
        m=m*1.01;
        m=floor(m);
    }
    
}
    









Measured memory_bytes: 3640
a = [int(input()) for i in range(5)]
time = 10
for i in range(5):
         if (a[i] + 9) % 10 < time:
                  time = (a[i] + 9) % 10
                  mindish = i
ans = 0
for i in range(5):
         ans += ((a[i] + 9 ) //10)*10
ans = ans - (((a[mindish] + 9 )//10 ) *10)+ a[mindish]
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> vecA(n);
  vector<int> vecB(n);
  vector<int> vecC(n-1);
  
  for (int i = 0; i < n; i++){
    cin >> vecA.at(i);
  }
  for (int i = 0; i < n; i++){
    cin >> vecB.at(i);
  }
  for (int i = 0; i < n-1; i++){
    cin >> vecC.at(i);
  }
  
  int sum = 0;
  
  for (int i = 0; i < n; i++){
    sum += vecB.at(i);
  }
  for (int i = 0; i < n-1; i++){
    if (vecA.at(i) == vecA.at(i+1) -1){
    sum += vecC.at(vecA.at(i)-1);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lld long double
#define vc vector<ll>
typedef pair<ll,ll>pairs;
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	cin>>n>>k;
	vc a(n+1);
	i=1;
	while(i<=n)cin>>a[i++];
	sort(a.begin()+1,a.end());
	ll sum=0;
	for(i=1;i<=k;i++)
	    sum+=a[i];
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF INT_MAX
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[100010], mi[100010], ma[100010], sum;
signed main() {
	cin >> n;
	bool f = false, g = false;
	rep(i, n) {
		cin >> a[i];
		if (a[i] <= 0)f = true;
		if (a[i] >= 0)g = true;
		sum += abs(a[i]);
	}
	sort(a, a + n);
	if (n == 2) {
		cout << a[1] - a[0] << endl;
		cout << a[1] << " " << a[0] << endl;
		return 0;
	}
	if (f ^ g) {
		if (f) {
			reverse(a, a + n);
			cout << sum - abs(a[0]) * 2 << endl;
			cout << a[0] << " " << a[1] << endl;
			int now = a[0] - a[1];
			for (int i = 2; i < n - 1; i++) {
				cout << now << " " << a[i] << endl;
				now -= a[i];
			}
			cout << now << " " << a[n - 1] << endl;
		}
		else {
			cout << sum - abs(a[0]) * 2 << endl;
			cout << a[0] << " " << a[1] << endl;
			int now = a[0] - a[1];
			for (int i = 2; i < n - 1; i++) {
				cout << now << " " << a[i] << endl;
				now -= a[i];
			}
			cout << a[n - 1] << " " << now << endl;
		}
	}
	else {
		cout << sum << endl;
		int now = a[0], s;
		rep(i, n) {
			if (a[i] >= 0) {
				s = i;
				break;
			}
		}
		if (!s) {
			cout << a[0] << " " << a[1] << endl;
			now = a[0] - a[1];
			for (int i = 2; i < n - 1; i++) {
				cout << now << " " << a[i] << endl;
				now -= a[i];
			}
			cout << a[n - 1] << " " << now << endl;
		}
		else if (s == 1) {
			cout << a[0] << " " << a[s] << endl;
			now -= a[s];
			for (int i = 2; i < n - 1; i++) {
				cout << now << " " << a[i] << endl;
				now -= a[i];
			}
			cout << a[n - 1] << " " << now << endl;
		}
		else if (s == n - 1) {
			cout << a[s] << " " << a[0] << endl;
			now = a[s] - a[0];
			for (int i = 1; i < n - 1; i++) {
				cout << now << " " << a[i] << endl;
				now -= a[i];
			}
		}
		else {
			cout << a[s] << " " << a[0] << endl;
			now = a[s] - a[0];
			for (int i = 1; i < n; i++) {
				if (i == s)continue;
				if (i == s - 1) {
					cout << a[i] << " " << now << endl;
					now = a[i] - now;
				}
				else if (i == n - 1) {
					cout << a[i] << " " << now << endl;
					now = a[i] - now;
				}
				else {
					cout << now << " " << a[i] << endl;
					now -= a[i];
				}
			}
		}
	}
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        x:usize,
        ln:[usize;n],
    }
    let mut v = vec![0];
    for j in 0..n{
        let diff = v[j] + ln[j];
        v.push(diff);
    }
    let ans = v.iter().filter(|&t| *t <= x).count();
    println!("{}",ans);
}

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


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

   int ans=1000;
   for (int i = 0; i < s.size()-2; ++i){
      int a=(s[i]-48)*100+(s[i+1]-48)*10+s[i+2]-48;
      ans=min(ans,abs(753-a));
   }

   cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}



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



    int i = 0, j = n-1;
    int swaps_need = 0;
    while(i < j) {
        if(a[j] == 'R' and a[i] == 'W') {
            swaps_need ++;
            i++;
            j--;
            continue;
        }
        if(a[i] == 'R'){
            i++;
        }
        if(a[j] == 'W') {
            j--;
        }
    }
    cout << swaps_need << endl;

}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int a, b, low, high;
bool ok;

int main () {
    cin >> a >> b;
    ok = false;
    int i = 0;
    while (i < 1010 && !ok) {
        if (floor(i*0.08) == a && floor(i*0.1) == b) {
            cout << i;
            ok = true;
            break;
        }
        i++;
    }
    if (ok == false) cout << -1;
}

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

namespace Keyence
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<long> A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            List<long> B = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            List<long> D = new List<long>();
            for(int i = 0; i < N; i++)
            {
                D.Add(A[i] - B[i]);
            }
            long Asum = A.Sum();
            long Bsum = B.Sum();

            if (Bsum > Asum)
            {
                Console.WriteLine("-1");
                return;
            }

            D.Sort();
            int numMinus = D.Count(x => x < 0);
            if (numMinus == 0)
            {
                Console.WriteLine("0");
                return;

            }

            long sumMinus = -D.Where(x => x < 0).Sum();

            int counter = 0;
            long sum = 0;
            for(int i = N - 1; i > 0; i--)
            {
                sum += D[i];
                counter++;
                if (sum >= sumMinus) break;
            }

            int numChange = numMinus + counter;
            Console.WriteLine(numChange);

        }
    }
}


Measured memory_bytes: 32608
"""AtCoder"""

a, b, c, d = map(int, input().split())
check = False

if abs(a-c) > d:
    if a >= b >= c or a <= b <= c:
        if abs(a-b) <= d and abs(b-c) <= d:
            check = True
else:
    check = True
        
if check:
    print("Yes")
else:
    print("No")


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

int N;
vector<long long> x, y;

int solve() {
    if (N == 1) return 1;

    int res = N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            long long dx = x[j] - x[i], dy = y[j] - y[i];

            int sub = 0;
            for (int i2 = 0; i2 < N; ++i2) {
                for (int j2 = 0; j2 < N; ++j2) {
                    if (j2 == i2) continue;
                    if (dx == x[j2] - x[i2] && dy == y[j2] - y[i2]) ++sub;
                }
            }
            res = min(res, N - sub);
        }
    }
    return res;
}

int main() {
    cin >> N;
    x.resize(N); y.resize(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A

#B

#C
def dfs(n,k,nu):
    global ans
    if n == 0:
        d = [0,0,0]
        m = 0
        for i in range(nu):
            if k[i] < 3:
                if d[k[i]] != 0:
                    m += 10
                d[k[i]] += l[i]
        if d[0]*d[1]*d[2] != 0:
            m += abs(a-d[0])+abs(b-d[1])+abs(c-d[2])
            ans = min(ans, m)
    else:
        for i in range(4):
            dfs(n-1,k+[i],nu)
n,a,b,c = LI()
l = IR(n)
li = []
ans = float("inf")
dfs(n,[],n)
print(ans)
#D
"""
a,b,q = LI()
s = IR(a)
t = IR(b)
for i in range(q):
    x = I()
    c = bisect.bisect_left(s,x)
    ans = float("inf")
    if c == a:
        k = abs(x-s[-1])
        y = s[-1]
        d = bisect.bisect_left(t,y)
        if d == b:
            k += abs(y-t[-1])
        else:
            if abs(y-t[d-1]) < abs(y-t[d]):
                k += abs(y-t[d-1])
            else:
                k += abs(y-t[d])
        ans = min(k,ans)
    else:
        k = abs(x-s[c-1])
        y = s[c-1]
        d = bisect.bisect_left(t,y)
        if d == b:
            k += abs(y-t[-1])
        else:
            if abs(y-t[d-1]) < abs(y-t[d]):
                k += abs(y-t[d-1])
            else:
                k += abs(y-t[d])
        ans = min(k,ans)
        k = abs(x-s[c])
        y = s[c]
        d = bisect.bisect_left(t,y)
        if d == b:
            k += abs(y-t[-1])
        else:
            if abs(y-t[d-1]) < abs(y-t[d]):
                k += abs(y-t[d-1])
            else:
                k += abs(y-t[d])
        ans = min(k,ans)
    c = bisect.bisect_left(t,x)
    if c == b:
        k = abs(x-t[-1])
        y = t[-1]
        d = bisect.bisect_left(s,y)
        if d == a:
            k += abs(y-s[-1])
        else:
            if abs(y-s[d-1]) < abs(y-s[d]):
                k += abs(y-s[d-1])
            else:
                k += abs(y-s[d])
        ans = min(k,ans)
    else:
        k = abs(x-t[c-1])
        y = t[c-1]
        d = bisect.bisect_left(s,y)
        if d == a:
            k += abs(y-s[-1])
        else:
            if abs(y-s[d-1]) < abs(y-s[d]):
                k += abs(y-s[d-1])
            else:
                k += abs(y-s[d])
        ans = min(k,ans)
        k = abs(x-t[c])
        y = t[c]
        d = bisect.bisect_left(s,y)
        if d == a:
            k += abs(y-s[-1])
        else:
            if abs(y-s[d-1]) < abs(y-s[d]):
                k += abs(y-s[d-1])
            else:
                k += abs(y-s[d])
        ans = min(k,ans)
    print(ans)
"""

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 49884
#include<stdio.h>

int main()
{
 int a,b,c;
 int i;
 int count=0;
 scanf("%d %d %d",&a,&b,&c);

 for(i=a;i<=b;i++)
 {
   if(c%i==0)count++;
 }
 
 printf("%d\n",count);
 return 0;
}

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

int main(){
  int N,count = 1;
  cin >> N;
  vector<int> d(N);
  for(int i = 0;i < N;i++)
    cin >> d.at(i);
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  for(int j = 0;j < N - 1;j++){
    if(d.at(j) > d.at(j + 1))
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define REP(i,n) for(LL i=0, i##_len=(n); i<i##_len; ++i)

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

template <LL MOD=1000000007> class MODLL {
public:
  LL x;
  MODLL(const LL _x) : x(_x % MOD) {};
  MODLL operator+(const MODLL rhs) const { return MODLL(*this) += rhs; }
  MODLL operator-(const MODLL rhs) const { return MODLL(*this) -= rhs; }
  MODLL operator*(const MODLL rhs) const { return MODLL(*this) *= rhs; }
  MODLL operator/(const MODLL rhs) const { return MODLL(*this) /= rhs; }
  MODLL& operator+=(const MODLL rhs) { x += rhs.x; x %= MOD; return *this; }
  MODLL& operator-=(const MODLL rhs) { x -= rhs.x; x %= MOD; if(x<0) x += MOD; return *this; }
  MODLL& operator*=(const MODLL rhs) { x *= rhs.x; x %= MOD; return *this; }
  MODLL inv() const {
    if(x == 0) { throw "does not have inverse"; }
    LL a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return MODLL(u);
  }
  MODLL& operator/=(const MODLL rhs) { (*this) *= rhs.inv(); return *this; }
  MODLL pow(ULL n) const {
    MODLL res = 1;
    MODLL a = x;
    while (n > 0) {
      if (n & 1) res *= a;
      a = a * a;
      n >>= 1;
    }
    return res;
  }
};

typedef MODLL<> ML;

void test() {
  {
    ML x = 3;
    assert(x.pow(45).x == 644897553);
  }
  {
    for(int i=1; i<13; i++) {
      MODLL<13> x = i;
      assert( (x.inv().x * i) % 13 == 1 );
    }
  }
}


int main() {
  LL N, K;
  std::cin >> N >> K;
  std::vector<LL> x(N);
  REP(i,N) {
    std::cin >> x[i];
  }
  LL ans = 100000000000000;
  for(LL l=0; l<=N-K; l++) {
    LL r = l + K - 1;
    LL dl = std::abs(x[l]);
    LL dr = std::abs(x[r]);
    LL d = (x[r] - x[l]);
    LL min_d = std::min(dl, dr) + d;
    ans = std::min(ans, min_d);
  }

  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1024
/*---> 16 January 2020 <--- > 12:06:36 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;
int prob[N],pen[N];
int32_t main(){__
	int n,m;
	cin>>n>>m;
	int x;
	string s;
	int ans=0;
	for(int i=0;i<m;i++){
		cin>>x>>s;
		if(s=="WA"){
			if(!prob[x])
				pen[x]++;
		}
		else{
			if(!prob[x])
				ans++;
			prob[x]=1;
		}
	}
	cout<<ans<<" ";
	ans=0;
	for(int i=1;i<=n;i++){
		if(prob[i])
			ans+=pen[i];
	}
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

const int INF = 1 << 30;

int A[1010], B[1010];
int C[1010][22];

int dp[1010][50505];  // dp[i][j]: i番目の鍵までで宝箱の集合jを開けている時の最小コスト

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, 0, M) {
        cin >> A[i] >> B[i];
        rep(j, 0, B[i]) {
            cin >> C[i][j];
            C[i][j]--;
        }
    }
    rep(i, 0, M) rep(j, 0, 1 << N) {
        dp[i][j] = INF;
    }
    dp[0][0] = 0;
    rep(i, 0, M) rep(mask, 0, 1 << N) {
        if (dp[i][mask] == INF) continue;
        // i+1番目の鍵を使用しない場合
        dp[i + 1][mask] = min(dp[i + 1][mask], dp[i][mask]);
        // i+1番目の鍵を使用する場合
        int key_mask = 0;
        rep(j, 0, B[i]) {
            key_mask |= (1 << C[i][j]);
        }
        dp[i + 1][mask | key_mask] = min(dp[i + 1][mask | key_mask], dp[i][mask] + A[i]);
    }
    if (dp[M - 1][(1 << N) - 1] == INF) cout << -1 << endl;
    else cout << dp[M - 1][(1 << N) - 1] << endl;
    return 0;
}

Measured memory_bytes: 197248
#include<bits/stdc++.h>
#define maxn 555555

using namespace std;
struct point{
    int x,y;
    point operator +(point const &u){
        if (x>u.x){
            if (y>u.x) return {x,y}; else return {x,u.x};
        }
        else {
            if (u.y>x) return {u.x,u.y}; else return {u.x,x};
        }
    }
};

point a[maxn];
int n,k,s;

int main(){
    cin >> n; k=1<<n;
    for (int i=0;i<k;i++) cin >> a[i].x;
    for (int i=0;i<n;i++)
        for (int j=0;j<k;j++)
            if (j&(1<<i)) a[j]=a[j]+a[j^(1<<i)];
    for (int i=1;i<k;i++) {
        s=max(s,a[i].x+a[i].y);
        cout << s << endl;
    }
}


Measured memory_bytes: 7168
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7

def main():
    N,K = cin.mapInt()
    D = set(cin.string().split())
    while True:
        if len(D & set(str(N))) == 0:
            break
        N +=1
    print(N)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 40556
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define fi first
#define sec second
#define pb push_back
int hit[25],frame[25];
bool spare[25],strike[25];
int game(){
	memset(hit,0,sizeof(hit));
	memset(frame,-1,sizeof(frame));
	memset(spare,false,sizeof(spare));
	memset(strike,false,sizeof(strike));
	int cur = 0;
	for(int i=1;i<=9;i++){
		scanf("%d",&hit[cur]);
		frame[cur]=i;
		cur++;
		if(hit[cur-1]==10){
			strike[cur-1]=true;
			continue;
		}
		scanf("%d",&hit[cur]);
		frame[cur]=i;
		if(hit[cur]+hit[cur-1]==10)spare[cur]=true;
		cur++;
	}
	for(int i=10;i<=10;i++){
		scanf("%d",&hit[cur]);
		frame[cur]=i;
		cur++;
		scanf("%d",&hit[cur]);
		frame[cur]=i;
		cur++;
		if(hit[cur-1]+hit[cur-2]<10)break;
		scanf("%d",&hit[cur]);
		frame[cur]=i;
		cur++;
	}
	int ret = 0;
	for(int i=0;i<cur;i++){
		ret += hit[i];
		if(strike[i]){
			ret += hit[i+1];
			ret += hit[i+2];
		}
		if(spare[i])ret += hit[i+1];
	}
	return ret;
}
int main(){
	int m;
	while(1){
		scanf("%d",&m);
		if(m==0)break;
		vector<P> vec;
		for(int i=0;i<m;i++){
			int id;
			scanf("%d",&id);
			int score = game();
			vec.pb(P(-score,id));
		}
		sort(vec.begin(),vec.end());
		for(int i=0;i<vec.size();i++){
			printf("%d %d\n",vec[i].sec,-vec[i].fi);
		}
	}
	return 0;
}

Measured memory_bytes: 1192
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    A = [int(input()) for i in range(n)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Dic = {i:A[i-1] for i in range(1, n+1)}

    cnt = 0
    now = 1
    rout = []
#    while now not in rout:
    for _ in range(n):
        rout.append(now)
        now = Dic[now]
        cnt += 1
        if now == 2:
            break

    if now == 2:
        print(cnt)
    else:
        print("-1")

resolve()

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


// dp[0][0][0] = 0
// ans = dp[#{i| a[i] == 1}][][#{k|a[k] == 3}]
// dp[i][j][k] = 1 + ((N - i - j - k) / N) * dp[i][j][k] + (i / N) * dp[i - 1][j][k] + ...
// (i + j + k) / N * dp[i][j][k] = 1 + (i / N) * dp[i - 1][j][k] + (j / N) * dp[i + 1][j - 1][k] + ...
double dp[302][302][302];
int N;

int main(){
    int first_cnt[4] = {};
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        first_cnt[a]++;
    }
    for(int k = 0; k <= first_cnt[3]; k++){
        for(int j = 0; j <= first_cnt[2] + first_cnt[3]; j++){
            for(int i = 0; i <= N; i++){
                if(i == 0 && j == 0 && k == 0){
                    continue;
                }
                dp[i][j][k] += 1.0 * N / (i + j + k);
                if(i > 0){
                    dp[i][j][k] += 1.0 * i / (i + j + k) * dp[i - 1][j][k];
                }
                if(j > 0){
                    dp[i][j][k] += 1.0 * j / (i + j + k) * dp[i + 1][j - 1][k];
                }
                if(k > 0){
                    dp[i][j][k] += 1.0 * k / (i + j + k) * dp[i][j + 1][k - 1];
                }
            }
        }
    }
    cout << setprecision(10) << dp[first_cnt[1]][first_cnt[2]][first_cnt[3]] << endl;
}



Measured memory_bytes: 215296
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

char A[810][810];
int d[810][810];
int n, m, k;

void solve(){
	scanf("%d%d%d", &n, &m, &k);
	pii S = pii(0,0);
	for(int i=1;i<=n;i++) {
		scanf("%s", A[i]+1);
		for(int j=1;j<=m;j++) if(A[i][j] == 'S') S = pii(i, j);
	}
	queue <pii> que;
	memset(d, -1, sizeof d);
	d[S.Fi][S.Se] = 0;
	que.push(S);
	int xx[4] = {1, -1};
	while(!que.empty()) {
		pii t = que.front(); que.pop();
		rep(k, 4) {
			int nx = t.Fi + xx[k];
			int ny = t.Se + xx[(k+2) & 3];
			if(1 <= nx && nx <= n && 1 <= ny && ny <= m && A[nx][ny] != '#' && d[nx][ny] == -1) {
				d[nx][ny] = d[t.Fi][t.Se] + 1;
				que.push(pii(nx, ny));
			}
		}
	}
	int ans = 1e9;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(d[i][j] != -1 && d[i][j] <= k) {
		int t = min({i-1, j-1, n-i, m-j});
		ans = min(ans, (t + k - 1) / k + 1);
	}
	printf("%d\n", ans);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d\n", tc);
		solve();
	}
	return 0;
};

Measured memory_bytes: 3584
def main():
    N = int(input())
    m = {}
    for i in range(N):
        S = input()
        m.setdefault(S, 0)
        m[S] += 1
    L = list(m.items())
    L.sort(key=lambda x: x[1])
    max_freq = L[-1][1]
    I = []
    for k, v in m.items():
        if v == max_freq:
            I.append(k)
    I.sort()
    print('\n'.join(I))

if __name__ == '__main__':
    main()


Measured memory_bytes: 48348