akhauriyash/Code-Regression huggingface dataset:
s = str(input())

def dfs(i,f,sum):
  if i == 3:
    if sum == 7:
      print(f + '=7')
      exit()
  else:
    dfs(i+1,f+'+'+s[i+1],sum+int(s[i+1]))
    dfs(i+1,f+'-'+s[i+1],sum-int(s[i+1]))

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

Measured memory_bytes: 9164
n = int(input())
l = list(map(int, input().split()))
a = sum(l)

min_s = float('inf')
x = 0
for i in range(n-1):
  x += l[i]
  s = abs(a-2*x)
  if s <= min_s:
    min_s = s
print(min_s)

Measured memory_bytes: 76752
#include<stdio.h>
int main(){
  int a,b,c,d,ans=0;
  scanf("%d%d",&a,&b);
  scanf("%d%d",&c,&d);
  if(a!=c){
    ans=1;
  }
  else{
    ans=0;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String str1 = in.next();
        String str2 = in.next();
        int a = Integer.parseInt(str1);
        int b = Integer.parseInt(str2);
        if(a > b) {
        System.out.println("a > b");
        }else if(a < b) {
        System.out.println("a < b");
        }else if(a == b){
        System.out.println("a == b");}
        
    }
    
}

Measured memory_bytes: 26172
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        long K = sc.nextLong();
        
        Gluttony gl = new Gluttony(N, K);
        
        for(int i = 0; i < N; i++){
            gl.A[i] = sc.nextInt();
        }
        sc.nextLine();
        for(int i = 0; i < N; i++){
            gl.F[i] = sc.nextInt();
        }
        
        System.out.println(gl.find());
    }
}

class Gluttony {
    public Integer[] A;
    public Integer[] F;
    public int N;
    public long K;

    
    public Gluttony(int N, long K){
        this.N = N;
        this.K = K;
        A = new Integer[N];
        F = new Integer[N];
    }
    
    public long find(){
        long left = -1;
        long right = 1000000000005L;
        
        sort();
        
        while(right - left > 1){
            long mid = (left + right) / 2;

            if( is(mid) ){
                right = mid;
            } else {
                left = mid;
            } 
        }
        
        return right;
    }
    
    private void sort(){
        Arrays.sort(A);
        Arrays.sort(F, Collections.reverseOrder());
    }
    
    private boolean is(long mid){
        
        long sum = 0;
        
        for(int i = 0; i < N; i++){
            sum += Math.max( A[i] - mid / F[i], 0);
        }
        
        return sum <= K;
    }
}




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

using namespace std;

#define N 1
int a, b, c, d, e, f;

bool can(int i, int j) {
    bool ok = false;
    for (int l = 0; l * a <= j; l++) {
        if ((j - l * a) % b == 0) {
            ok = true;
            break;
        }
    }
    if (!ok)
        return false;
    ok = false;
    for (int l = 0; l * c <= i; l++) {
        if ((i - l * c) % d == 0) {
            ok = true;
            break;
        }
    }
    return ok;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b >> c >> d >> e >> f;
    double cc = -1;
    int cci = -1, ccj = -1;
    for (int j = a; j <= f / 100; j++) {
        for (int i = 0; i <= e * j; i++)
            if (can(i, j) && i + j * 100 <= f) {
                if (cc < 1.0 * i / j)
                    cc = 1.0 * i / j, cci = i, ccj = j;
            }
    }
    cout << (cci + ccj * 100) << " " << cci << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,q;
ll s;
ll a[100001],b[100001],c[100001];
map<ll,int> mp;
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n)
	cin>>a[i];
	rep(i,n)
	s+=a[i];
	cin>>q;
	rep(i,n)
	mp[a[i]]++;
	rep(i,q){
		cin>>b[i]>>c[i];
		s+=mp[b[i]]*(c[i]-b[i]);
		mp[c[i]]+=mp[b[i]];
		mp[b[i]]=0;
		cout<<s<<"\n";
	}
	re 0;
}

Measured memory_bytes: 11768
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use feature qw/say/;

