akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<LL,int>;
const LL INF=1e14;

struct edge{
	int to;
  	LL cost;
  	edge(int to, LL cost): to(to), cost(cost) {}
};

int main(){
	int N, M, L;
	cin >> N >> M >> L;
	vector<vector<edge>> G(N);
	rep(i,M){
		int A, B;
      	LL C;
		cin >> A >> B >> C;
		A--; B--;
      	G[A].emplace_back(B,C);
      	G[B].emplace_back(A,C);
	}
	int Q;
	cin >> Q;
	vector<int> s(Q), t(Q);
	rep(i,Q) cin >> s[i] >> t[i];
	LL dist[310][310], ans[310][310];
	rep(i,N){
		rep(j,N) dist[i][j]=INF, ans[i][j]=INF;
	}
	rep(i,N) dist[i][i]=0, ans[i][i]=0;
	rep(st,N){
		rep(i,N){
			priority_queue<P,vector<P>,greater<P>> q;
			if(i==0) q.push({0,st});
			else{
				rep(j,N){
					if(ans[st][j]==i-1){
                      	dist[st][j]=0;
						q.push({dist[st][j],j});
					}
				}
			}
			while(!q.empty()){
              	P p=q.top(); q.pop();
				int n=p.second;
              	LL d=p.first;
              	if(dist[st][n]<d) continue;
				rep(j,G[n].size()){
					int next=G[n][j].to;
					if(ans[st][next]<i) continue;
					if(dist[st][next]<=d+G[n][j].cost) continue;
					if(dist[st][n]+G[n][j].cost>L) continue;
                  	dist[st][next]=d+G[n][j].cost;
					q.push({dist[st][next],next});
					ans[st][next]=i;
				}
			}
		}
	}
	rep(i,Q){
		if(ans[s[i]-1][t[i]-1]==INF) cout << -1 << endl;
		else cout << ans[s[i]-1][t[i]-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 5916
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

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

  if(abs(a-b) > 20){
    cout << "-1\n";
    return 0;
  }

  int res = b*10;
  bool flg = false;
  REP(i,10){
    if(floor((res+i)*0.08) == a){
      res += i;
      flg = true;
      break;
    }
  }

  if(flg == false) res = -1;
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;
const LL LINF=1e18;

int main(){
    string s[3];
    for(int i=0;i<3;i++){
        cin >> s[i];
    }
    cout << s[0][0] << s[1][1] << s[2][2] << endl;
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    set<string> st;
    rep(i, n) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 19184
#include <bits/stdc++.h>
using namespace std;
int n,x,y,z,nw;
const int mod=1e9+7;
int S,f[45][1<<17],ans=1;
int main()
{
    cin >> n;
    cin >> x >> y >> z;
    for(int i=1;i<=n;i++) ans=1ll*ans*10%mod;
    nw=(1<<x-1)|(1<<x+y-1)|(1<<x+y+z-1);
    S=(1<<x+y+z)-1;
    f[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=S;j++)
            for(int k=1;k<=10;k++)
            {
                int T=(j<<k)|(1<<k-1);
                T&=S;
                if((T&nw)!=nw) f[i][T]=(f[i][T]+f[i-1][j])%mod;
            }
    for(int i=0;i<=S;i++) ans=(ans-f[n][i]+mod)%mod;
    cout << ans;
}

Measured memory_bytes: 22272
import qualified Data.ByteString.Char8 as B
import Data.List

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

readIntPairs :: B.ByteString -> [(Int, Int)]
readIntPairs = map (pair . map readInt . B.words) . B.lines

pair :: [t] -> (t, t)
pair [x, y] = (x, y)
pair _ = undefined

main = do
  [h,w,_] <- map read . words <$> getLine
  abs <- readIntPairs <$> B.getContents
  mapM_ print (nurie h w abs)

nurie h w abs = zero : apps
  where
    zero = (h - 2) * (w - 2) - sum apps
    apps = map (pred . length) $ group $ sort $ ([1..9] ++) $ map length $ group $ sort $ concatMap (square h w) abs

square h w (a,b) = [(i,j) | i<-[a-2..a], j<-[b-2..b], i>0, i<=h-2, j>0, j<=w-2]

Measured memory_bytes: 159996
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var x = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        if (n == 1) { Console.WriteLine(Math.Abs (x -a[0])); goto end; }
        var b = new List<int>();
        for (int i = 0; i < n -1; i++)
        {
            if (a[i] > x && a[i + 1] > x) b.Add(a[i + 1] - a[i]);
           else   if (a[i] < x && a[i + 1] < x) b.Add(a[i + 1] - a[i]);
            else
            {
                b.Add(a[i + 1] - x);
                b.Add(x - a[i]);
            }
        }
        var b2 = b.Distinct().ToArray();
        if (b2.Length == 1) { Console.WriteLine(b2[0]); goto end; }
        var ans = Gcd(b2[0], b2[1]);
        for (int i = 2; i < b2.Length ; i++)
            ans = Gcd(ans, b2[i]);
        Console.WriteLine(ans);
        end:;
    }
    public static int Gcd(int a, int b)
    {
        if (a < b)
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}


Measured memory_bytes: 19808
N = list(input())

if N[len(N)-1] == '3':
    print('bon')
elif (N[len(N)-1] == '0') or (N[len(N)-1] == '1') or (N[len(N)-1] == '6') or (N[len(N)-1] == '8'):
    print('pon')
else:
    print('hon')

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

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

int main() {
  int K;
  cin >> K;
  ll ans = 0;
  for(int a = 1; a <= K; a++) {
    for(int b = 1; b <= K; b++) {
      for(int c = 1; c <= K; c++) {
        ans += gcd(a, gcd(b, c));
      }
    }
  }

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


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#define all(v) (v).begin(),(v).end()

using namespace std;

int main(){
  	int N, K;
  	cin >> N >> K;
  	vector<int> a(N);
  	for(int i=0;i<N;i++) cin >> a[i];
  	sort(all(a), greater<int>());
  	auto itr = a.begin();
  	itr += K;
  	cout << accumulate(a.begin(), itr, 0) << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

bool check(vector<int> nums, int k){
	vector<int> dp;
	rep(i,8001){
		dp.push_back(0);
	}
	dp[0] = 1;
	rep(i,nums.size()){
		vector<int> dp2;
		rep(i,8001){
			dp2.push_back(dp[i]);
		}
		rep(j,k+1){
			if(j+nums[i] > k) break;
			dp2[j+nums[i]] = max(dp2[j+nums[i]], dp[j]);
		}
		dp = dp2;
	}
	if(dp[k] == 1) return true;
	else return false;
}

int main(void){
	string s; cin>>s;
	s.push_back('T');
	int x,y; cin>>x>>y;
	vector<int> mx,my;
	int sum_x = 0, sum_y = 0;
	int ri = 0;
	int count = 0;
	rep(i,s.size()){
		char t = s[i];
		if(t == 'F'){
			count++;
		}else{
			if(ri == 0){
				ri = 1;
				x -= count;
			}else if(ri == 2){
				ri = 1;
				mx.push_back(count);
				sum_x += count;
			}else{
				ri = 2;
				my.push_back(count);
				sum_y += count;
			}
			count = 0;
		}
	}
	x = abs(x); y = abs(y);
	if(sum_x%2 != x%2 || sum_y%2 != y%2 || sum_x < x || sum_y < y){
		cout<<"No"<<endl;
		return 0;
	}
	if(check(mx, (sum_x - x) / 2 + x) && check(my, (sum_y - y) / 2 + y)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>


typedef struct s_table
{
	int num_0;//0枚の皿
	int num_1;
	int num_2;
	int num_3;
	int times;
} t_table;

typedef struct s_dp
{
	double exp;
	t_table *table;
	int num_t;
} t_dp;

double expect(int num_0, int n)
{
	double r_num = num_0 / 1.0;

	return((n*1.0)/(n-r_num));
}

double f(int c1, int c2, int c3, int N, double ***dp, int ***memo_flag)
{
	double fans;
	if(memo_flag[c1][c2][c3] == 1)
	{
		return (dp[c1][c2][c3]);
	}
	memo_flag[c1][c2][c3] = 1;
	fans = 1/(1-((double)(N-c1-c2-c3)/N));
	//printf("fan:%.4lf, c1:%d, c2:%d, c3:%d, N:%d\n",fans,c1,c2,c3,N);
	if(c1>0)
	{
		fans += f(c1-1,c2,c3,N,dp,memo_flag)*c1/N/(1-(double)(N-c1-c2-c3)/N);
	}
	if(c2>0)
	{
		fans += f(c1+1,c2-1,c3,N,dp,memo_flag)*c2/N/(1-(double)(N-c1-c2-c3)/N);
	}
	if(c3>0)
	{
		fans += f(c1,c2+1,c3-1,N,dp,memo_flag)*c3/N/(1-(double)(N-c1-c2-c3)/N);
	}
	return (dp[c1][c2][c3]=fans);
}
int main(void)
{
	int ***memo_flag;
	double ***dp;
	int n;
	int *a;
	scanf("%d",&n);
	a = (int *)malloc(sizeof(int)*(n+1));
	int i,j,k,l;
	int sum;
	i = 0;
	j = 0;
	k = 0;
	l = 0;
	
	while (i < n)
	{
		scanf("%d",&(a[i]));
		i++;
	}
	i = 0;
	j = 0;
	memo_flag = (int***)malloc(sizeof(int **)*(301));
	dp = (double ***)malloc(sizeof(double **)*(301));
	while (i < 301)
	{
		memo_flag[i] = (int **)malloc(sizeof(int *)*(301));
		dp[i] = (double **)malloc(sizeof(double *)*(301));
		j = 0;
		while (j < 301)
		{
			memo_flag[i][j] = (int*)malloc(sizeof(int)*(301));
			dp[i][j] = (double*)malloc(sizeof(double)*(301));
			k = 0;
			while (k < 301)
			{
				memo_flag[i][j][k] = 0;
				dp[i][j][k] = 0;
				k++;
			}
			j++;
		}
		i++;
	}
	i = 0;
	j = 0;
	k = 0;
	int c[4];
	c[0] = 0;
	c[1] = 0;
	c[2] = 0;
	c[3] = 0;
	while (i<n)
	{
		c[a[i]]++;
		i++;
	}
	memo_flag[0][0][0] = 1;
	double ans = f(c[1],c[2],c[3],n,dp,memo_flag);
	//printf("c1:%d, c2:%d, c3:%d, n;%d\n",c[1],c[2],c[3],n);
	printf("%.14lf\n",ans);
	return (0);
}


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

using namespace std;

vector<int> v[100006];

int dp[100003][2];

int M = 1e9+7;

int fun(int n ,int cr, int pr){
    
    if(dp[n][cr]!=-1)return dp[n][cr];
    
    long long int ans =1;
    
    for(int i=0;i<v[n].size();i++){
        long long val =0;
        if(v[n][i]!=pr){
            val+=fun(v[n][i],1-cr,n);
            val%=M;
            if(cr)val+=fun(v[n][i],cr,n);
            ans*=val;
            ans%=M;
        }
       
    }
    return dp[n][cr]=ans;
}

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;n--;
    while(n--){
        int a ,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    cout<<(fun(1,0,-1)+fun(1,1,-1))%M<<endl;
    
    return 0;
}

Measured memory_bytes: 14848
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c,d,cnt;
  cnt=0;
  cin >> n >> m >> c ;
  vector<vector<int>> a(n, vector<int>(m));
  vector <int>b(m);
  for (int i=0;i<m;i++)
    cin >> b[i];
  for (int i=0;i<n;i++){
    for (int j=0;j<m;j++)
      cin >> a.at(i).at(j);
  }
  d=0;
   for (int i=0;i<n;i++){
     d=0;
    for (int j=0;j<m;j++){
      d+=a.at(i).at(j)*b[j];
    }
     if(d+c>0)
       cnt++;

  }
  
  cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
int n, m, k;

int main() {
    scanf("%d %d %d", &n, &m, &k);
    vector<int> a(n + 1, 0), b(m + 1, 0);
    vector<long long> sumA(n + 1, 0), sumB(m + 1, 0);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        sumA[i] = sumA[i - 1] + a[i];
    }
    for (int i = 1; i <= m; ++i) {
        scanf("%d", &b[i]);
        sumB[i] = sumB[i - 1] + b[i];
    }

    int max_ans = 0;
    int j = m;
    for (int i = 0; i <= n; ++i) {
        if (sumA[i] > k) {
            break;
        }
        while (sumB[j] > k - sumA[i]) {
            j--;
        }
        max_ans = max(max_ans, i + j);
    }

    printf("%d\n", max_ans);
    return 0;
}


Measured memory_bytes: 8000
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
void factorization(ll n,map<ll,ll>& mp){
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
     }
     if(!(n == 1)) mp[n]++;
}
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
int main(){
	ll n;cin>>n;
	ll a[n];
	rep(i,n){
		cin>>a[i];
	}
    vector<map<ll,ll>>res(n);
    rep(i,n){
        factorization(a[i],res[i]);
    }
    map<ll,ll>re;
    rep(i,n){
        for(auto  x:res[i]){
            re[x.first]=max(x.second,re[x.first]);
        }
    }
    mint lcm =1;
    for(auto x:re){
        rep(i,x.second){
        lcm*=x.first;
        //lcm%=mod;
        }
    }
    mint ans =0;
    rep(i,n){
        mint temp =lcm/a[i];
        ans+=temp;
    }
    cout<<ans.x<<endl;
}

Measured memory_bytes: 3968
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int split(ll x, ll y) {
  ll diff = x * y;
  REP(i, 2) {
    ll x1 = x / 3 + i;
    // 縦
    REP(j, 2) {
      ll x2 = (x - x1) / 2 + j;
      ll x3 = x - x1 - x2;
      if (x1 == 0 || x2 == 0 || x3 == 0) continue;
      ll mina = min(min(x1, x2), x3) * y;
      ll maxa = max(max(x1, x2), x3) * y;
      // cout << x1 << " " << x2 << " " << x3 << endl;
      // cout << mina << " " << maxa << endl;
      // cout << endl;
      diff = min(diff, maxa - mina);
    }
    REP(j, 2) {
      ll x2 = x - x1;
      ll y2 = y / 2 + j;
      ll y3 = y - y2;
      if (x1 == 0 || x2 == 0 || y2 == 0 || y3 == 0) continue;
      ll mina = min(min(x1 * y, x2 * y2), x2 * y3);
      ll maxa = max(max(x1 * y, x2 * y2), x2 * y3);
      // cout << x1 << " " << x2 << " " << y2 << " " << y3 << endl;
      // cout << mina << " " << maxa << endl;
      // cout << endl;
      diff = min(diff, maxa - mina);
    }
  }
  return diff;
}

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

  ll H, W;
  cin >> H >> W;

  cout << min(split(H, W), split(W, H)) << endl;
  return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int dis[MAXN];

set<pii> st;

void solve(){
	int k;
	cin >> k;
	REP(i, 0, k) {
		dis[i] = INF;
	}
	REP(i, 1, 10) {
		dis[i % k] = min(dis[i % k], i);
	}
	REP(i, 0, k) {
		st.insert(mp(dis[i], i));
	}
	while(true) {
		int cur = st.begin()->_2;
		st.erase(st.begin());
		if (cur == 0) {
			printf("%d\n", dis[cur]);
			return;
		}
		REP(i, 0, 10) {
			int nxt = (cur * 10 + i) % k;
			if (dis[nxt] > dis[cur] + i) {
				st.erase(mp(dis[nxt], nxt));
				dis[nxt] = dis[cur] + i;
				st.insert(mp(dis[nxt], nxt));
			}
		}
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

int main()
{
    int k;cin >>k;
    int a,b;cin >>a>>b;
    bool flg=false;
    for(int i=a;i<=b;i++){
        if(i%k==0)flg=true;
    }
    if(flg)puts("OK");
    else puts("NG");
    return 0;
}


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

int main() {
    int n,q;
    string s;
    cin>>n>>q>>s;
    int a[n]{};
    for (int i=1;i<n;i++) {
        a[i]=a[i-1];
        if (s[i-1]=='A'&&s[i]=='C')
            a[i]++;
    }
    for (int i=0;i<q;i++) {
        int l,r;
        cin>>l>>r;
        cout<<a[r-1]-a[l-1]<<endl;
    }
    return 0;
}

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


int main()
{
char a[4],b[4];int cnt=0;
scanf("%s",&a);
scanf("%s",&b);
for(int i=0;i<3;i++){
    if(a[i]==b[i]) {cnt++;
 }

}
printf("%d",cnt);
return 0;



}
 

Measured memory_bytes: 256
n,m = map(int,input().split())
if n == 1 and m == 1:
    print(1)
    exit()
elif n == 1 or m == 1:
    print(n*m-2)
    exit()
elif n == 2 or m == 2:
    print(0)
    exit()
else:
    print(n*m-(2*(m-1)+2*(n-1)))

Measured memory_bytes: 9132
x,y,a,b,c=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort(reverse=True)
A.sort()
B.sort()
A=A[a-x:]
B=B[b-y:]
D=A+B+C
D.sort(reverse=True)
sum=0
for i in range(x+y):
    sum+=D[i]
print(sum)



Measured memory_bytes: 23328
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const long long MOD_NUM = 1000000007LL;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}


static void D_task();

#if 1
int main()
{
	D_task();
	fflush(stdout);
	return 0;
}
#endif

static void D_task()
{
	int A, B, X;
	get3int(A, B, X);

	double box = (double)(A * A * B);
	double pyramid = 0.0, x = 0.0, tanx = 0.0;
	if ((double)X > ((double)box / 2.0)) {
		pyramid = box - X;
		x = pyramid * 2.0 / (double)(A * A);
		tanx = x / (double)A;
	}
	else {
		pyramid = X;
		x = pyramid * 2.0 / (double)(A * B);
		tanx = (double)B / x;
	}

	double deg = (atan(tanx) * (double)(180.0)) / (double)(3.141592653589793);
	printf("%.09lf\n", deg);
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> H;
	int ans = 0;
	int k = 1;
	while (H > 0) {
		H /= 2;
		ans += k;
		k *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    string str;
    string out = "";
    cin >> str;
    for (int i=0; i<str.size(); i++) {
        if (str[i]=='B' && out.size()!=0) {
            out = out.substr(0,out.size()-1);
        } else if (str[i]!='B'){
            out += str[i];
        }
    }
    cout << out << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int maxn=2000+2;
const int mod=1e9+7;
int a,b;
int C[maxn][maxn];
void init(){
	C[0][0]=1;
	for (int i=1;i<maxn;i++){
		C[i][0]=C[i][i]=1;
		for (int j=1;j<i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
}
int main(){
	init();
	scanf("%d%d",&a,&b);
	int ans=a+1;
	for (int i=1;i<b;i++){
		if (b-i>a) continue;
		for (int j=1;j<=b-i;j++){
			if ((b-i)+(b-i-j)>a) continue;
			ans=(ans+1LL*C[b-1][i-1]*C[b-i-1][j-1]%mod*C[a-(b-i-1)-(b-i-j-1)][2]%mod)%mod;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 14976
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int roan[105];

int main()
{
//	cut here before submit 
//	freopen ("testcase.DH", "r", stdin );
	memset (roan, 0, sizeof (roan ) );
	int n;
	scanf ("%d", &n );
	roan[0] = 100000;

	for (int i = 1; i <= 100; i++ ){
		double curr = (double)roan[i-1];
		curr *= 1.05;
		curr /= 1000.;
//		cout << "curr: " << curr << endl;
		curr = ceil (curr );
//		cout << "curr: " << curr << endl;
		curr *= 1000.;
		roan[i] = 	curr;
	} // end for
	cout << roan[n] << endl;
/*
	rep (i, 101 ){
		cout << roan[i] << endl;
	} // end rep
*/
//	printf ("%d\n", res );
		
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a < b) cout << "a < b" << endl;
    if(a > b) cout << "a > b" << endl;
      if(a == b) cout << "a == b" << endl;
  return 0;
}



Measured memory_bytes: 3084
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

d.sort()
t.sort()
j = 0
#print(d)
#print(t)
for i in range(n):
    if d[i] == t[j]:
        if j < m-1:
            j += 1
        else:
            j += 1
            break

if j == m:
    print('YES')
else:
    print('NO')

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

int main() {
	int A;
	cin >> A;
	int B = A % 10;
	int C = (A - B) % 100 / 10;
	int D = (A - B - C*10) / 100;
	int E = B + C + D;
	cout << E << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main(){
    int a,b; cin>>a>>b;
    string ans;
    if(a<b) ans="<";
    if(a==b) ans="==";
    if(a>b) ans=">";
    cout<<"a "<<ans<<" b"<<endl;
    return 0;
}



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

int main() {
	int N, M;
	cin >> N >> M;
	vector<long long> x(N), y(N), z(N), Sans(8);
	for(int i = 0; i < N; i++) {
		cin >> x.at(i) >> y.at(i) >> z.at(i);
	}
	vector<int> xfugo(8), yfugo(8), zfugo(8);
	xfugo.at(0) = 1, yfugo.at(0) = 1, zfugo.at(0) = 1;
	xfugo.at(1) = -1, yfugo.at(1) = 1, zfugo.at(1) = 1;
	xfugo.at(2) = 1, yfugo.at(2) = -1, zfugo.at(2) = 1;
	xfugo.at(3) = 1, yfugo.at(3) = 1, zfugo.at(3) = -1;
	xfugo.at(4) = -1, yfugo.at(4) = -1, zfugo.at(4) = 1;
	xfugo.at(5) = -1, yfugo.at(5) = 1, zfugo.at(5) = -1;
	xfugo.at(6) = 1, yfugo.at(6) = -1, zfugo.at(6) = -1;
	xfugo.at(7) = -1, yfugo.at(7) = -1, zfugo.at(7) = -1;
	for(int i = 0; i < 8; i++) {
		vector<long long> S(N);
		for(int j = 0; j < N; j++) {
			S.at(j) = xfugo.at(i) * x.at(j)  +  yfugo.at(i) * y.at(j)  +  zfugo.at(i) * z.at(j);
		}
		sort(S.begin(), S.end());
		reverse(S.begin(), S.end());
		for(int j = 0; j < M; j++) {
			Sans.at(i) = Sans.at(i) + S.at(j);
		}
	}
	cout << *max_element(Sans.begin(), Sans.end()) << endl;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

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

    s = s + s;

    vector<vector<ll >> point(26);
    rep(i, s.size()) {
        char c = s[i];
        ll j = c - 'a';
        point[j].push_back(i);
    }

    ll position = -1;
    rep(i, t.size()) {
        char c = t[i];
        ll j = c - 'a';
        ll ps = position == -1 ? -1 : position % (s.size() / 2);
        auto it = upper_bound(point[j].begin(), point[j].end(), ps);
        if (it == point[j].end()) {
            cout << -1 << endl;
            ret();
        }
        ll k = *it;
        assert(ps < k);
        ll m = k - ps;
        position += m;
    }
    cout << position + 1 << endl;
}





Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A;
  A=0;
  cin>>N;
  for(int i=0;i<N;i++){
    int r,l;
    cin>>l>>r;
    A=A+r-l+1;
  }
  cout<<A<<endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int64_t current = 2, next = 1, tmp;
  for (int i = 0; i < N; i++) {
    tmp = current;
    current = next;
    next += tmp;
  }
  cout << current << endl;
}


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

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, s;

			string[] word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			//a, b, cの最大値を求める
			int m = a;
			if (b > m) m = b;
			if (c > m) m = c;

			//最大値を除く金額の和
			s = a + b + c - m;



			Console.WriteLine(s);

			Console.ReadLine();
				
				
		}
	}
}

Measured memory_bytes: 27156
M=10**9+7
n,m=map(int,input().split())
F=[1]
for i in range(1,m+1): F+=[i*F[-1]%M]
a=0
for k in range(n+1):
  a+=(-1)**k*F[m-k]*pow(F[k]*F[n-k],-1,M)%M
print(a*F[n]*F[m]*pow(F[m-n]**2,-1,M)%M)

Measured memory_bytes: 28560
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    char a,b; cin >> a >> b ;
    if(a == 'H'){cout << ((b == 'H') ? 'H':'D') << endl; return 0;}
    else if(a == 'D'){cout << ((b =='H') ? 'D':'H') << endl; return 0;}
}


Measured memory_bytes: 256
import math
N,D=map(int,input().split())
X = []
for i in range(N):
    array=list(map(int,input().split()))
    X.append(array)

Y = []
i=0
n=0
for j in X[i:]:
    for k in X[i+1:]:
        m=0
        for l in range(D):
            m=m+(j[l]-k[l])**2
        o=math.sqrt(m)
        if o.is_integer()==True:
            n+=1

    i+=1

print(n)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long int;

ll mpow(ll a, ll n, ll mod)
{
	ll r = 1;
	while (n) {
		if (n&1) r = r*a%mod;
		a = a*a%mod;
		n >>= 1;
	}
	return r;
}

const int N = 1e6+5;
int Div[N];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	const int mod = 998244353;
	int n, k; cin >> n >> k;
	vector<array<int, 2>> intervals(k);
	for (auto &[x, y] : intervals)
		cin >> x >> y;
	vector<ll> dp(n+1), pref(n+1);
	dp[1] = pref[1] = 1;
	for (int i = 2; i <= n; ++i) {
		for (auto [l, r] : intervals) {
			int L = max(1, i-r), R = i-l;
			if (L > R) continue;
			// Add dp[L...R]
			dp[i] += (pref[R] - pref[L-1])%mod;
			dp[i] = (dp[i]%mod + mod)%mod;
		}
		pref[i] = (pref[i-1] + dp[i])%mod;
	}
	cout << dp[n];
}

Measured memory_bytes: 6392
N = int(input())
S = list(input())
if N%2 == 0:
    flg = 1
    for i in range(int(N/2)):
        if not S[i] == S[i+int(N/2)]:
            flg = 0
    if flg == 0:
        print('No')
    else:
        print('Yes')

else:
    print('No')


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;

string s;
int now,n,t;

ll pow(ll x){
  ll res=1;
  while(x--){
    res*=n;
    if(res>(ll)(1e9))return (ll)(1e9+1);
  }
  return res;
}

ll num(){return s[now++]-'0';}
ll mono(){now+=2; return pow(num());}
ll poly(){
  if(s.size()<=now)return 0;
  ll res=mono();
  now++;
  return min(res+poly(),(ll)(1e9+1));
}

int main(void){
  cin >> n >> t >> s;
  ll res=poly();

  if(res*t<=1e9)cout << res*t << endl;
  else cout << "TLE" << endl;
  return 0;
}

Measured memory_bytes: 1196
<?php
list($H, $W, $K) = ints();
for($i = 0; $i < $H; $i++){
  foreach(str_split(trim(fgets(STDIN))) as $v){
    $map[$i][] = boolval($v); 
  }
}
$min = 10**10;
for($i = 0, $I = 2**($H-1); $i < $I; $i++){
  $over = 0;
  $line[0] = 0;
  $ii = $i;
  for($j = 1; $j < $H; $j++){
    $line[$j] = $line[$j-1] + ($ii & 1);
    $ii >>= 1;
  }
  $counts = array_fill(0, $line[$H-1]+1, 0);
  $fromJ = 0;
  for($j = 0; $j < $W; ++$j){
    for($k = 0; $k < $H; ++$k){
      if($map[$k][$j])$counts[$line[$k]]++;
    }
    if(max($counts) > $K){
      $counts = array_fill(0, $line[$H-1]+1, 0);
      if($fromJ == $j)continue 2;
      $fromJ = $j;
      $over++;
      $j--;
    }
  }
  chmin($min, $over + popcount($i));
}
echo $min;
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 4604
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


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


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    X, N = MAP()
    if N == 0:
        print(X)
        exit()

    p = LIST()
    ans = []
    for i in range(200):
        if not X-i in p:
            print(X-i)
            exit()
        if not X+i in p:
            print(X+i)
            exit()
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 10652
#include <bits/stdc++.h>
using namespace std;
char s[110];
int n,pos,maxn;
int main()
{
    cin>>n>>s+1;
    for(int i=1;i<=n;++i)
    {
        if(s[i]=='I') ++pos;
        else --pos;
        maxn=max(maxn,pos);
    }
    cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	string s;
	cin>>s;
	if(s!="AAA"&&s!="BBB") cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::io::*;
use std::str::FromStr;
use std::usize;

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

#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    cost: usize,
    position: usize,
    pre_node: usize,
}

impl Ord for State {
    // Orderingは2つの値の比較結果(<. =, >)で、次の列挙体で定義されている
    /*
    pub enum Ordering {
        Less,
        Equal,
        Greater,
    }
    */
    fn cmp(&self, other: &State) -> Ordering {
        other
            .cost
            .cmp(&self.cost)
            .then_with(|| self.position.cmp(&other.position))
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

#[derive(Clone)]
struct Edge {
    node: usize,
    cost: usize,
}

fn dijkstra(adj_list: &Vec<Vec<Edge>>, start: usize) -> Option<(usize, Vec<usize>)> {
    /*
    最短経路とその経路だけ知りたければmemoをtrueに
    各地点までの最短経路数を知りたければfalseにする
    */
    let mut dist: Vec<_> = vec![usize::MAX; adj_list.len()];
    let mut pre_nodes: Vec<_> = (0..adj_list.len()).map(|i| i).collect();
    let mut heap = BinaryHeap::new();

    dist[start] = 0;
    heap.push(State {
        cost: 0,
        position: start,
        pre_node: 0,
    });

    while let Some(State {
        cost,
        position,
        pre_node,
    }) = heap.pop()
    {
        if cost > dist[position] {
            continue;
        }
        pre_nodes[position] = pre_node;

        for edge in &adj_list[position] {
            let next = State {
                cost: cost + edge.cost,
                position: edge.node,
                pre_node: position,
            };
            if next.cost < dist[next.position] {
                heap.push(next);
                dist[next.position] = next.cost;
            }
        }
    }
    return Some((0, dist));
}

fn main() {
    let v: usize = read();
    let e: usize = read();
    let start: usize = read();
    let mut graph = vec![vec![]; v + 1];
    for _ in 0..e {
        let x: usize = read();
        let y: usize = read();
        let z: usize = read();
        graph[x].push(Edge { node: y, cost: z });
    }
    let result = dijkstra(&graph, start).unwrap();
    for i in 0..v {
        match result.1[i] {
            usize::MAX => println!("INF"),
            d => println!("{}", d),
        }
    }
}



Measured memory_bytes: 25396
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			List<ArrayList<Integer>> cost = new ArrayList<>(), to = new ArrayList<>();
			int N = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < N; i++) {
				to.add(new ArrayList<>());
				cost.add(new ArrayList<>());
			}
			for (int i = 0; i < N - 1; i++) {
				String[] line = sc.nextLine().split(" ");
				int u = Integer.parseInt(line[0]) - 1;
				int v = Integer.parseInt(line[1]) - 1;
				int w = Integer.parseInt(line[2]);
				to.get(u).add(v);
				cost.get(u).add(w);
				to.get(v).add(u);
				cost.get(v).add(w);
			}
			int[] ans = new int[N];
			Arrays.fill(ans, -1);
			ans[0] = 0;
			Deque<Integer> q = new ArrayDeque<>();
			q.add(0);
			while (!q.isEmpty()) {
				int v = q.poll();
				for (int i = 0; i < to.get(v).size(); i++) {
					int u = to.get(v).get(i);
					if (ans[u] > -1) continue;
					int w = cost.get(v).get(i);
					ans[u] = (ans[v] + w) % 2;
					q.push(u);
				}
			}
			Arrays.stream(ans).forEach(r -> System.out.println(r));
		}
	}
}

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

using namespace std;

int main()
{
  string str;
  cin >> str;
  int q;
  cin >> q;
  for(int i = 0;i < q;i++)
  {
    string D;
    cin >> D;
    if(D == "replace")
    {
      int a, b;
      cin >> a >> b;
      string chan;
      cin >> chan;
      int j = 0;
      for(int k = a;k <= b;k++)
      {
        str[k] = chan[j];
        j++;
      }
    }
    if(D == "reverse")
    {
      int a, b;
      cin >> a >> b;
      reverse(str.begin() + a, str.begin() + b + 1);
    }
    if(D == "print")
    {
      int a, b;
      cin >> a >> b;
      for(int k = a;k <= b;k++)
      {
        cout << str[k];
      }
      cout << endl;
    }
  }
}



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

int main() {
  int a, b;
  cin>>a>>b;
  int m=1,sum=0;
  if(a>=b){
    for(int i=0; i<a; i++){
      sum += m;
      m *= 10;
    }
    cout << b*sum << endl;
  }
  else {
    for(int i=0; i<b; i++) {
      sum += m;
      m *= 10;
    }
    cout << a*sum << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        long result = 0;
        for (long i = 1; i < n; i++) {
            result += i;
        }

        // 出力
        System.out.println(result);
    }
}


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

using namespace std;

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

	vector<int> vec_N;

	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;

		vec_N.push_back(n);
	}
	
	//重複チェック前のベクトルサイズ
	int size_before = vec_N.size();

	//cout << "size_before:" <<size_before << endl;

	//並び替え
	sort(vec_N.begin(), vec_N.end());

	//重複要素を消す
	vec_N.erase(unique(vec_N.begin(), vec_N.end()), vec_N.end());

	//重複削除後のベクトルサイズ
	int size_after = vec_N.size();

	//cout << "size_after:" << size_after << endl;

	if (size_before == size_after) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 1400
#include<stdio.h>
#include<queue>
const int N=2e5+3,K=18;
int n,fn[2][N][K],a[N],lg[N];
struct node{
	int l,r,p,f;
	bool operator<(const node&b)const{return a[p]>a[b.p];}
};
std::priority_queue<node> q;
inline int Min(int l,int r,int k){
	int t=lg[r-l];
	if(a[fn[k][l][t]]<a[fn[k][r-(1<<t)][t]])
	  return fn[k][l][t];
	return fn[k][r-(1<<t)][t];
}
int main(){
	node u;int b;
	scanf("%d",&n);
	for(int i=2;i<=n;i++)lg[i]=lg[i>>1]+1;
	a[n]=n+1;
	for(int i=0;i<n;i++){
	  scanf("%d",a+i);
	  fn[i&1][i][0]=i;
	  fn[~i&1][i][0]=n;
	}
	for(int k=0;k<2;k++)
	  for(int j=1;j<K;j++)
		for(int i=0;i+(1<<j)<=n;i++)
		  if(a[fn[k][i][j-1]]<a[fn[k][i+(1<<j-1)][j-1]])
			fn[k][i][j]=fn[k][i][j-1];
		  else fn[k][i][j]=fn[k][i+(1<<j-1)][j-1];
	q.push((node){0,n,Min(0,n,0),0});
	for(;!q.empty();){
	  u=q.top(),q.pop();
	  b=Min(u.p+1,u.r,u.f^1);
	  printf("%d %d ",a[u.p],a[b]);
	  if(u.l<u.p)q.push((node){u.l,u.p,Min(u.l,u.p,u.f),u.f});
	  if(u.p+1<b)q.push((node){u.p+1,b,Min(u.p+1,b,u.f^1),u.f^1});
	  if(b+1<u.r)q.push((node){b+1,u.r,Min(b+1,u.r,u.f),u.f});
	}
	return 0;
}

Measured memory_bytes: 33632
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int a = Input.ScanInt();
          
          Console.WriteLine((a/2)*(a-a/2));
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
    c=a*b;
	if(c%2==0){
		printf("Even\n");
	}
	if(!(c%2==0)){
		printf("Odd\n");
	}
	return 0;
}

Measured memory_bytes: 128