akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int ans;
        if(k <= a)
        	ans = k;
        else if(k <= (a + b))
        	ans = a;
        else {
        	ans = a - (k - (a + b));
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;

ll n, a, b;

int main()
{
    cin >> n >> a >> b;
    if (n == 1)
        if (a == b) printf("1\n");
        else printf("0\n");
    else if (a <= b) cout << ll(n - 2) * (b - a) + 1ll << endl;
         else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
c=0;N,*A=map(int,open(0).read().split()) #open(0).read()でどんな形も読み込み可能。Aの前の*でAが変数であることを示す。
while all(map(lambda i:i&1==0,A)):
    A=list(map(lambda i:i>>1,A));c+=1
print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
long long n,k;
long long a[500000];
long long s[500000];
int dp[500000];
int main() {
    scanf("%lld %lld",&n,&k);
    long long ans=0;
    for(int i=1;i<=n;i++) {
        scanf("%lld",&a[i]);
        s[i]=a[i]+s[i-1];
    }
    m[0]=1;
    int j=0;
    for(int i=1;i<=n;i++) {
        while(i-j>=k) {
            m[s[j]]--;
            j++;
        }
        s[i]=(s[i]-i)%k+k;
        s[i]=(s[i]%k);
        ans+=m[s[i]];
        m[s[i]]++;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 15872
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;

    struct Edge {
        ll to, yen, snuke;
    };
    vector<vector<Edge>> connect(n);
    for (ll i = 0; i < m; i++) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        connect[u].push_back({ v, a, b });
        connect[v].push_back({ u, a, b });
    }

    vector<ll> yen_cost(n, LLONG_MAX / 2), snuke_cost(n, LLONG_MAX / 2);

    {
        //円
        priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
        yen_cost[s] = 0;
        pq.push({ 0, s });
        while (!pq.empty()) {
            auto t = pq.top();
            pq.pop();

            for (auto e : connect[t.second]) {
                ll new_cost = t.first + e.yen;
                if (new_cost < yen_cost[e.to]) {
                    yen_cost[e.to] = new_cost;
                    pq.push({ new_cost, e.to });
                }
            }
        }

    }
    {
        //snuke
        priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
        snuke_cost[t] = 0;
        pq.push({ 0, t });
        while (!pq.empty()) {
            auto t = pq.top();
            pq.pop();

            for (auto e : connect[t.second]) {
                ll new_cost = t.first + e.snuke;
                if (new_cost < snuke_cost[e.to]) {
                    snuke_cost[e.to] = new_cost;
                    pq.push({ new_cost, e.to });
                }
            }
        }
    }

    vector<ll> ans(n);
    ll min_value = LLONG_MAX;
    for (ll i = n - 1; i >= 0; i--) {
        ll tmp = 0;
        tmp = yen_cost[i] + snuke_cost[i];
        min_value = min(min_value, tmp);
        ans[i] = min_value;
    }

    for (ll i = 0; i < n; i++) {
        cout << (ll)1e15 - ans[i] << endl;
    }
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n + 2];
	a[0] = 0;
	a[n + 1] = 0;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += abs(a[i] - a[i - 1]);
	}
	sum += abs(a[n + 1] - a[n]);
	for (int i = 1; i < n + 1; i++) {
		int ans = sum;
		ans -= (abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]));
		ans += abs(a[i + 1] - a[i - 1]);
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 1664
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
typedef    complex<ld>   P;
#define    X   real()
#define    Y   imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf   1000000000000000001
#define    ninf   -1000000000000000001
#define    ima   1000000001
#define    imi   -1000000001
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	
ll n;
cin>>n;
ll ans=0;
for(ll i=1;i<=n;i++)
{
	if(i%3!=0&&i%5!=0)
	ans+=i;
}

cout<<ans;

}return 0;}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll w[205];
ll v[205];
ll x[20000005];
ll a[10005], b[10005];
ll dp[10005][10005];
typedef pair<ll, ll> P;