my @num = do { my $line = <STDIN>; chomp $line; split(//, $line) };
my $size = scalar(@num);
my $sum = 0;
for my $x (0..((1 << $size - 1)-1)) {
    my $cur = 0;
    my $tmp = $num[0];
    for my $i (0..$size-2) {
        if ($x & (1 << $i)) {
            $cur += $tmp;
            $tmp = $num[$i+1];
        } else {
            $tmp = $tmp * 10 + $num[$i+1];
        }
    }
    $sum += $cur + $tmp;
}
say $sum;

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int r[20000];
int main(){
	int n,s,ans;
	while(true){cin>>n>>s;if(n==0&&s==0)break;ans=0;for(int i=0;i<n;i++){cin>>r[i];for(int j=0;j<i;j++)if(r[i]+r[j]>s)ans++;}cout<<ans<<endl;}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000



int main(){
	
	int N;
	cin>>N;
	
	int ans = 0;
	
	for(int i=1;i<=N;i+=2){
		int cnt = 0;
		for(int j=1;j<=i;j++){
			if(i%j==0)cnt++;
		}
		if(cnt==8)ans++;
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

constexpr auto mod = 998'244'353;

static array<array<large, 3005>, 3005> dp;

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

    auto cnt = 1LL;

    dp[a][b] = 1;

    for (auto Ai = a; Ai < c; ++Ai) {
        dp[Ai + 1][b] = dp[Ai][b] * b;
        dp[Ai + 1][b] %= mod;
    }
    for (auto Bi = b; Bi < d; ++Bi) {
        dp[a][Bi + 1] = dp[a][Bi] * a;
        dp[a][Bi + 1] %= mod;
    }

    for (auto Ai = a; Ai < c; ++Ai) {
        for (auto Bi = b; Bi < d; ++Bi) {
            auto xxx = 0LL;
            auto yyy = 0LL;
            auto zzz = 0LL;

            xxx = dp[Ai + 1][Bi] * large(Ai + 1);
            yyy = dp[Ai][Bi + 1] * large(Bi + 1);
            zzz = large(Ai) * large(Bi) % mod;
            zzz *= dp[Ai][Bi];
            zzz %= mod;

            xxx %= mod;
            yyy %= mod;
            dp[Ai + 1][Bi + 1] = ((xxx + yyy) % mod + mod - zzz) % mod;
        }
    }

    cout << dp[c][d] << endl;
    return 0;
}


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

int main()
{
int n;scanf("%d",&n);
int N=n;printf("%d:",N);
for(int i=2;i<pow(N,0.5)+1;i++)
{
if(n%i==0){printf(" %d",i);n/=i;i--;}
}
if(n!=1)printf(" %d",n);
printf("\n");
}



Measured memory_bytes: 3392
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let n: usize = read();
    let mut total = 0;
    for i in 1..(n + 1) {
        if i % 2 == 0 { continue; }
        let mut count = 0;
        for j in 1..(i + 1) {
            if i % j == 0 { count += 1; }
        }
        if count == 8 { total += 1; }
    }
    println!("{}", total);
}

fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] a;
    a =new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
      for(int i=0;i<n/2;i++){
      int temp = a[i];
      a[i]=a[n-1-i];
      a[n-1-i]=temp;
      }
      for(int i=0;i<n;i++){
        if(i!=n-1){
        System.out.print(a[i] + " ");
        }else{
          System.out.print(a[i]);
        }
      }
      System.out.println();
  sc.close();
 }
}


Measured memory_bytes: 26324
n = int(input())
s = input()

num = [0,1,2,3,4,5,6,7,8,9]
memo = []
for i in num:
  for j in num:
    for k in num:
      memo.append(str(num[i]) + str(num[j]) + str(num[k]))

ans = 0

for i in memo:
  x = 0
  for j in range(n):
    if i[x] == s[j]:
      x += 1
      if x == 3:
        break
  if x == 3:
    ans += 1
    
print(ans)

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

