akhauriyash/Code-Regression huggingface dataset:
A, B, C, X, Y = map(int, input().split())
price = 0
P = []
s = 0
t = 0
u = 0
if A + B <= 2*C:
    price = A*X + B*Y
else:
    sa = abs(X - Y)
    price = C*2*(min(X, Y)-sa)
    XX = X - (min(X, Y)-sa)
    YY = Y - (min(X, Y)-sa)
    dai = max(XX, YY)
    syou = min(XX, YY)

    for i in range(dai+1):
        u = i*2
        if syou>=i:
            s = XX - i
            t = YY - i
        else:
            if X >= Y:
                s = XX - i
                t = 0
            else:
                s = 0
                t = YY - i
        P.append(A*s + B*t + C*u)
    price += min(P)

print(price)

Measured memory_bytes: 12028
#include <iostream>
#include <iomanip>
#include <complex>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <stdlib.h>

using namespace std;
typedef complex<long> com;

long tri(com a, com b) //triangle size
{
	return(conj(a)*b).imag() / 2;
}

long s_ll(string s) //入力した数字を10*6倍にしてlongとして読み取る
{
	int ssize=s.size();
	int j=6;
	for(int i=0;i<ssize;i++)
	{
		if(s[i]=='.')
		{
			s.erase(i,1);
			j=7-ssize+i;
			break;
		}
	}
	long l;
	l=atoi(s.c_str());
	for(int i=0;i<j;i++)
	{
		l=l*10;
	}
	return l;
}

int n;
string x1, x2, x3, x4, yi, y2, y3, y4;
long  X1, X2, X3, X4, Y1, Y2, Y3, Y4;

int main()
{
	cin >> n;
	while (n--)
	{
		cin >> x1 >> yi >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		X1 = s_ll(x1);
		X2 = s_ll(x2);
		X3 = s_ll(x3);
		X4 = s_ll(x4);
		Y1 = s_ll(yi);
		Y2 = s_ll(y2);
		Y3 = s_ll(y3);
		Y4 = s_ll(y4);
		if (tri(com(X2 - X1, Y2 - Y1), com(X4 - X3, Y4 - Y3)) == 0)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3020
A, B, C = map(int, input().split())
cnt = 0
while True:
  if A%2!=0 or B%2!=0 or C%2!=0:
    print(cnt)
    break
  elif A == B and B == C and A == C:
    print(-1)
    break
  else:
    temp_A = A
    temp_B = B
    A = B/2 + C/2
    B = temp_A/2 + C/2
    C = temp_A/2 + temp_B/2
    cnt += 1

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

bool f(int n, const string& s, int index, const string& signs)
{
    if (index == 4) {
        if (n == 7) {
            for (int i = 0; i < index - 1; ++i) {
                cout << s[i] << signs[i];
            }
            cout << s[index - 1] << "=" << n << endl;
            return true;
        }
        return false;
    }
    int d = s[index] - '0';

    return f(n + d, s, index + 1, signs + "+")
        || f(n - d, s, index + 1, signs + "-");
}

void main_()
{
    string S;
    cin >> S;
    f(S[0] - '0', S, 1, "");
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

#define what_is(x) cout << #x << " is " << x << endl;
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 1000000000000000000
#define ninf -9223372036854775802
#define M 1000000007
#define eps 1e-9
#define MAX 5
#define N 8
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX];
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a, ll b, ll p) {
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    ll temp = vpow(a, b / 2, p);
    temp *= temp;
    temp %= p;
    if (b % 2 == 0)
        return temp;
    temp = temp * a;
    temp %= p;
    return temp;
}

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


ll inverseMod(ll a, ll b, ll p) {
    if (b == 0)
        return 1;
    ll temp = vpow(b, p - 2, p);
    ll ans = temp * a;
    ans %= p;
    return ans;
}
void sieve()
{
    prime[0] = prime[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}

void factorial() {
    fact[0] = 1;
    fact[1] = 1;
    rep(i, 2, MAX) {
        fact[i] = (fact[i - 1] * i);
        // fact[i]%=M;
    }
}
ll dp[2001];
ll rec(ll s){
	if(s==0)
		return 1;
	if(s<3)
		return 0;
    if(s<5){
        return 1;
    }
    ll &val=dp[s];
    if(val!=-1)
        return val;
    val=0;
    rep(i,3,s+1){
        val+=rec(s-i);
        val%=M;
    }
    //cout<<"Value for "<<s<<" = "<<val<<endl;
    return val;
}
void solve(ll ttt) {
    ll s;
    cin>>s;
    rep(i,0,s+1)
        dp[i]=-1;
    ll ans=rec(s);
    cout<<ans<<endl;
}

int main() {
    io;
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    // freopen("output1.txt","w",stdout);
#endif

    ll t = 1;
    //cin >> t;
    fix(12);
    rep(q, 1, t + 1) {
        // cout<<"Test case : "<<q<<endl;
        solve(q);
        //solve2();
    }
    return 0;

}


Measured memory_bytes: 3648
#include <iostream>


using namespace std;

template<class T> inline int gcd(T a, T b) { return b ? gcd(b, a % b) : a; }



int main(){

int n;
  cin >> n;
  int a[n];
 
  for(int i=0;i<n;i++){
   cin >> a[i];
  }
    
  int l[n+1],r[n+1];
  
  l[0]=0;
  r[n]=0;
  
  for(int i=0; i<n;i++){
   l[i+1]=gcd(l[i],a[i]);
   r[n-i-1]=gcd(r[n-i],a[n-i-1]);
  }
  

  
  int m=0;
  for(int i=0;i<n;i++){
  m=max(m,gcd(l[i],r[i+1]));
  }
  
  
 cout << m << endl;


}

Measured memory_bytes: 1408
def dfs(i,f):
  if i == n-1:
    return sum(list(map(int, f.split('+'))))
  
  return dfs(i+1, f+s[i+1]) + dfs(i+1, f+'+'+s[i+1])

s = input()
n = len(s)

print(dfs(0, s[0]))

Measured memory_bytes: 9140
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            Solve();

        }
        static string S;
        static string T;
        static int H;
        static int W;
        static int N;
        static int SH;
        static int SW;
        static void Solve()
        {
            var HWN = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            H = HWN[0];
            W = HWN[1];
            N = HWN[2];
            var SP = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            SH = SP[0];
            SW = SP[1];
            S = Console.ReadLine();
            T = Console.ReadLine();
            var ans = false;
            if (IsOkWide() && IsOkHeight())
            {
                ans = true;
            }
            Console.WriteLine(ans ? "YES" : "NO");
        }

        static bool IsOkWide()
        {
            var min = 1;
            var max = W;
            for (int i = (int)N - 1; i >= 0; i--)
            {
                if(T[i] == 'L')
                {
                    max = Min(max + 1, W);
                }else if (T[i] == 'R')
                {
                    min = Max(min - 1, 1);
                }

                if (S[i] == 'L')
                {
                    min++;
                }else if (S[i] == 'R')
                {
                    max--;
                }

                if(min > max)
                {
                    return false;
                }
            }
            return (min <= SW) &&(SW <= max);
        }

        static bool IsOkHeight()
        {
            var min = 1;
            var max = H;
            for (int i = (int)N - 1; i >= 0; i--)
            {
                if (T[i] == 'U')
                {
                    max = Min(max + 1, H);
                }
                else if (T[i] == 'D')
                {
                    min = Max(min - 1, 1);
                }

                if (S[i] == 'U')
                {
                    min++;
                }
                else if (S[i] == 'D')
                {
                    max--;
                }

                if (min > max)
                {
                    return false;
                }
            }
            return (min <= SH) && (SH <= max);
        }

    }
}