P f(int x) {
	int a;
	a = x % 10;
	int b = 0;
	while (x) {
		b = x;
		x = x / 10;
	}
	return P(a, b);
}
int main() {
	ll n;
	cin >> n;
	map<P, int>mp;
	for (int i = 1; i <= n; i++) {
		P p = f(i);
		mp[p]++;
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		P p = f(i);
		P q(p.second, p.first);
		ans += mp[q];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n, k = map(int ,input().split())
mn = 0
mx = 0
for i in range(k):
    mn += i
    mx += (n-i)
ans = 0
for i in range(k,n+2):
    ans += mx - mn + 1
    ans %= MOD
    mn += i
    mx += (n-i)
print(ans)


Measured memory_bytes: 9156
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
using namespace std;
const int INF = 1 << 30;
const int NIL = -1;
const int MAXN = 10005;
int vis[MAXN];
int d[MAXN];
int head[500005];
int n;
int cnt;
struct Edge {
	int to, next, w;
	Edge() {}
} edge[500005];

void add(int u, int v, int w)
{
	edge[cnt].to = v;
	edge[cnt].w = w;
	edge[cnt].next = head[u];
	head[u] = cnt++;
}

struct Node {
	int u, w;
	Node (int _u, int _w) :u(_u), w(_w) {}
	friend bool operator<(const Node& a, const Node& b)
	{
		return a.w > b.w;
	}
};

void dijkstra(int s)
{
	priority_queue<Node> q;
	for (int i = 0; i < n; ++i)
		d[i] = INF, vis[i] = false;
	d[s] = 0;
	
	Node t(s, 0);
	q.push(t);
	int u, v, w;
	int count = 0;
	while (!q.empty() && count < n - 1)
	{
		t = q.top();
		q.pop();
		u = t.u;
		if (d[u] < t.w)
			continue;
		vis[u] = true;
		++count;
		for (int i = head[u]; i != NIL; i = edge[i].next)
		{
			v = edge[i].to;
			w = edge[i].w;
			if (!vis[v] && d[v] > d[u] + w)
			{
				d[v] = d[u] + w;
				q.push(Node(v, d[v]));
			}
		}
	}
	if (count == n - 1)
		for (int i = 0; i < n; ++i)
			printf("%d %d\n", i, d[i]);

}

int main(void)
{
	int k, s, e, w;
	scanf("%d", &n);
	memset(head, NIL, sizeof(-1));
	cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d%d", &s, &k);
		while (k--)
		{
			scanf("%d %d", &e, &w);
			add(s, e, w);
		}
	}
	dijkstra(0);

	return 0;
}

Measured memory_bytes: 9140
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;

  while(left < right) {
    mid = (left + right) / 2;
    if (key == A[mid]) return 1;
    if (key > A[mid]) left = mid+1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}

int main()
{
  int i, q, k, sum = 0;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++) {
    scanf("%d", &k);
    if(binarySearch(k)) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 3012
#include <stdio.h>

int main(int argc, char const *argv[])
{

	int m, f, r;

	while(1) {
		scanf("%d %d %d", &m, &f, &r);
		if (m==-1 && f==-1 && r==-1) break;

		if (m==-1 || f==-1)
			printf("F\n");
		else if (m+f >= 80)
			printf("A\n");
		else if (m+f >= 65)
			printf("B\n");
		else if (m+f >= 50)
			printf("C\n");
		else if (m+f >= 30 && r >= 50)
			printf("C\n");
		else if (m+f >= 30)
			printf("D\n");
		else
			printf("F\n");	
	
	} 


	return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
#include<stdlib.h>
int main(void){
	char n[200000];
	int i,sum=0;
	scanf("%s",n);
	for(i=0;n[i]!='\0';i++){
		sum+=n[i]-'1'+1;
	}
	printf(sum%9==0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1848
def combinations(n,k,mod):
    x,y = 1,1
    for i in range(k):
        x = (x*(n-i))%mod
        y = (y*(i+1))%mod
    return (x*pow(y,mod-2,mod))%mod
    

mod = 10**9+7
n,k = map(int,input().split())

def cmap(n,k):
    x = [1]
    y = [1]
    c = [1]
    for i in range(k+1):
        x.append((x[i]*(n-i))%mod)
        y.append((y[i]*(i+1))%mod)
        c.append((x[i+1]*pow(y[i+1],mod-2,mod))%mod)
    return c
    
#print(cmap(n,n))
nc=cmap(n,n-1)
n1c=cmap(n-1,n-2)

ans = 0
for i in range(min(n-1,k)+1):
    ans = (ans+(nc[i]*n1c[i]))%mod

print(ans)

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

bitset<MAX> found;

ll solve(ll, ll K, const vector<int>& xs)
{
    int i = 1;
    found[1] = true;

    while (not found[xs[i]])
    {
        i = xs[i];
        found[i] = true;
        --K;

        if (K == 0)
            return i;
    }

    int s = 0, x0 = i;

    do {
        i = xs[i];
        --K;
        ++s;

        if (K == 0)
            return i;
    } while (i != x0);

    K %= s;

    while (K--)
        i = xs[i];

    return i;
}

int main()
{
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    vector<int> xs(N + 1);

    for (int i = 1; i <= N; ++i)
        cin >> xs[i];

    auto ans = solve(N, K, xs);

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

int main() {
    int n, x, t, ans=0;
    cin >> n >> x >> t;
    for(int i=0; i<1000000; i++) {
        if(n>0) {
            n-=x;
            ans+=t;
        }
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=2000;
const int MAXW=2000;

int h,w;
char g[MAXH][MAXW+1];


int lim[MAXH][MAXW-1];

pair<int,int> stck[MAXW]; int nstck;

void run() {
	scanf("%d%d",&h,&w);
	REP(x,h) scanf("%s",g[x]);

	REP(y,w-1) lim[h-1][y]=h;
	for(int x=h-2;x>=0;--x) REP(y,w-1) lim[x][y]=((g[x][y]=='#'?1:0)+(g[x][y+1]=='#'?1:0)+(g[x+1][y]=='#'?1:0)+(g[x+1][y+1]=='#'?1:0))%2==1?x+1:lim[x+1][y];
	//REP(x,h) { REP(y,w-1) printf("%2d ",lim[x][y]); puts(""); }

	int ret=0;
	REP(x,h) {
		nstck=0; stck[nstck++]=MP(0,h);
		REP(y,w-1) {
			int from=y;
			while(nstck>0&&lim[x][y]<stck[nstck-1].second) {
				pair<int,int> prv=stck[--nstck];
				int cur=(prv.second-x)*(y+1-prv.first); if(cur>ret) ret=cur; from=prv.first;
				//printf("x:%d..%d y:%d..%d -> %d\n",x,prv.second,prv.first,y+1,cur);
			}
			if(nstck==0||lim[x][y]>stck[nstck-1].second) stck[nstck++]=MP(from,lim[x][y]);
			//if(x==0) { printf("stck:"); REP(i,nstck) printf(" (%d,%d)",stck[i].first,stck[i].second); puts(""); }
		}
		while(nstck>0) {
			pair<int,int> prv=stck[--nstck];
			int cur=(prv.second-x)*(w-prv.first); if(cur>ret) ret=cur;
			//printf("x:%d..%d y:%d..%d -> %d\n",x,prv.second,prv.first,w,cur);
		}
	}
	printf("%d\n",ret);
}

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


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

int main(){
    int x; cin>>x;
    if(x>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3612
import Control.Monad
import Data.List as L
import Data.IntMap as M

primes :: [Integer]
primes = takeWhile (<31623) $ 2:3:p
    where 
        p = 5:q 1 7 p
        q m s (p:ps) = [n|n<-[x+y|x<-[s,s+6..p*p-2],y<-[0,4]],gcd m n<2]++q (m*p) (p*p) ps

fac :: [Integer]->M.IntMap Integer->Integer->M.IntMap Integer
fac _ m 1 = m
fac [] m n = M.insert (fromIntegral n) 1 m
fac pa@(p:pr) m n
    |mod n (fromIntegral p)==0=fac pa (M.insertWith(+) (fromIntegral p) 1 m) (div n (fromIntegral p))
    |otherwise =fac pr m n

invmod a p = invmod' a p p 0 1
    where invmod' a p q x y
            | amq==0 = mod (x+p) p
            | True   = invmod' q p amq (y-(div a q)*x) x
            where amq = mod a q

divmod a b p = mod (a * invmod b p) p

cmbmod n k p = L.foldl' (\a i->divmod (mod (a*(n-i+1)) p) i p) 1 [1..k]

main=do
    (n:m:_)<-L.map read.words<$>getLine::IO[Integer]
    print $ sol n m
--
sol 1 _ = 1
sol _ 1 = 1
sol n m = L.foldl' (\a b -> (a * cmbmod (b+n-1) b 1000000007) `mod` 1000000007) 1 fm
    where fm = elems $ fac primes M.empty m

Measured memory_bytes: 1148
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t;
	cin>>n;
ll s=100;
	k=0;
	while(1)
	{
		if(s>=n)break;
		s=s+s/100;
		k++;
	}
	cout<<k<<endl;

}

Measured memory_bytes: 3632
#include <stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n],fil[500001]={0};
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    fil[a[i]]++;
    if(fil[a[i]]>2){
        printf("0");
        return 0;
    }
  }
  if(n%2==1&&fil[0]>1){
      printf("0");
      return 0;
  }
  long long ans=1;
  for(int i=0;i<n/2;i++){
      ans*=2;
      ans%=1000000007;
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n;
  k=n%10;
  if(k==2 || k==4 || k==5 || k==7 || k==9) cout<<"hon";
  else if(k==0 || k==1 || k==6 || k==8) cout<<"pon";
  else cout<<"bon";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
ll a[100];
int n;
int ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    rep1(i,0,n) cin >> a[i];
    sort(a, a + n);
    for(int i = 0; i + 2 < n; i++)
        for(int j = i + 1; j + 1 < n; j++)
            for(int k = j + 1; k < n; k++){
                if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
                    if(a[i] + a[j] > a[k]) ans++;
                }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3644
import sys
import math
sys.setrecursionlimit(1000000)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
LI = LI()
A = LI[0]
B = LI[1]
H = LI[2]
M = LI[3]
a = (60 * H + M) / 720 * 2 * math.pi
b = M / 60 * 2 * math.pi

theta = a - b
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
print(ans)

Measured memory_bytes: 62660
from collections import deque
S = input()
N = len(S) 
s1 = deque(S[0:int((N-1)/2)])
s2 = deque(S[int((N+3)/2)-1:N])
t1 = deque(S[0:int((N-1)/2)])
t2 = deque(S[int((N+3)/2)-1:N])
ans = "None"
if len(S) == 3 and S[0] == S[2]:
    ans = "Yes"
while len(s1) >= 2:
    if s1.popleft() != s2.pop():
        ans = "No"
        break
    if len(s1) == 1 or len(s1) == 0:
        ans = "preYes"
        break

if ans == "preYes":
    while len(t1) >= 2:
        if t1.pop() != t1.popleft():
            ans = "No"
            break
        if len(t1) == 1 or len(t1) == 0:
            ans = "Yes"
            break
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
    int ans=0;
    int n,k;
    cin >> n>>k;
    if(n==k){
        cout<<1<<endl;
        return 0;
    }
    ans = (n+k-3)/(k-1);
    
    cout << ans <<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    s = input().split()
    a = int(s[0])
    b = int(s[1].replace('.', ''))
    print(a*b//100)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
def servey(a):
  for i in range(len(a)):
    global ans
    tmp=a[i]%ans
    if tmp!=0 and tmp<ans:
      ans=tmp
      return False
  return True

n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=min(a)
while True:
  if servey(a):
    break
print(ans)



Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#define ini ll_MAX
#define inl LLONG_MAX
#define MOD 1000000007
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define pbds tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
 
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
 
ll mod(ll a,ll b)
{
    return (b+a%b)%b;
}
 
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}
 
ll sqdist(ll a,ll b,ll c,ll d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}
ll fact(ll n)
{
    if(n==0)return 1;
    ll ans = 1;
    FOR(i,1,n+1)ans*=i;
    return ans;
}

ll arr[15][15];

void ch(ll n)
{
    ll p;
    ll q=n%10;
    while(n)
    {
        p=n%10;
        n/=10;
    }
    //cout<<p<<' '<<q<<endl;
    arr[p][q]++;
}


void solve()
{
    ll n;
    cin>>n;
    FOR(i,1,n+1)
    {
        ch(i);
        //FOR(j,0,10)cout<<arr[j]<<' ';cout<<endl;
    }
    ll ans = 0;
    FOR(i,1,n+1)
    {
        ll p,q=i%10;
        ll n = i;
        while(n)
        {
            p=n%10;
            n/=10;
        }
        ans+=arr[q][p];

    }
    cout<<ans<<endl;
}
 
 
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    // ll t;
    //cout<<"Y"<<endl;
    //cin>>t;
    //while(t--)
        solve();
}

Measured memory_bytes: 256
R,G,B,N=map(int,input().split())
ans=0
for r in range(N//R+1):
    for g in range((N-R*r)//G+1):
        if (N-R*r-G*g)%B==0:
            # print((r,g,(N-R*r-G*g)//B)) #DB
            ans+=1

print(ans)

Measured memory_bytes: 40432
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		TreeMap<Integer,Integer>map=new TreeMap();
		int []a=new int [n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			map.put(a[i],map.getOrDefault(a[i], 0)+1);
			
		}
		for(int x:a) {
			int c=map.get(x);
			map.put(x,c-1);
			if(c==1)
				map.remove(x);
			out.println(map.lastKey());
			map.put(x,map.getOrDefault(x, 0)+1);

		}
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 61188
#include<stdio.h>
int main(void){
	int x,d,area;
	
	while(scanf("%d",&d)!=EOF){
		area=0;
		x=d;
		while(x<600){
			area +=d*x*x;
			x +=d;
		}
		printf("%d\n",area);
		
	}
	
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n, m, a, b, c;
    string s, t;
    cin >> n;
    if(n<1000) s = "ABC";
    else s = "ABD";
    cout << s << endl;
}


Measured memory_bytes: 256
// atcoder/agc024/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

const int N = 2 * 1e5 + 5;
vec<int> g[N];

int memo[N];
int rec(int curr)
{
  int& ret = memo[curr];
  if (ret != -1) return ret;
  if (g[curr].empty()) return 1;
  each (next, g[curr]) {
    ret = rec(next) + 1;
  }
  return ret;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<lli> a(n);
    cin >> a;
    each (i, a) --i;

    fill(g, g + N, vec<int>());
    map<int, int> idx;
    for (int i = 0; i < a.size(); ++i) {
      idx[a[i]] = i;
    }

    for (int i = 0; i + 1 < a.size(); ++i) {
      if (idx[i] < idx[i + 1]) {
        g[i].push_back(i + 1);
      }
    }

    fill(memo, memo + N, -1);
    int mx = 0;
    for (int i = 0; i < a.size(); ++i) {
      setmax(mx, rec(i));
    }
    cout << n - mx << endl;
  }

  return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = -1;
  rep(i, 1001){
    if((floor(i * 0.08) == a) && (floor(i * 0.1) == b)) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
let () =
  let rotate n str =
    String.sub str n (String.length str - n) ^ String.sub str 0 n
  in
  let rec shuffle card = function
      0 -> card
    | i ->
      let h = read_int () in
      shuffle (rotate h card) (i-1)
  in
  let rec loop () =
    match read_line () with
      "-"  -> ()
    | card ->
      let times = read_int () in
      print_endline (shuffle card times);
      loop ()
  in loop ()


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

int main() {
  int a, b, c, x;
  cin>>a>>b>>c>>x;
  int cnt = 0;
  for (int i=0; i<=a; i++) {
    for (int j=0; j<=b; j++) {
      if (x - 500 * i - 100 * j < 0) {
        break;
      }
      if ((x - 500 * i - 100 * j) / 50 <= c) {
        ++cnt;
      }
    }
  }
  cout<<cnt<<endl;
}

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

int main()
{
    int q;
    while(cin >> q, q != -1){
        double x = q / 2.0;
        while(1){
            if(abs(x * x * x - q) < 0.00001 * q){
                cout << fixed << x << endl;
                break;
            } else {
                x = x - (x * x * x - q)/(3 * x * x);
            }
        }
        //cout << fixed << cbrt((long double)q) << endl;
    }
}

Measured memory_bytes: 1236
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

void dijkstra(int n, vector< vector<edge> >& G, int s, vector<ll>& d) {
	fill(d.begin(), d.end(), LLONG_MAX); d[s] = 0;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > q;
	q.push(ll_i(0, s));
	while (!q.empty()) {
		ll_i p = q.top(); q.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				q.push(ll_i(d[e.v], e.v));
			}
		}
	}
}

int main() {
	for (;;) {
		int N, M, L; cin >> N >> M >> L;
		if (N == 0) break;
		int n = N * (L + 1);
		vector< vector<edge> > G(n);
		while (M--) {
			int A, B, D, E;
			cin >> A >> B >> D >> E;
			A--; B--;
			for (int l = 0; l <= L; l++) {
				int u = A * (L + 1) + l, v = B * (L + 1) + l;
				edge e = {u, v, E};
				G[u].push_back(e);
			}
			for (int l = 0; l <= L; l++) {
				int u = B * (L + 1) + l, v = A * (L + 1) + l;
				edge e = {u, v, E};
				G[u].push_back(e);
			}
			for (int l = 0; l + D <= L; l++) {
				int u = A * (L + 1) + (l + D), v = B * (L + 1) + l;
				edge e = {u, v, 0};
				G[u].push_back(e);
			}
			for (int l = 0; l + D <= L; l++) {
				int u = B * (L + 1) + (l + D), v = A * (L + 1) + l;
				edge e = {u, v, 0};
				G[u].push_back(e);
			}
		}
		vector<ll> d(n);
		dijkstra(n, G, L, d);
		ll mini = LLONG_MAX;
		for (int l = 0; l <= L; l++)
			mini = min(mini, d[(N - 1) * (L + 1) + l]);
		cout << mini << endl;
	}
}

Measured memory_bytes: 12512
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		HashMap<String,Integer> hm = new HashMap<>();
		for(int i = 0; i < n; i++){
		String s = sc.nextLine();
		char[] chr = s.toCharArray();
		Arrays.sort(chr);
		String str = String.valueOf(chr);
		hm.put(str, 1 + hm.getOrDefault(str,0));
		}
		long count = 0;
		for(long cur : hm.values()){
			count += (cur * (cur - 1)/2);
		}
		System.out.println(count);
	}
		
		
	}

Measured memory_bytes: 106844
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int main(){
	int a,b,q;
	cin>>a>>b>>q;
	vector<long long> s,t;
	for(int i=0;i<a;i++){
		long long hoge;
		cin>>hoge;
		s.push_back(hoge);
	}
	for(int i=0;i<b;i++){
		long long hoge;
		cin>>hoge;
		t.push_back(hoge);
	}
	long long nt[100000];
	long long ns[100000];
	for(int i=0;i<a;i++){
		int hoge=lower_bound(t.begin(),t.end(),s[i])-t.begin();
		if(hoge==a){
			nt[i]=abs(s[i]-t[a-1]);
		}else if(hoge==0){
			nt[i]=abs(s[i]-t[hoge]);
		}else{
			nt[i]=min(abs(s[i]-t[hoge]),abs(s[i]-t[hoge-1]));
		}
	}
	for(int i=0;i<b;i++){
		int hoge=lower_bound(s.begin(),s.end(),t[i])-s.begin();
		if(hoge==b){
			ns[i]=abs(t[i]-s[b-1]);
		}else if(hoge==0){
			ns[i]=abs(t[i]-s[hoge]);
		}else{
			ns[i]=min(abs(t[i]-s[hoge]),abs(t[i]-s[hoge-1]));
		}
	}
	for(int i=0;i<q;i++){
		long long ans=1e18;
		long long x;
		cin>>x;
		int hoge=lower_bound(s.begin(),s.end(),x)-s.begin();
		if(hoge==a){
			ans=min(ans,abs(s[hoge-1]-x)+nt[hoge-1]);
		}else if(hoge==0){
			ans=min(ans,abs(s[hoge]-x)+nt[hoge]);
		}else{
			ans=min(ans,abs(s[hoge]-x)+nt[hoge]);
			ans=min(ans,abs(s[hoge-1]-x)+nt[hoge-1]);
		}
		hoge=lower_bound(t.begin(),t.end(),x)-t.begin();
		if(hoge==b){
			ans=min(ans,abs(t[hoge-1]-x)+ns[hoge-1]);
		}else if(hoge==0){
			ans=min(ans,abs(t[hoge]-x)+ns[hoge]);
		}else{
			ans=min(ans,abs(t[hoge]-x)+ns[hoge]);
			ans=min(ans,abs(t[hoge-1]-x)+ns[hoge-1]);
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

int main()
{
    int k;
    int n;
    cin >> k >> n;
    int arr[n];
    int maxint = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (i == n - 1)
        {
            maxint = max(maxint, (k - arr[i]) + arr[0]);
        }
        else
        {
            maxint = max(maxint, arr[i + 1] - arr[i]);
        }
    }
    cout << k - maxint << endl;
}

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

namespace Program1
{
    class Program
    {
        static void Main(string[] args)
        {

            var line = Console.ReadLine();
            var num = int.Parse(line);  //K倍

            var line2 = Console.ReadLine();
            var num2 = line2.Split(' ');
            var A = int.Parse(num2[0]); //A
            var B = int.Parse(num2[1]); //B (A <= Kx <= B)

            Boolean flag = false;

            for(var i = A; i < B + 1; i++)
            {
                if (i % num == 0)
                {
                    Console.WriteLine("OK");
                    flag = true;
                    break;
                }
            }
            if (flag == false)
            {
                Console.WriteLine("NG");
            }
        }

    }
}


Measured memory_bytes: 27436
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    string S;
    ll K;
    cin >> S >> K;
    ll ans = 0;
    ll len = 1;
    rep(i,S.size()-1){
        if (S[i] != S[i+1]) {ans += len/2; len = 1;}
        else{
            len++;
        }
    }
    
    if (len == S.size()){
        cout << (K*len)/2 << endl;
        rn 0;
    }
    

    
    if (S[0] == S[S.size()-1]){
        ll l0 = 1;
        rep(i,S.size()-1){
            if (S[i] == S[i+1]){l0++;}
            else break;
        }
        ans -= l0/2;
        ans *= K;
        ans += (l0+len)/2*(K-1) + len/2 + l0/2;
    }
    else{
        ans += len/2;
        ans *= K;
    }
    
    cout << ans << endl;
    rn 0;
}


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

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rf(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define rb(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int N = 1e5 + 1;
const int INF = 2e9;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    rf(i, 1, n) {
        rf(j, 1, n) {
            rf(k, 1, n) { ans += __gcd(__gcd(i, j), k); }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3652
#include <iostream>

bool is_unevenNumber(int n) {
    int digit = 0;
    while (n > 0) {
        ++digit;
        n /= 10;
    }
    return (digit % 2) == 1;
}

int main() {
    int N;
    int ans = 0;
    std::cin >> N;
    for (int i=1; i<=N; ++i) {
        if (is_unevenNumber(i)) ++ans;
    }
    std::cout << ans << std::endl;
    return 0;
}



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

using namespace std;
using i64 = int64_t;

string a;
i64 n;
vector<array<i64, 26>> g;
int main() {
    cin >> a;
    n = a.size();
    g = decltype(g)(n + 1);
    for (i64 i = 0; i <= n; ++i) {
        i64 k = a[i - 1] - 'a';
        for (i64 j = i - 1; j >= 0 && g[j][k] == 0; --j) {
            g[j][k] = i;
        }
    }

    queue<i64> q;
    q.push(0);
    vector<i64> p(n + 1, -1);
    while (!q.empty()) {
        i64 u = q.front(); q.pop();
        for (i64 k = 0; k < 26; ++k) {
            i64 v = g[u][k];
            if (v > 0) {
                if (p[v] < 0) {
                    q.push(v);
                    p[v] = u;
                }
            } else {
                string s;
                s.push_back(k + 'a');
                for (i64 v = u; v > 0; v = p[v]) s.push_back(a[v - 1]);
                reverse(begin(s), end(s));
                cout << s << '\n';
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 42884
#include<bits/stdc++.h>
    # define loop(i,a,n) for(int i=a;i<n;++i)
    # define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(0);
    # define ll long long int 
    using namespace std;
    int main()
    {
        fast
       long long int a,b,c,k;
       cin>>a>>b>>c>>k;
       long long int count=0;
       if(k>a)
       {
           count=count+a;
           k=k-a;
       }
       else
       {
           count=count+k;
           k=0;
       }

       if(k>b)
       {
           k=k-b;

       }
       else
       {
           k=0;
       }

       if(k>c)
       {
           count=count-c;

       }
       else
       {
           count=count-k;

       }
       cout<<count<<endl;
       

       

        return 0;
    }

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int n,sum=199999;
int main()
{
	cin>>n;
	for(int i=1;i<=n/2;i++)
	{
		int t=0;
		int a=i;
		int b=n-a;
		while(b!=0)
		{
			t=t+b%10;
			b/=10;
		}
		while(a!=0)
		{
			t=t+a%10;
			a/=10;
		}
	    if(t<sum) sum=t;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define showdp(d,n,m) fab(i,0,n){ fab(j,0,m) if(d[i][j]==-1 || d[i][j]>9) cout<<d[i][j]<<" "; else cout<<" "<<d[i][j]<<" "; cout<<endl; }
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 300005
#define inf 1e18+7
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}
 
bool isPrime(ll p)
{
    for(ll i=2;i*i<=p;i++)
        if(p%i==0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n+1];
    memset(prime,true,sizeof(prime));
    for(ll i=3;i*i<=n;i+=2)
        if(prime[i])
            for(ll j=i;j*i<=n;j+=2)
                prime[j*i]=false;
        
    for(ll i=3;i<=n;i+=2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result=n;
    for(ll p=2;p*p<=n;p++)
    {
        if(n%p==0)
        {
            while(n%p==0)
                n/=p;
            result-=result/p;
        }
    }

    if(n>1)
        result-=result/n;
    return result;
}


int main()
{
	sup;
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif */
	
    ll n,cnt=0;
    string s;
    map<string,ll>m;
    m["ABC"]=1;
    cin>>n>>s;
    fab(i,0,n-2)
    {
        string k;
        fab(j,0,3)
            k+=s[i+j];
        if(m[k]==1)
            cnt++;
    }
    pr(cnt);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<"### "<<x<<endl;
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
inline int read(){
    int x=0;char c=getchar();
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}
int main(){
	string a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<=2;i++)if(a[i]==b[i])ans++;
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
int k;
vector<int> a;
bool check(int idx)
{
    int dum = 0;
    for(auto x : a)
    {
        dum+=(x/idx);
        if(x%idx==0)
            dum--;
    }
    return (dum<=k);
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n;
    cin>>n>>k;
    a.resize(n);
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    int low = 1 , high = 1e9 , mid , ans;
    while(high>=low)
    {
        mid = (high+low)/2;
        if(check(mid))
        {
            ans = mid;
            high = mid-1;
        }
        else
            low = mid+1;
    }
    cout<<ans;


    printclock;
    return 0;
}

Measured memory_bytes: 4704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653

int main(){
	double n, m, d; cin >> n >> m >> d;
	if (n==1 && d==0) cout << setprecision(10) << (double)(m-1) << endl;
	else if (d==0) cout << setprecision(10) << (double)((n-d)*(m-1))/(n*n) << endl;
	else cout << setprecision(10) << (double)(2*(n-d)*(m-1))/(n*n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

struct edge { int to; long long weight;};
vector<vector<edge>> G;

vector<long long> dijkstra(int s) {
    vector<long long> dist(G.size(), numeric_limits<long long>::max());
    dist[s] = 0;
    using P = pair<long long, long long>;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (edge e : G[v]) {
            if (dist[e.to] > dist[v] + e.weight) {
                dist[e.to] = dist[v] + e.weight;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
    return dist;
}

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

    int v, e, r;
    cin >> v >> e >> r;
    G.resize(v);
    rep(i, e) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].pb(edge{t, d});
    }
    auto dist = dijkstra(r);
    rep(i, v) {
        if (dist[i] > 1e18) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
}



Measured memory_bytes: 19544