int main(void)
{
  int a, b, c, k;
  int ans = 0;

  cin >> a >> b >> c >> k;

  if (k <= a)
  {
    ans += k;
  }
  else
  {
    ans += a;
    k -= (a + b);

    if (k > 0)
    {
      ans -= k;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<queue>
using namespace std;
#define MAX 100
#define NIL -1

int n, T[MAX+1][MAX+1], d[MAX+1];
string color[MAX+1];
queue<int> Q;

void search(int u){
  Q.push(u);
  while(!Q.empty()){
    u = Q.front();
    color[u] = "black";
    for ( int i = 1; i <= n; i++){
      if ( T[u][i] && color[i] == "white"){
        if ( d[u] != NIL){
          d[i] =  d[u] + 1;
          color[i] = "brown";
        }
        Q.push(i);
      }
    }
    Q.pop();
  }
}

int main(){
  cin >> n;

  //init
  for ( int i = 1; i <= n; i++){
    color[i] = "white";
    d[i] = NIL;
    for ( int j = 0; j <= n; j++){
      T[i][j] = 0;
    }
  }

  int u, k, v;
  for (int i = 1; i <= n; i++ ){
    cin >> u >> k;
    for ( int j = 0; j < k; j++){
      cin >> v;
      T[u][v] = 1;
    }
  }

  d[1] = 0;
  for ( int i = 1; i <= n; i++){
    search(i);
  }

  for ( int i = 1; i <= n; i++){
    cout << i << " " << d[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3236
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>      
#include <numeric> 
#include <iterator>
#include <map> 
#include <boost/math/common_factor.hpp>
using namespace std; 
#define ll long long int
int main()
{
  ll n,i,p=1,q=0;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=0;i<n;i++)
  {
    if(a[i]==p)
     p++;
    else
      q++;
  }
  if(p==1)
    cout<<-1<<endl;
  else
    cout<<q<<endl;
  
  
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#define ONLINE_JUDGE
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#define pii pair<int, int>
#define makep make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main0 ();
int main () {
	#ifndef ONLINE_JUDGE
		freopen("C:\\Users\\98497\\Desktop\\code\\file.in", "r", stdin);
	#endif
	ios::sync_with_stdio(false);
	main0();
	#ifndef ONLINE_JUDGE
		fclose(stdin);
	#endif
	return 0;
}

const int INF = 0x3f3f3f3f;
const int N = 1e3;
const int M = 1e6;

ll c[N], v[N];
ll dp[M];

int main0 () {
	int n, w;
	cin >> n >> w;
	for (int i = 1;i <= n;i++) {
		cin >> c[i] >> v[i];
	}
	
	memset(dp, INF, sizeof dp);
	dp[0] = 0;
	for (int j = 1;j <= n;j++)
		for (int i = 100000;i >= v[j];i--)
			dp[i] = min(dp[i], dp[i - v[j]] + c[j]);
	int p = 100000;
	while (dp[p] > w) p--;
	cout << p << endl;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define output(x) cout<<x<<endl;
#define fre(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define frd(i, a, b) for (int i = (int)(a); i >= b; --i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
const ll mod=1e9+7;
const int maxn = 200010;

ll t[4*maxn];

ll maximum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(maximum(v*2, tl, tm, l, min(r, tm)),maximum(v*2+1, tm+1, tr, max(l, tm+1), r));
}
void update(int v, int tl, int tr, int pos, ll new_val) {
    if (tl == tr) {
        t[v] = max(new_val,t[v]);
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

int h[maxn];
ll a[maxn];

int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);	
	int n;
	cin>>n;
	fre(i,1,n) cin>>h[i];
	fre(i,1,n) cin>>a[i];
	ll ans=0;
	fre(i,1,n){
		ll temp=maximum(1,1,n,1,h[i]-1);
		ans=max(ans,temp+a[i]);
		update(1,1,n,h[i],temp+a[i]);
	}
	output(ans);
	return 0;
}

Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		System.out.println((N + D * 2) / (D * 2 + 1));
	}
}	


Measured memory_bytes: 23764
import math
a = list(map(int,input().split()))

flag = False
for i in range(1001):
  if math.floor(i*0.08) == a[0]:
    if math.floor(i*0.1) == a[1]:
      flag = True
      break

if flag:
  print(i)
else:
  print("-1")

Measured memory_bytes: 3060
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val t = readLine()!!.split(" ").map { it.toInt() }
    val m = readLine()!!.toInt()
    val total = t.sum()
    val drink = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
    drink.forEach {
        println(total - (t[it[0]-1] - it[1]))
    }
}

Measured memory_bytes: 38212
/// In the name of God
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
int main(){
    IOS;
    int n, a, b;
    cin >> n >> a >> b;
    if((a - b)&1)
        cout << "Borys" << endl;
    else
        cout << "Alice" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;
vector<int> G[MAX];
ll ans[MAX];
ll size[MAX];

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

void preDFS(int u,int p){
    for(int to:G[u]){
        if(to==p) continue;
        preDFS(to,u);
        size[u]+=size[to];
    }
    size[u]++;
}
ll sum=1;

void DFS(int u,int p){
    ans[u]=sum;
    for(int to:G[u]){
        if(to==p) continue;
        
        ll a=size[u],b=size[to],c=sum;
        
        sum*=size[to];
        sum%=mod;
        
        size[u]-=size[to];
        sum*=rui(size[u],mod-2);
        sum%=mod;
        size[to]=a;
        
        DFS(to,u);
        
        sum=c;
        
        size[u]=a;
        size[to]=b;
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    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);
    }
    
    preDFS(0,-1);
    
    for(ll i=N-1;i>=1;i--){
        sum*=i;
        sum%=mod;
    }
    
    for(ll i=1;i<N;i++){
        sum*=rui(size[i],mod-2);
        sum%=mod;
    }
    
    DFS(0,-1);
    
    for(int i=0;i<N;i++){
        cout<<ans[i]<<"\n";
    }
}



Measured memory_bytes: 17012
L, R = map(int, input().split())

if R - L > 2020:
  print(0)
else:
  answer = []
  for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
      answer.append((i * j) % 2019)
  
  print(min(answer))

Measured memory_bytes: 75332
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef long long ll;
const int N = 5*(1e5)+5;





int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l,r;
    cin >> l >> r;
    int mn = 2019;
    if ( r-l + 1 >= 2019)
    {
        cout << 0;
        return 0;
    }
    l = l % 2019;
    r = r % 2019;
    if ( l >= r || l == 0)
    {
        cout << 0;
        return 0;
    }
    for ( int i = l; i < r; ++i)
        for ( int j = i + 1; j <= r; ++j)
            mn = min(mn,(i*j)%2019);


    cout << mn;









    return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int K; cin >> K;
	deque<int>dq;
	vector<int>dist(K, INF);
	dq.push_back(1);
	dist[1] = 1;
	while (dq.size()) {
		int v = dq.front();
		dq.pop_front();
		int u = (v + 1) % K;
		if (chmin(dist[u], dist[v] + 1)) {
			dq.push_back(u);
		}
		int w = 10 * v%K;
		if (chmin(dist[w], dist[v])) {
			dq.push_front(w);
		}
	}
	cout << dist[0] << endl;


	return 0;
}


Measured memory_bytes: 1408
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
		int ans = 0;
		ArrayList<Integer>[] bulbs = new ArrayList[M];
		int[] p = new int[M];
		for (int i = 0; i < M; i++) {
			bulbs[i]=new ArrayList<Integer>();
		}
		for (int i = 0; i < M; i++){
			int num = input.nextInt();
			for (int next = 0; next < num; next++) {
				bulbs[i].add(input.nextInt());
			}
		}
		for (int i = 0; i < M; i++) {
			p[i]=input.nextInt();
		}
		//1<<N creates N slots of 0 and 1 placements
		for (int mask = 0; mask < (1<<N); mask++) { //2^N possibilities due to taking or not taking 
			//allowing for 2 options for each step in the N slots
			int[] cnts = new int[M];
			boolean good=true;
			for (int i = 0; i < N; i++) {
				int curnum = mask>>i;
				//System.out.print(curnum%2);
				if (curnum%2==1) {
					for (int bulb = 0; bulb < M; bulb++) {
						if (bulbs[bulb].contains(i+1)) cnts[bulb]++;
					}
				}
			}
			for (int i = 0; i < M; i++) {
				if (cnts[i]%2!=p[i]) good=false;
			}
			if (good) ans++;
			//System.out.print("\n");
		}
		System.out.println(ans);
	}	
}