Measured memory_bytes: 29584
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();

        for (int i = 1; i <= n; i++) {
            if (i % 3 == 0) {
                System.out.print(" " + i);
            } else {
                int x = i;
                while (x != 0) {
                    if (x % 10 == 3) {
                        System.out.print(" " + i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
        System.out.println();
    }
}

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

typedef long long int ll;
ll n, m;
priority_queue<ll, vector<ll>, greater<ll>> mn;
priority_queue<ll> mx;
ll sl, sr, mid;
ll q;
ll b;
int main()
{
    cin >> q;
    rep(i, q)
    {
        ll x;
        cin >> x;
        if (x == 1)
        {
            ll y, z;
            cin >> y >> z;
            b += z;
            if (mx.empty() || mx.top() <= y)
            {
                mn.push(y);
                sr += y;
            }
            else
            {
                mx.push(y);
                sl += y;
                ll t = mx.top();
                sl -= t;
                sr += t;
                mn.push(t);
                mx.pop();
            }
            while (mn.size() > mx.size())
            {
                ll t = mn.top();
                mn.pop();
                sr -= t;
                mx.push(t);
                sl += t;
            }
        }
        else
        {
            ll t = mx.top();
            cout << t << " " << sr - (sl - t) + (ll)(mx.size() - mn.size() - 1LL) * t + b << endl;
        }
    }
}

Measured memory_bytes: 3828
H,W=map(int,input().split())
S=list(list(input()) for _ in range(H))
ans=0
for i in S:
    for j in range(W):
        if i[j]!='#' and j!=W-1:
            ans+=1
        elif i[j]!='#'and j==W-1 :
            for k in range(ans+1):
                i[j-k]=ans+1
            ans=0
        else:
            for k in range(1,ans+1):
                i[j-k]=ans
            ans=0
S_t=list(map(list,zip(*S)))
ans=0
for i in S_t:
    for j in range(H):
        if i[j]!='#' and j!=H-1:
            ans+=1
        elif i[j]!='#'and j==H-1 :
            for k in range(ans+1):
                i[j-k]+=ans+1
            ans=0
        else:
            for k in range(1,ans+1):
                i[j-k]+=ans
            ans=0
            i[j]=0
c=0
for i in S_t:
    c=max(c,max(i))
print(c-1)

Measured memory_bytes: 341384
#include<bits/stdc++.h>
using namespace std;
long long gcd(int x,int y);
long long lcm(int x,int y);
int main(){
    long long a,b;
    int c,d;
    cin>>a>>b>>c>>d;
    long long divc=b/c;
    long long divd=b/d;
    //cout<<lcm(c,d)<<endl;
    cout<<(b-(divc+divd-b/lcm(c,d)))-((a-1)-((a-1)/c+(a-1)/d-(a-1)/lcm(c,d)))<<endl;
    return 0;
}
long long gcd(int x,int y){
    if(y==0)return x;
    else return gcd(y,x%y);
}
long long lcm(int x,int y){
    return x/gcd(x,y)*y;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    int p = 0;
    while (p < s.length() && s[p] != 'C')
        p++;
    while (p < s.length() && s[p] != 'F')
        p++;
    cout << (p == s.length() ? "No" : "Yes") << endl;
    return 0;
}


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

int main(){
  ll n,x,count=0;
  cin >> n >> x;
  vector<ll> v(n,0);
  r(i,n)cin >> v.at(i);
  sort(v.begin(),v.end());
  r(i,n){
    x-=v.at(i);
    if(i<n-1&&x>=0)count++;
    if(i==n-1&&x==0)count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin.readline
na = lambda: map(int, stdin().split())
ns = lambda: stdin().rstrip()
ni = lambda: int(ns())

def main():
  n, k = na()
  s = ns()

  ans = n-1
  for i in range(1, n):
    if s[i] != s[i-1]:
      ans -= 1
  print(min(n-1, ans+2*k))
main()

Measured memory_bytes: 3316
#include<stdio.h>
#define N 1000000

int main(){
  int n,i,j,k,l,x,c=0,m=0;
  int a[N],g[N];

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&a[i]);

  g[0]=1;
  for(i=1;g[i-1]<=n;i++){
    m++;
    g[i]=g[i-1]*3+1;
    if(m>100)break;
  }

  for(i=0;i<m/2;i++){
    x=g[i];
    g[i]=g[m-i-1];
    g[m-i-1]=x;
  }

  for(i=0;i<m;i++){
    for(j=g[i];j<n;j++){
      l=a[j];
      k=j-g[i];

      while(k>=0 && a[k]>l){
	a[k+g[i]]=a[k];
	k=k-g[i];
	c++;
      }
      a[k+g[i]]=l;
    }
  }

  printf("\n%d\n",m);
  for(i=0;i<m;i++){
    printf("%d ",g[i]);
    
  }
  printf("\n%d\n",c);

  for(i=0;i<n;i++)printf("%d\n",a[i]);

  return 0;
}



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

struct AS{
    long A;
    long num;

    AS(long A2, long num2)
    {
        A=A2;
        num=num2;
    }

    bool operator < (const AS & another) const
    {
        return A < another.A;
    }
};


int main()
{
    long N;
    std::vector<AS> AS1;
    std::cin >> N;
    for(long i=0; i<N;i++){
        long h;
        std::cin >> h;
        AS1.push_back(AS(h,i));
    }
    std::sort(AS1.begin(),AS1.end());
    long big_num=AS1[N-1].num;
    for(int i=0; i<N; i++){
        if(i==big_num){
            std::cout << AS1[N-2].A << std::endl;
        }else{
            std::cout << AS1[N-1].A << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    LL Q,H,S,D,N;
    cin >> Q >> H >> S >> D >> N;
    LL one = min(S, min(2*H, 4*Q));
    LL res = 0;
    if(N>=2){
        LL two = min(2*one, D);
        res += (N/2) * two;
        N -= (N/2) * 2;
    }
    res += N*one;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    ll x, k, d;
    cin >> x >> k >> d;

    if (x < 0) x = -x;

    ll n = x / d;
    if (n >= k) {
        cout << x - k * d << '\n';
    } else {
        if (n % 2 == k % 2) {
            cout << x - n * d << '\n';
        } else {
            cout << abs(x - (n + 1) * d) << '\n';
        }
    }
}


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

int main(){
	int n, cnt = 0;
	string s, ans = "YES";
	
	cin >> n;
	
	for(int i = 0 ; i < n ;i++){
		cin >> s;
		if(s == "A"){
			cnt++;
			}
		else{
			cnt--;
			if(cnt < 0){
				ans = "NO";
				}
			}
		}
	
		if(cnt != 0){
			ans = "NO";
			}
	
	cout << ans << endl;
	
	return 0;
	}

Measured memory_bytes: 3192
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String A = scan.next();
        String B = scan.next();
        BigInteger a = new BigInteger(A);
        BigInteger b = new BigInteger(B);
        String answer = "";
        int compare = a.compareTo(b);
        if (compare == 0) {
            answer = "EQUAL";
        } else if (compare < 1) {
            answer = "LESS";
        } else {
            answer = "GREATER";
        }
        System.out.println(answer);
    }
}


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

int main()
{
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  long long sum = 0;
  vector<long long> V(N + 1, 0); //累積和
  for (int i = 0; i < N; i++)
  {
    sum += A.at(i);
    V.at(i + 1) = sum;
    //cout << sum << endl;
  }
  
  sort(V.begin(), V.end());
  V.push_back(V.at(N) + 1);
  //for (int i = 0; i < N + 1; i++) cout << V.at(i) << endl;
  
  long long cnt = 1;
  long long ans = 0;
  for (int i = 0; i < N + 1; i++)
  {
    if (V.at(i) == V.at(i + 1)) cnt++;
    else
    {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  
  cout << ans << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, BN;
int S[300010];

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

	cin >> N;
	BN = 1 << N;
	int maxs = 0;
	multiset<int> sset;
	rep(i, 0, BN)
	{
		cin >> S[i];
		chmax(maxs, S[i]);
		sset.insert(S[i]);
	}

	vector<int> C;
	C.push_back(maxs);
	sset.erase(sset.find(maxs));

	rep(i, 0, N)
	{
		vector<int> TC;
		for (auto c : C)
		{
			auto itr = sset.lower_bound(c);
			if (itr == sset.begin())
			{
				cout << "No" << endl;
				return 0;
			}
			itr--;
			TC.push_back(*itr);
			sset.erase(itr);
		}
		rep(j, 0, SZ(TC))
		{
			C.push_back(TC[j]);
		}
		sort(all(C), greater<int>());
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 17508
import collections
k = int(input())
li = [str(i) for i in range(1,10)]
st_li = li[:]

q = collections.deque(li)
count = 0
n = 10 ** 10

for i in range(1,n):
    # print(st_li)
    a = q.popleft()
    num = int(a[-1])
    # print(num)
    if num != 0:
        aa = a + str(num-1)
        st_li.append(aa)
        q.append(aa)
        count += 1
    aa = a + str(num)
    st_li.append(aa)
    q.append(aa)
    count += 1
    if num != 9:
        aa = a + str(num+1)
        st_li.append(aa)
        q.append(aa)
        count += 1
    if count > k:
        print(st_li[k-1])
        exit(0)


Measured memory_bytes: 55132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,c,sum;
		a = scan.nextInt();
		b = scan.nextInt();
		
		sum = a % b;
		
		if(sum == 0) sum = a / b;
		else sum = a / b + sum;
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 26180
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, int, int) {
	a, b, c := scanInt(sc), scanInt(sc), scanInt(sc)
	return a, b, c
}

func resolve(a, b, c int) int {
	return exchangeNum([]int{a, b, c})
}

func allSame(v []int) bool {
	sort.Sort(sort.IntSlice(v))
	return v[0] == v[len(v)-1]
}

func all(v []int, pred func(v int) bool) bool {
	for _, i := range v {
		if !pred(i) {
			return false
		}
	}
	return true
}

func next(v []int) (n []int) {
	n = make([]int, len(v))
	n[0] = (v[0] + v[len(v)-1]) >> 1
	for i := 1; i < len(v); i++ {
		n[i] = (v[i] + v[i-1]) >> 1
	}
	return n
}

func exchangeNum(v []int) int {
	num := 0
	for all(v, func(v int) bool { return v%2 == 0 }) {
		if allSame(v) {
			if v[0]%2 == 0 {
				return -1
			} else {
				return num
			}
		}
		v = next(v)
		num++
	}
	return num
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}


Measured memory_bytes: 1780
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int num = Integer.parseInt(sc.next()) + Integer.parseInt(sc.next());
            int ans = 1;

            while (num / 10 != 0) {
                ans++;
                num /= 10;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 26288
#include <iostream>

using namespace std;

int main(void){
  int A, B, C;
  cin >> A >> B >> C;

  if( (A == B && A != C)|(B == C && B != A) | (C == A && C != B)){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }


  return 0;
}

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

using namespace std;

long euclid(long a, long b)
{
  while(1){
    if(a < b){
      long temp;
      temp = a;
      a = b;
      b = temp;
    }
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(void)
{
  long N, X;
  cin >> N >> X;
  vector<long> vi(N+1);
  for(int i = 0; i < N; i++){
    cin >> vi[i];
  }
  vi[N] = X;
  sort(vi.begin(), vi.end());
  long a = vi[1] - vi[0];
  long b;
  long c;
  for(int i = 1; i < N; i++){

    b = vi[i+1] - vi[i];
    a = euclid(a, b);
  }
  cout << a << endl;
  return 0;
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

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


template <typename Monoid>
class BIT {
private:
    vector<Monoid> _bit;
    int _n_max;
    function<Monoid(Monoid&, Monoid&)> _binary_operator;

public:
    BIT(int n, Monoid initial_val, function<Monoid(Monoid&, Monoid&)> binary_operator): 
        _n_max(n), _binary_operator(binary_operator) {
        _bit.resize(_n_max + 1, initial_val);
    }

    void add(int i, Monoid x) {  // 1-indexed
        for(int j = i; j <= _n_max; j += j & -j) 
            _bit.at(j) = _binary_operator(x, _bit.at(j));
    }

    Monoid sum(int i) {  // 1-indexed, sum of [1, i]
        Monoid res = 0;
        for(int j = i; j > 0; j -= j & -j) 
            res = _binary_operator(res, _bit.at(j));
        return res;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI a(n);
    REP(i, n) cin >> a.at(i);
    vector<BIT<int>> bit(n + 1, BIT<int>(k + 1, 0, [](int& lhs, int& rhs) {
        return (lhs % MOD + rhs % MOD) % MOD;
    }));
    bit.at(0).add(0 + 1, 1);
    FOR(i, 1, n)FOR(j, 0, k) {
        ll sum = bit.at(i - 1).sum(j + 1) 
            - bit.at(i - 1).sum(max(j - a.at(i - 1), 0));
        bit.at(i).add(j + 1, (sum + MOD) % MOD);
    }

    cout << (bit.at(n).sum(k + 1) - bit.at(n).sum(k) + MOD) % MOD << ln;
    return 0;
}


Measured memory_bytes: 40192
#!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 list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
print(eval(input()))
"""
#B
n = I()
t = LI()
s = sum(t)
m = I()
for i in range(m):
    p,x = LI()
    p -= 1
    print(s-t[p]+x)
#C
"""
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
for i in d.items():
    if i[0] != 0 and i[1] == 1:
        print(0)
        quit()
    elif i[1] > 2:
        print(0)
        quit()
print(pow(2,n//2,mod))
"""

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

using namespace std;

string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

string ana;
int now;

string Cipher();
string String();
char Letter();

string Cipher() {
  string ret = "";
  while (now < ana.size()) {
    if (ana[now] == ']') break;
    ret += String();
  }
  return ret;
}
string String() {
  char c = ana[now];
  if (c == '[') {
    ++now;
    string ret = Cipher();
    reverse( ret.begin(), ret.end() );
    ++now;
    return ret;
  }
  else {
    string ret = "";
    ret += Letter();
    return ret;
  }
}
char Letter() {
  string ret = "";

  char c = ana[now++];
  if (c == '+') {
    return (char)((Letter()-'A'+1)%26 + 'A');
  }
  else if (c == '-') {
    return (char)((Letter()-'A'-1+26)%26 + 'A');
  }
  else {
    return c;
  }
}

string GetCipher(string str) {
  ana = str;
  now = 0;
  return Cipher();
}

string f(string str) {
  int pos = -1;
  for (int i = 0; i < str.size(); ++i) {
    if (str[i] == '?') {
      pos = i;
      break;
    }
  }
  if (pos < 0) {
    return GetCipher(str);
  }
  else {
    vector<string> v(chars.size());
    for (int i = 0; i < chars.size(); ++i) {
      str[pos] = chars[i];
      v[i] = f(str);
    }
    string ret = v[0];
    for (int i = 0; i < v.size(); ++i) {
      if (v[i] < ret) ret = v[i];
    }
    return ret;
  }
}

int main() {
  string str;
  while ( cin >> str, str != "." ) {
    cout << f(str) << endl;
  }
}

Measured memory_bytes: 1248
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	ll N, c;
	cin >> N;

	if(N <= 9){
		cout << N << endl;
		return;
	}else if(N >= 10 && N < 100){
		cout << 9 << endl;
		return;
	}else if(N >= 100 && N <1000){
		cout << N - 90 << endl;
		return;
	}else if(N >= 1000 && N < 10000){
		cout << 909 << endl;
		return;
	}else if(N >= 10000 && N < 100000){
		cout << N - 9090 << endl;
	}else{
		cout << 90909 << endl;
	}




}

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

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
#define nl endl
using namespace std;

void code()
{       
    string s,t;
    cin>>s>>t;
    int cou = 0;
    int n = s.size();
    for(int i=0; i<n; i++)
    {
     	  	if(s[i]!=t[i])	
     	  		cou++;
    }
    cout<<cou;
}
signed main()

{

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
        
        FAST_IO;
        int t = 1;

        // cin>>t;

        while(t--)
        {
                code();
        }
        

#ifndef ONLINE_JUDGE
cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#endif

        return 0;
}


Measured memory_bytes: 3796
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int R = sc.nextInt();
    if (N >= 10) {
      System.out.println(R);
    } else {
      System.out.println(R + 100 * (10 - N));
    }
  }
}

Measured memory_bytes: 22868
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Ti4 tuple<int, int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n, a, b, c, x; 
    
    while (cin >> n >> a >> b >> c >> x) {
        if (n == 0) return 0;
        int ans = 0, y[n];
        for (int i = 0; i < n; i++) {
            cin >> y[i];
        }
        for (int i = 0; i < n; i++) {
            while (y[i] != x && ans <= 10001) {
                x = (a*x + b) % c;
                ans++;
            }
            if (ans > 10001) break;
            x = (a*x + b) % c;
            ans++;
        }
        ans--;
        cout << (ans > 10000 ? -1 : ans) << endl;
    }
}



Measured memory_bytes: 3016
#include<stdio.h>
#define MAX 2000000

int H,A[MAX+1];
void maxHeapify(int);
void swap(int *,int *);

int main(){
  int i;
  scanf("%d",&H);

  for(i = 1;i <= H;i++){
    scanf("%d",&A[i]);
  }

  for(i = H/2;i >= 1;i--){
    maxHeapify(i);
  }

  for(i = 1;i <= H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}
void maxHeapify(int i){
  int l,r,largest;
  l = 2*i;
  r = 2*i+1;

  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;

if(largest != i){
  swap(&A[i],&A[largest]);
  maxHeapify(largest);
}
}
void swap(int *A,int *B){
  int temp;
  temp = *A;
  *A = *B;
  *B = temp;
  }

Measured memory_bytes: 2556
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 2e5+7;
using LL = int_fast64_t;
int n;
LL A[MAXN],f[MAXN];
int main(){
    ____();
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i];
    if(!(n&1)){
        f[1] = A[1]; f[2] = A[2];
        for(int i = 2; i <= n / 2; i++){
            f[i*2] = max(f[(i-1)*2-1],f[(i-1)*2]) + A[i*2];
            f[i*2-1] = f[(i-1)*2-1] + A[i*2-1];
        }
        cout << max(f[n],f[n-1]) << endl;
    }
    else{
        f[1] = A[1]; f[2] = A[2]; f[3] = A[3];
        for(int i = 2; i <= n / 2; i++){
            f[i*2+1] = max(max(f[(i-1)*2-1],f[(i-1)*2]),f[(i-1)*2+1]) + A[i*2+1];
            f[i*2] = max(f[(i-1)*2-1],f[(i-1)*2]) + A[i*2];
            f[i*2-1] = f[(i-1)*2-1] + A[i*2-1];
        }
        cout << max(max(f[n],f[n-1]),f[n-2]) << endl;
    }
    return 0;
}

Measured memory_bytes: 6704
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
using vint = std::vector<int>;
using vvint = std::vector<std::vector<int>>;
using namespace std;
ll mod = 1e9 + 7;

class unionFind{

private:
    std::vector<int> par;
    std::vector<int> rank;

public:
    unionFind(int N) : par(N), rank(N){
        
        for(int i = 0; i < N; i++){
            par[i] = i;
            rank[i] = 0;
        }

    }

    int find(int x){

        if(par[x] == x)return x;
        else return par[x] = find(par[x]);

    }

    void unite(int x, int y){

        x = find(x);
        y = find(y);
        if(x == y)return;
        if(rank[x] < rank[y])par[x] = y;
        else{
            par[y] = x;
            if(rank[x] == rank[y])rank[x]++;
        }

    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

};

int main(){

    
    int N, K, L; cin >> N >> K >> L;//まずは入力の受け取り
    unionFind road(N), rail(N);//道路用と鉄道用とで二つunionFindクラスを用意してあげる
    for(int i = 0; i < K; i++){
        int p, q; cin >> p >> q;//入力を受け取る
        road.unite(p - 1, q - 1);//pとqは連結しているため併合してあげる(扱いやすいように0-indexedにする)
    }
    //鉄道においても同じことをしてあげる
    for(int i = 0; i < L; i++){
        int r, s; cin >> r >> s;
        rail.unite(r - 1, s - 1);
    }

    vector<pair<int, int>> p(N);//各頂点iについて、道路においてグループ～、鉄道においてグループ～であるという情報を格納する配列を作ってあげる
    map<pair<int, int>, int> m;//上のような情報を連想配列形式で扱ってあげる
    for(int i = 0; i < N; i++){
        p[i] = make_pair(road.find(i), rail.find(i));
        m[p[i]]++;
    }

    for(int i = 0; i < N; i++){
        cout << m[p[i]] << " ";//最後に結果を出力してあげる
    }




    return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
	
	int n, T; cin >> n >> T;
	bool ok = false;
	int ans = 100000000;
	for (int i = 0; i < n; i++) {
		int c, t; cin >> c >> t;
		if (T < t) continue;
		if (chmin(ans, c)) {
			ok = true;
		}
	}
	if (ok) cout << ans << endl;
	else cout << "TLE" << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    ll N,D;
    cin >> N >> D;
    int counter=0;
    rep(i,N){
        ll X,Y;cin >> X >> Y;
        if(X*X+Y*Y<=D*D)counter++;
    }   
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))

ans = 1
x = 0

for i in range(n-1):
    if a[i] < a[i+1]:
        if x == -1:
            ans += 1
            x = 0
        elif x == 0:
            x = 1
    elif a[i] > a[i+1]:
        if x == 1:
            ans += 1
            x = 0
        elif x == 0:
            x = -1
print(ans)

Measured memory_bytes: 14228
import collections

n,m=list(map(int,input().split()))
#チェックしたか
checked=[False]*n
way=[[] for i in range(n)]
for i in range(m):
  x,y,z=list(map(int,input().split()))
  x-=1
  y-=1
  way[x].append(y)
  way[y].append(x)
ans=0

for i in range(n):
  if checked[i]==False:
    #木に繋がっているノードをチェック済にする
    q=collections.deque()
    q.append(i)
    while len(q)>0:
      c=q.popleft()
      for i in way[c]:
        if not checked[i]:
          checked[i]=True
          q.append(i)
    ans+=1
print(ans)

Measured memory_bytes: 27740
# coding: utf-8
import copy
N,K=map(int,input().split())
A=list(map(int,input().split()))
for k in range(K):
    imos=[0 for i in range(N+1)]
    
    for i in range(N):
        imos[max(i-A[i],0)]+=1
        imos[min(i+A[i]+1,N)]-=1
    tmp=[imos[0]]
    for i in range(N-1):
        tmp.append(tmp[i]+imos[i+1])
    A=copy.deepcopy(tmp)
    if set(A)==set([N]):
        break
    
print(*A)

Measured memory_bytes: 180804
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string str;

const int MAX = 210000;
vector<int> place[30];
int nextc[MAX][30];


int dp[MAX];
int ne[MAX];

string solve() {
    for (int i = 0; i < str.size(); ++i) {
        int id = str[i] - 'a';
        place[id].push_back(i);
    }
    for (int i = 0; i < 26; ++i) {
      char c = 'a' + i;
      string res = ""; res += c;
      if (place[i].empty()) return res;
    }
    for (int i = 0; i < str.size(); ++i) {
      for (int j = 0; j < 26; ++j) {
	int it = upper_bound(place[j].begin(), place[j].end(), i) - place[j].begin();
	if (it == place[j].size()) nextc[i][j] = -1;
	else nextc[i][j] = place[j][it];
      }
    }

    for (int i = 0; i < MAX; ++i) dp[i] = 1<<29, ne[i] = -1;
    dp[(int)str.size() - 1] = 2;
    for (int i = (int)str.size() - 2; i >= 0; --i) {
      for (int j = 0; j < 26; ++j) {
	if (nextc[i][j] != -1) {
	  if (chmin(dp[i], dp[nextc[i][j]] + 1)) {
	    ne[i] = j;
	  }
	}
	else {
	  if (chmin(dp[i], 2)) {
	    ne[i] = j;
	  }
	}
      }
      //cout << i << ": " << dp[i] << endl;
    }

    string res = "";
    int Min = 1<<29;
    int MinI = -1;
    for (int j = 0; j < 26; ++j) {
      int ind = nextc[0][j];
      if (str[0] == (char)('a' + j)) ind = 0;
      if (chmin(Min, dp[ind])) {
	MinI = ind;
      }
    }
    res += str[MinI];
    do {
      int ch = ne[MinI];
      res += (char)('a' + ch);
      MinI = nextc[MinI][ch];
    } while (MinI != -1);

    return res;
}


int main() {
    while (cin >> str) {
        for (int i = 0; i < 30; ++i) place[i].clear();
        cout << solve() << endl;
    }
}









Measured memory_bytes: 26500
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

lb = 10 ** (N - 1) if N > 1 else 0
for n in range(lb, 10 ** N):
    flag = True
    for s, c in X:
        flag &= n // (10 ** (N - s)) % 10 == c

    if flag:
        print(n)
        break
else:
    print(-1)


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

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

const int N = 1e5 + 5, M = 27, mod = 1e9 + 7;

int cnt[M];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	fill(cnt, cnt + 26, 1);
	for (auto ch : s)
		cnt[ch - 'a']++;
	for (int i = 0; i < 26; i++)
		ans = (1LL * ans * cnt[i]) % mod;
	cout << (ans - 1 + mod) % mod << "\n";
}


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

struct Node{
  int  key;
  Node *next;
  Node *prev;
};

Node *nil;

void initialize(){
  nil=(Node*)malloc(sizeof(Node));
  nil->prev=nil;
  nil->next=nil;
}

void insert(int key){
  Node *in;
  in = (Node*)malloc(sizeof(Node));

  in->key=key;
  in->next=nil->next;
  in->prev=nil;
  nil->next=in;
  in->next->prev=in;
}

void delFirst(void){
  nil->next=nil->next->next;
  nil->next->prev=nil;
}

/*
void delLast(void){
  Node* i;
  
  for(i=nil; i->next!=nil; i=i->next);
  i->prev->next=nil;
}
*/

void delLast(void){
  nil->prev=nil->prev->prev;
  nil->prev->next=nil;
}

void del(int key){
  Node* i;

  for(i=nil->next; i!=nil; i=i->next){
    if(i->key == key){
      i->next->prev=i->prev;
      i->prev->next=i->next;
      break;
    }
  }
}

void print(void){
  for(Node* i=nil->next; i!=nil; i=i->next){
    if(i->prev==nil) printf("%d", i->key);
    else printf(" %d", i->key);
  }
  printf("\n");
}

int main(void){
  int  n, num;
  char com[12];

  initialize();
  
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%s %d", com, &num);
    if(com[0] == 'i') insert(num);
    else if(com[6] == 'F') delFirst();
    else if(com[6] == 'L') delLast();
    else del(num);
  }

  print();

  return 0;
}



Measured memory_bytes: 37480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 998244353;

ll const N = 1e6 + 10;
bool vis[N] = {0}, done[N] = {0};
ll f[N];

void solve() {
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        f[a[i]]++;
        if(!done[a[i]]) {
            for(ll j = 2 * a[i]; j <= N; j += a[i]) vis[j] = 1;
            done[a[i]] = 1;
        }
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        if(!vis[a[i]] && f[a[i]] == 1) ans++;
    }
    cout << ans;
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;   
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

const long long MOD = 1000000007;

int N, K;
vector<vector<int>> G;
long long res = 1;

void dfs(int cur, int pre, int num) {
  res = res * num % MOD;
  num = K - 1;
  if (pre != -1) num--;

  for (auto e : G[cur]) {
    if (e == pre) continue;
    dfs(e, cur, num);
    num--;
  }
}

int main() {
  cin >> N >> K;
  G.assign(N, vector<int>());
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0, -1, K);

  cout << res << endl;

  return 0;
}

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

int ans[1000][2][12];//二つ目の次元の0の0に数列の長さ、0の1に操作回数、1に答えの数列

int counter=0,flag=0;

void solve(){
	int n;
	cin >> n;
	if(n==0){flag=1;return;}
	ans[counter][0][0]=n;
	
	int S[12];//数列
	for(int i=0;i<n;i++){
		cin >> S[i];
	}
	
	bool check=false;//操作の有無のフラグ
	int time=0;//操作回数
	do{
		map<int,int> marker;
		for(int i=0;i<n;i++){
			marker[S[i]];
			marker[S[i]]++;
		}
		check=false;
		for(int i=0;i<n;i++){
			if(S[i]!=marker[S[i]]){
				check=true;
				S[i]=marker[S[i]];
			}
		}
		if(check) time++;
	}while(check);
	
	ans[counter][0][1]=time;
	for(int i=0;i<n;i++){
		ans[counter][1][i]=S[i];
	}
	counter++;
}

int main(){
	while(flag==0)solve();
	for(int i=0;i<counter;i++){
		cout << ans[i][0][1] << endl;
		for(int j=0;j<ans[i][0][0]-1;j++){
			cout << ans[i][1][j]<<" ";
		}
		cout << ans[i][1][ans[i][0][0]-1] << endl;
	}
}
			
	
	

Measured memory_bytes: 1208
#include <iostream>
#include <stack>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	string Sa;
	string Sb;
	string Sc;
	cin >> Sa >> Sb >> Sc;
	char s;

	int sa = 0;
	int sb = 0;
	int sc = 0;

	if (sa == Sa.size()) {
		cout << "A" << "\n";
		return 0;
	}
	s = Sa[sa];
	while (1) {
		switch (s) {
		case 'a': {
			if (sa == Sa.size()) {
				cout << "A" << "\n";
				return 0;
			}
			s = Sa[sa];
			sa++;
			break;
		}
		case 'b': {
			if (sb == Sb.size()) {
				cout << "B" << "\n";
				return 0;
			}
			s = Sb[sb];
			sb++;
			break;
		}
		case 'c': {
			if (sc == Sc.size()) {
				cout << "C" << "\n";
				return 0;
			}
			s = Sc[sc];
			sc++;
			break;
		}
		}
	}
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000 + 1024
)

func main() {

	scanner := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)

	/* 1st line X Y Z K */
	var x, y, z, k int
	fmt.Scan(&x, &y, &z, &k)

	/* 2nd line Ai */
	scanner.Scan()
	strA := strings.Split(scanner.Text(), " ")

	/* 3rd line Bi */
	scanner.Scan()
	strB := strings.Split(scanner.Text(), " ")

	/* 4th line Ci */
	scanner.Scan()
	strC := strings.Split(scanner.Text(), " ")

	na, nb, nc := make(Int64Slice, x), make(Int64Slice, y), make(Int64Slice, z)
	for i, s := range strA {
		na[i], _ = strconv.ParseInt(s, 10, 64)
	}
	for i, s := range strB {
		nb[i], _ = strconv.ParseInt(s, 10, 64)
	}
	for i, s := range strC {
		nc[i], _ = strconv.ParseInt(s, 10, 64)
	}

	nab := make(Int64Slice, x*y)
	i := 0
	for _, a := range na {
		for _, b := range nb {
			nab[i] = a + b
			i++
		}
	}
	sort.Sort(nab)
	m := min(len(nab), k)
	n := make(Int64Slice, m*z)
	j := 0
	for i := 0; i < m; i++ {
		for _, c := range nc {
			n[j] = nab[i] + c
			j++
		}
	}
	sort.Sort(n)
	for i := 0; i < k; i++ {
		fmt.Println(n[i])
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

type Int64Slice []int64

func (s Int64Slice) Len() int {
	return len(s)
}
func (s Int64Slice) Less(i, j int) bool {
	return s[j] < s[i]
}
func (s Int64Slice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}


Measured memory_bytes: 33024