Measured memory_bytes: 27888
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);
    auto jisa = readln.split.to!(int[]);
    jisa.sort();

    if (n >= 24) {
        writeln(0);
        return;
    }
    else if (n >= 12) {
        auto cnt = new int[](24);

        foreach (i ; 0 .. n) {
            cnt[jisa[i]]++;
        }

        bool z = (cnt[0] > 0);

        foreach (i ; 1 .. 24) {
            if (cnt[i] > 2) z = true;
        }

        writeln(z ? 0 : 1);

        return;
    }

    auto d = new int[](n);

    int ans = 0;

    foreach (cmb ; 0 .. (1<<n)) {
        foreach (i ; 0 .. n) {
            if (cmb & (1<<i)) {
                d[i] = jisa[i];
            }
            else {
                d[i] = 24 - jisa[i];
            }
        }

        int mindf = jisa[0];

        foreach (i ; 0 .. n) {
            foreach (j ; i + 1 .. n) {
                int df = abs(d[i] - d[j]);
                mindf = min(mindf, min(df, 24 - df));
            }
        }

        ans = max(ans, mindf);
    }

    writeln(ans);
}



struct UnionFind {
    private {
        int N;
        int[] p;
        int[] rank;
    }

    this (int n) {
        N = n;
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x) {
        if (p[x] != x) {
            p[x] = find_root(p[x]);
        }

        return p[x];
    }

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

    void unite(int x, int y) {
        int u = find_root(x), v = find_root(y);

        if (u == v) return;

        if (rank[u] < rank[v]) {
            p[u] = v;
        }
        else {
            p[v] = u;

            if (rank[u] == rank[v]) {
                rank[u]++;
            }
        }
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



struct Queue(T) {
    private {
        int N, head, tail;
        T[] data;
    }

    this(int n) {
        N = n + 1;
        data = new T[](N);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return (tail + 1) % N == head;
    }

    T front() {
        return data[head];
    }

    void push(T x) {
        assert(!full);
        data[tail++] = x;
        tail %= N;
    }

    void pop() {
        assert(!empty);
        head = (head + 1) % N;
    }

    void clear() {
        head = tail = 0;
    }
}

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


using namespace std;
 
int main(){
int h,w;
cin >> h >> w;
vector<string> s(h);

for(int i = 0; i < h; i++) cin >> s[i];

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

for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
        if(s[i][j] == '#') continue;

        int num = 0;
        for(int d = 0; d < 8; ++d){
            const int ni = i + dy[d];
            const int nj = j + dx[d];

            if(ni < 0 || h <= ni) continue;
            if(nj < 0 || w <= nj) continue;
            if(s[ni][nj] == '#') num++;

        }

        s[i][j] = char(num + '0');
    }
}

for(int i = 0; i < h; ++i) cout << s[i] << endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	while(cin>>a>>b>>c)
	{
		if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
		cout<<"Yes"<<endl;
		else 
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
/*
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
█████████───███─────────███───███─────────████████████───███████████████───████████████───████████████───█████████───────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
███─────────███─────────███───███─────────███──────███───███───███───███───███──────███───███──────███───███─────────────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
█████████──────███───███──────███─────────████████████───███───███───███───████████████───███──────███───█████████───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
███────────────███───███──────███─────────███──────███───███───███───███───███────────────███──────███─────────███───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
█████████─────────███─────────█████████───███──────███───███───███───███───███────────────████████████───█████████───────
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fori(n) for ( int i = 0; i < (n);i++)
#define forj(n) for ( int j = 0; j < (n);j++)
#define fork(n) for ( int k = 0; k < (n);k++)
#define forghj(n) for ( int ghj = 0; ghj < (n);ghj++)
#define fori1(n) for ( int i = (n)-1; i >= 0;i--)
#define all(vector) (vector).begin(),(vector).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1e9+7
#define EPS 1e-6
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"

int main() {
    srand(time(NULL));
    int n;
    cin >> n;
    vector < int > a;
    a.resize(n);
    fori(n) cin >> a[i];
    int kol = 0;
    fori(n) if (a[i] - 1 != i) kol++;
    if (kol <= 2) {
        cout << "YES";
        return 0;
    }
    cout << "NO";
}






Measured memory_bytes: 256
import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input=sys.stdin.readline
from random import randint
##import numpy as np
#sys.setrecursionlimit(10**7)
mo=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())

for _ in range(1):
    s=sin().strip()
    t=sin().strip()
    ls,lt=len(s),len(t)
    ans=ls
    for i in range(0,ls-lt+1):
        c=0
        for j in range(i,i+lt):
            if(s[j]!=t[j-i]):
                c+=1
        ans=min(ans,c)
    print(ans)
            
    
    
        
    

        
        
        
    
    
    

        
    

        
        
    
        
    
    
            
    
        
    
    
    

                    
                    
                    
                    
                    
        
    
    
    
    
            
        
    

            
            
            
            
        
        
                
                
    

    
    
    
    
    

                    
                
    

    

        


    
        

    
    
    
    
    
    
    
    
        
    
    
    
    
    
    
        
        
    
    
    
    


    




##def msb(n):n|=n>>1;n|=n>>2;n|=n>>4;n|=n>>8;n|=n>>16;n|=n>>32;n|=n>>64;return n-(n>>1) #2 ki power
##def pref(a,n,f):             
##    pre=[0]*n
##    if(f==0):         ##from beginning
##        pre[0]=a[0]
##        for i in range(1,n):
##            pre[i]=a[i]+pre[i-1]
##    else:              ##from end
##        pre[-1]=a[-1]
##        for i in range(n-2,-1,-1):
##            pre[i]=pre[i+1]+a[i]
##    return pre
##maxint=10**24 
##def kadane(a,size): 
##    max_so_far = -maxint - 1
##    max_ending_here = 0
##       
##    for i in range(0, size): 
##        max_ending_here = max_ending_here + a[i] 
##        if (max_so_far < max_ending_here): 
##            max_so_far = max_ending_here 
##  
##        if max_ending_here < 0: 
##            max_ending_here = 0   
##    return max_so_far
##def power(x, y):
##    if(y == 0):return 1
##    temp = power(x, int(y / 2))%mo
##    if (y % 2 == 0):return (temp * temp)%mo 
##    else:
##        if(y > 0):return (x * temp * temp)%mo 
##        else:return ((temp * temp)//x )%mo


Measured memory_bytes: 77524
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int K;
    cin >> K;
    string S;
    cin >> S;

    int length = S.size();
    if (length <= K)
    {
        cout << S << endl;
        return (0);
    }
    else
    {
        for (int i = 0; i < K; i++)
        {
            cout << S[i];
        }
        cout << "..." << endl;
    }
    return (0);
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <list>
#include <cstring>
using namespace std;

int main(){
	int n,sw;
	bool f[30];
	string str;
	list<char> li;
	cin >> n;
	for(int i = 0;i < n;++i){
		sw = 0;
		memset(f,0,sizeof(f));
		li.clear();
		cin >> str;
		for(int j = 0;j < str.size();++j){
			if(str[j] == '<') sw = 0;
			else if(str[j] == '>') sw = 1;
			else if(str[j] != '-'){
				if(!f[(int)(str[j] - 'a')]){
					if(sw) li.push_back(str[j]);
					else li.push_front(str[j]);
				}
				f[(int)(str[j] - 'a')] = true;
			}
		}
		list<char>::iterator it = li.begin();
		while(it != li.end()){
			cout << *it;
			++it;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int w, h;
char field[21][21];
bool used[21][21];

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

void solve(int y,int x){

	REP(i, 4){
		int ny = y + dy[i], nx = x + dx[i];
		if (ny < h&&ny >= 0 && nx < w&&nx >= 0){
			if (field[ny][nx] == '.'&&used[ny][nx] == 0){
				used[ny][nx] = 1;
				solve(ny, nx);
			}
		}
	}

	return;
}

int main(){
	while (cin >> w >> h&&w + h){
		REP(i, 21)REP(j, 21)used[i][j] = 0;
		REP(i, h){
			REP(j, w){
				cin >> field[i][j];
				if (field[i][j] == '@'){
					sy = i, sx = j;
				}
			}
		}

		solve(sy, sx);
		used[sy][sx] = 1;

		int ans = 0;
		REP(i, h){
			REP(j, w){
				if (used[i][j])ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
int dfs(int no,int d,int k);
vector<int> ed[100001];
int visit[100001];
int ans=0;
int main(){
int i,j;
int n,k;
cin>>n>>k;
int a[n+1];
for(i=1;i<=n;i++)
{cin>>a[i];
if(i==1){
    if(a[1]!=1)
        {a[1]=1;
        ans++;
        }

continue;
}
else
ed[a[i]].pb(i);
}

if(k<=1e5){
dfs(1,0,k);
}
cout<<ans<<endl;




return 0;
}
int dfs(int no,int p,int k){
int i=0;
int res=0;
for(i=0;i<ed[no].size();i++){

    res=max(res,dfs(ed[no][i],no,k)+1);

}
if(p!=1&&p!=0&&res==(k-1))
{

    ans++;
    res=-1;

}

return res;

}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

char tolower(char c)
{
    return (c + 0x20);
}

int main()
{
    int N, K; cin >> N >> K;
    string S; cin >> S;
    S[K-1] = tolower(S[K-1]);
    cout << S << endl;
}

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

const int MAX = 100000;
int main() {
	int N, a[MAX], L;
	cin >> N >> L;
	for (int i = 0;i < N;i ++) cin >> a[i];
	
	for (int i = 0;i < N - 1;i ++) {
		if (a[i] + a[i + 1] >= L) { // この区間を基準にできる
			cout << "Possible" << endl;
			for (int j = 1;j <= i;j ++) cout << j << endl;
			for (int j = N - 1;j > i + 1;j --) cout << j << endl;
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

ある区間[a_i, a_i+1]の長さがL以上であるとする
この時、その区間を常に含むように区間を取り端から結び目をほどけば、答えが導出できる
逆に、そのような区間が存在しない時は最後の2区間になった時に結び目がほどけない
*/

Measured memory_bytes: 1152
//In the name of 'ALLAH'
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a , b , c ;
    cin >> a >> b >> c ;
    ll ans = ( b/c  - a/c);

    if( a%c ==0)
    {
        ans ++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

void init(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
}

int main() 
{
    init();
    int N, L;
    cin >> N >> L;

    int natural_sum = (1 + N) * N / 2;
    int buff = N * (L - 1);
    int consumed = INT_MAX;
    REP(i, N) {
        if(abs(i + L) < abs(consumed)) {
            consumed = i + L;
        }
    }

    int result = natural_sum + buff - consumed;
    cout << result << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int k =0, n = s.size(),m = t.size();
	vector<int> v;
	for(int i = 0; i<n; i++)
	{
		if(s[i]==t[k] || s[i]=='?')
			k++;
		else
		{
			if(k)
				i-=1;
			k = 0;
		}
		if(k==m)
		{
			v.push_back(i-m+1);
			k = 0;
			i -= m;
			i++;
		}
	}
	if(v.size()==0)
		cout<<"UNRESTORABLE"<<endl;
	else
	{
		set<string> st;
		for(auto l: v)
		{
			string t2="";
			for(int i = 0; i<n; i++)
			{
				if(i==l)
				{
					i += m-1;
					t2 +=t;
				}
				else if(s[i]=='?')
					t2.push_back('a');
				else
					t2.push_back(s[i]);
			}
			st.insert(t2);
		}
		cout<<*st.begin()<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val m = scn.nextInt()
	val ps = Array(n){ mutableListOf<Int>()}
	repeat(m) {
		val a = scn.nextInt()-1
		val b = scn.nextInt()-1
		ps[a].add(b)
		ps[b].add(a)
	}
	val d = IntArray(n){Integer.MAX_VALUE}
	d[0] = 0
	val arr = IntArray(n)
	val q = mutableListOf(0)
	while(q.size>0){
		val i = q.removeAt(0)
		ps[i].forEach{
			if (d[i]+1<d[it]){
				d[it] = d[i]+1
				arr[it] = i
				q.add(it)
			}
		}
	}
	if (d.any{it==Integer.MAX_VALUE}){
		println("No")
	}else {
		println("Yes")
		for (i in 1 until n) println(arr[i]+1)
	}
}

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

using ll = long long;

const ll MOD = 998244353;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());
    if (a[0] == a[N - 1]) {
        if (a[0] == N - 1 || a[0] <= N / 2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (a[0] + 1 < a[N - 1]) {
        cout << "No" << endl;
    } else {
        int i = 0;
        while (a[i] == a[0]) i++;
        if (a[0] >= i && a[0] < i + (N - i) / 2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    l = n + 1

    t = [[0]*n for _ in range(n)]
    w = [0] * l
    for i in range(n):
        w[i+1] = w[i] + a[i]

    for i in range(n-2,-1,-1):
        z = t[i]
        y = t[i+1]
        c = w[i]
        for j in range(i+1,n):
            b = inf
            for k in range(i,j):
                e = z[k] + t[k+1][j]
                if b > e:
                    b = e
            t[i][j] = b + w[j+1] - c

    return t[0][-1]


print(main())


Measured memory_bytes: 9284
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();

            int ans = Math.abs(753 - Integer.parseInt(S.substring(0, 3)));
            for (int i = 1; i < S.length() - 2; i++) {
                int temp = Math.abs(753 - Integer.parseInt(S.substring(i, i + 3)));
                if (temp < ans) {
                    ans = temp;
                }
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include<string>
using namespace std;
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define test unsigned int tet;cin >> tet;while(tet--)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define sf scanf 
#define pf printf 
int max(int a,float b){
    if(a>b)
       return a;
    return b;
}
ll gcd(ll a,ll b){
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a*b/gcd(max(a,b),min(a,b));
}
bool sort_pair(pair<int,int>a,pair<int,int> b){
   return a.first>b.first;
}
bool sort_pair_(pair<int,int>a,pair<int,int>b){
    return a.second>b.second;
}
bool isprime(int x){
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0)
        return 0;
    }
    return 1;
}
bool prime[100002];
int main() {
    int t;
    cin>>t;
    string s1="AC",s2="WA",s3="TLE",s4="RE",s;
    int c1=0,c2=0,c3=0,c4=0;
    for(int i=0;i<t;i++){
        cin>>s;
        if(s==s1)c1++;
        else if(s==s2)c2++;
        else if(s==s3)c3++;
        else if(s==s4)c4++;
    }
    cout<<s1<<" x "<<c1<<"\n";
    cout<<s2<<" x "<<c2<<"\n";
    cout<<s3<<" x "<<c3<<"\n";
    cout<<s4<<" x "<<c4<<"\n";
    
    
}



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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9)
    {
        cout << a * b << endl;
        return 0;
    }
    cout << -1 << endl;
}


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

using namespace std;

#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define mp make_pair
#define pb push_back
#define eps 1e-9
#define PI acos(-1.0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<int, pii> iii;
typedef vector<pii> vii;
typedef vector<iii> vip;
typedef long double ld;
const int MAX_N = 1e5 + 5;

// const ll INF = 1e18L + 5;
vi edges[MAX_N];
int indeg[MAX_N];
int dist[MAX_N];
int vist[MAX_N];
bool prime(ll x)
{
    if(x == 2)
        return true;
    for(int i = 2 ; i * i <= x ; i++)
        if(x % i == 0)
            return false;
    return true;
}


template <typename T> void self_max(T &a, T b)
{
    a = max(a, b);
}

void dfs(int x)
{
    vist[x] = true;
    for(int y : edges[x])
    {
            self_max(dist[y], dist[x] + 1);
            --indeg[y];
            if(indeg[y] == 0)
                dfs(y);
    }
}

int main()
{
    ios_base::sync_with_stdio (0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    while(m--)
    {
        int x, y;  
        cin >> x >> y;
        edges[x].push_back(y);
        indeg[y]++;
    }
    for (int i = 1; i <= n; ++i)
    {
        if(!vist[i] && indeg[i] == 0)
            dfs(i);
    }
    int ans = 0;
    for (int i = 0; i < n+1; ++i)
    {
        self_max(ans, dist[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  char x;cin>>x;
  
  if(islower(x)){
    cout<<'a'<<endl;
  }
  else{
    cout<<'A'<<endl;
  }
}

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

int main() {
  map<ll,ll> M;
  ll N;
  cin >> N;
  for(ll i=0;i<N;i++){
    ll a;
    cin >> a;
    if(M[a]==0){
      M[a]=1;
    }
    else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 16004
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, m, s; rd(n, m, s);
  alias edge=Edge!(int);
  auto g=new edge[][](n);
  foreach(_; 0..m){
    int a, b, c; rd(a, b, c);
    g[a]~=edge(b, c);
  }

  auto dist=dijkstra!(int)(g, s);
  foreach(d; dist){
    if(d==(int).max) writeln("INF");
    else writeln(d);
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


struct Edge(T){
  int to;
  T cost;
}

T[] dijkstra(T, alias edge=Edge!(T))(edge[][] g, int s){
  import std.algorithm, std.typecons, std.typetuple, std.container;
  const inf=T.max;
  auto dist=new T[](g.length);
  fill(dist, inf);
  dist[s]=T.init;
  alias P=edge;
  auto q=new BinaryHeap!(Array!P, "a.cost>b.cost");
  q.insert(P(s, dist[s]));
  while(q.length>0){
    auto cost=q.front.cost;
    auto u=q.front.to;
    q.removeFront;
    foreach(e; g[u]){
      if(cost+e.cost<dist[e.to]){
        dist[e.to]=cost+e.cost;
        q.insert(P(e.to, dist[e.to]));
      }
    }
  }
  return dist;
}



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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  int ans = 0;
  int c = a/k*k;

  
  while ( c <= b ) {
    if ( c >= a ) {
      ans = 1;
      break;
    }
    else if (c < a)
      c += k;
    
  }
  if ( ans == 1 )
   cout <<  "OK" << endl;
  else 
     cout <<  "NG" << endl;
  
}


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

int main() {
  int N, M, sum_now, sum_max = 0, temp1;
  string temp2;
  cin >> N;
  vector<string> s(N + 1);
  vector<string> t(M + 1);
  for(int i = 1; i <= N; i++){
    cin >> s.at(i);
  }
  cin >> M;
  for(int i = 1; i <= M; i++){
    cin >> t.at(i);
  }
  for(int i = 1; i <= N; i++){
    sum_now = 0;
    temp2 = s.at(i);
    for(int j = i; j <= N; j++){
      if(temp2 == s.at(j)){
        sum_now++;
      }
    }
    for(int i = 1; i <= M; i++){
      if(temp2 == t.at(i)){
        sum_now--;
      }
    }
    if(sum_now > sum_max){
      temp1 = sum_now;
      sum_now = sum_max;
      sum_max = temp1;
    }
  }
  cout << sum_max << endl;

}


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

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

     rep(i,n){
       ans*=i+1;
       ans%=1000000007;
     }
     cout << ans <<endl;
    }

Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main(){
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0;i<len;i++){
        if(i%2==0)printf("%c",s[i]);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 384