akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <limits.h>
int n,M[100][100];
int prim();
int main(){
  int i,j,w;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&w);
      if(w==-1)M[i][j]=INT_MAX;
      else M[i][j]=w;
    }
  }
  printf("%d\n",prim());
  return 0;
}
int prim(){
  int sum,i,u,mincost,C[100],d[100],p[100];
  for(i=0;i<n;i++){
    d[i]=INT_MAX;
    C[i]=0;
    p[i]=-1;
  }
  d[0]=0;
  while(1){
    u=-1;
    mincost=INT_MAX;
    for(i=0;i<n;i++){
      if(C[i]!=2&&d[i]<mincost){
        mincost=d[i];
        u=i;
      }
    }
    if(u==-1)break;
    C[u]=2;
    for(i=0;i<n;i++){
      if(C[i]!=2&&M[u][i]!=INT_MAX){
        if(d[i]>M[u][i]){
          d[i]=M[u][i];
          p[i]=u;
          C[i]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}



Measured memory_bytes: 2764
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,X,Y,Z = II()

max_val = (1<<17)-1
dp = [[0]*(max_val+1) for _ in range(N+1)]

for k in range(1,11):
    dp[1][1<<(k-1)] = 1

for i in range(1,N):
    for j in range(1,max_val+1):
        for k in range(1,11):
            val = ((j<<k) + (1<<(k-1))) & max_val
            if (val>>(Z-1)&1) and (val>>(Z+Y-1)&1) and (val>>(Z+Y+X-1)&1):
                continue
            else:
                dp[i+1][val] += dp[i][j]
                dp[i+1][val] %= mod

temp = 0
for j in range(1,max_val+1):
    temp += dp[N][j]
    temp %= mod

ans = (pow(10,N,mod)-temp)%mod
print(ans)

Measured memory_bytes: 85980
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
   int n;cin>>n;
   string s;cin>>s;
   stack<char>st;
   
   for(int i=0;i<n;i++)
   {
       if(st.empty() || st.top()!=s[i])
       st.push(s[i]);
   }
   int ans=st.size();
   cout<<ans<<endl;
}
int32_t main()
{
         rapido;
         int t;
         //cin>>t;
         t=1;
         while(t--)
         solve();
}

Measured memory_bytes: 3740
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(void){
    int a,b,c;
    cin >> a >> b >> c; 
    if(a < b && b < c){
        cout << "Yes";
        cout << endl;
    }else{
        cout << "No";
        cout << endl;
    }
 
}


Measured memory_bytes: 3088
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(m)]

xs = []
ys = []
for x, y, _ in xyz:
    x -= 1
    y -= 1
    xs.append(x)
    ys.append(y)

graph = csr_matrix(([1] * m, (xs, ys)), shape=(n, n))
num = connected_components(graph, connection="weak", return_labels=False)
print(num)


Measured memory_bytes: 52432
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main() {
    bool zero=false,more18=false;
    ll n,ans=1;
    ll maxn = pow(10,18);
    cin>>n;
    vll a(n);
    for(ll i=0;i<n;i++){
        cin>>a.at(i);
        if(a.at(i)==0){
            zero=true;
        }
    }
    if(zero)cout<<0<<endl;
    else{
       for(ll i=0;i<n;i++){
           if(a.at(i)>maxn){
            more18=true;
            break;
        }
        ans*=a.at(i);
        if(ans>maxn||ans<=0){
            more18=true;
           // cout<<ans<<endl;
            break;
        }
       //cout<<ans<<endl;
    } 
    
    if(more18)cout<<-1;
    else cout<<ans<<endl;
    }
    
    
}


Measured memory_bytes: 4056
package main

import (
	"fmt"
	"sort"
)

func main() {

	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	H := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(H)))

	var count int
	for i := K; i < N; i++ {
		count = count + H[i]
	}

	fmt.Println(count)

}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w; cin>>n>>w;
    ll dp[n+1][w+1];
    ll a[n+1],b[n+1];
    for(ll i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(ll i=0;i<=w;i++) dp[0][i]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(j>=a[i])
            dp[i][j]=max((b[i]+dp[i-1][j-a[i]]) , dp[i-1][j]);
            else 
            dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h> 
using namespace std;
long long max(long long a, long long b) { return (a > b)? a : b; } 
long long knapSack(int W, long long wt[], long long val[], int n) 
{ 
   int i, w; 
   long long K[n+1][W+1];
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   }
   return K[n][W]; 
} 
int main() 
{ 
	int  n , w;
	cin >> n >> w;
	long long val[n] , wt[n] ;
	for(int i = 0 ; i < n ; i++)
		cin >> wt[i] >> val[i] ;
	cout << knapSack(w, wt, val, n); 
	return 0; 
} 


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N;cin>>N;
    ll ans=0;
    int amari=0;
    for(int i=0;i<N;i++){
        ll a;cin>>a;
        ans+=(a+amari)/2;
        if(a!=0) amari=(a+amari)%2;
        else amari=0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>

using namespace std;
typedef long long ll;

void yes(){
cout<<"Yes"<<endl;
}
void no(){
cout<<"No"<<endl;
}
int main(){
string s;
cin>>s;
if(s.size()==2)
cout<<s<<endl;
else
cout<<s[2]<<s[1]<<s[0]<<endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A, B, C, res;
		A = scanner.nextInt();
		B = scanner.nextInt();
		C = scanner.nextInt();

		scanner.close();

		int[] num = { A, B, C };
		Arrays.sort(num);

		res = num[2] * 10 + num[1] + num[0];
		
		System.out.println(res);
	}
}


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

#define ll long long
#define all(x) (x).begin(),(x).end()
#define SZ(x) (x).size()
#define fir first
#define sec second

void scan() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}


using namespace std;
const int maxn = 2e5 + 7;
int a[maxn], pre[maxn];

int main() {
    //scan();

    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    map<string,int>mp;
    ll ret=0;
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        string ss;cin>>ss;
        sort(all(ss));
        ret+=mp[ss];
        mp[ss]++;
    }
    cout<<ret<<endl;


    return 0;
}




















Measured memory_bytes: 11264
#include <iostream>
#include <map>
using namespace std;
int main()
{
    int n;
    cin >> n;
    map<int, int> m;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        ++m[a];
    }
    int cnt = 0;
    for (auto e : m)
    {
        if (e.second % 2 == 1)
            ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define LL long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n;
LL a[100010];
int res=0;
int t;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	sort(a,a+n);
	t=(a[n-1]+1)/2;
	for (int i=0;i<n-1;i++)
	{
		if (abs(t-a[i])<abs(t-a[res]))
		    res=i;
	}
	cout <<a[n-1]<<" "<<a[res];
	return 0;
}

Measured memory_bytes: 1024
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  int n, a, mi, ma;
  mi = 1000000;
  ma = -1000000;
  long long su = 0;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    mi = min(mi, a);
    ma = max(ma, a);
    su += a;
  }
  cout << mi << " " << ma << " " << su << endl;

  return 0;
}



Measured memory_bytes: 3100
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = 0
for i in range(n):
    cnt += min(A[n - i], B[n - 1 - i])
    B[n - 1 - i] -= min(A[n - i], B[n - 1 - i])
    if(B[n - 1 - i] != 0):
        cnt += min(A[n - i - 1], B[n - 1 - i])
        A[n - i - 1] -= min(A[n - i - 1], B[n - 1 - i])

print(cnt)

Measured memory_bytes: 19004
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  long A,B,C,X,Y;
  long p[4];
  cin >> A >> B >> C >> X >> Y;
  p[0] = C * max(X,Y) * 2;
  if(X >= Y){
    p[1] = C * Y * 2 + A * (X-Y);
  }else{
    p[1] = C * X * 2 + B * (Y-X);
  }
  p[2] = A * X + B * Y;
  sort(p,p+3);
  cout << p[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,x,min=100000,max=0,count,ans=0;
    cin >> N;
    vector<int> v(100004,0);

    for(int i=0;i<N;i++){
        cin >> x;
        v.at(x)++;
        if(x<min){
            min = x;
        }
        if(x>max){
            max = x;
        }
    }

    for(int j=min;j<max+1;j++){
        count = 0;
        //xになるｖの要素を３回数えていて非効率、記憶させて効率化した
        count += (v.at(j)+v.at(j+1)+v.at(j+2));
        if(count > ans){
             ans = count;
        } 
    }
    cout << ans << endl;
}

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

int main() {
	int n; cin >> n;
	int a[n];
	int divi4 = 0, divi2 = 0, nodivi = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] % 4 == 0) divi4++;
		else if(a[i] % 2 == 0) divi2++;
		else nodivi++;
	}

	if(nodivi > (n+1) / 2) cout << "No" << endl;
	else if(n % 2 == 1 && nodivi == (n+1) / 2) {
		if(divi4 < nodivi - 1) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	else {
		if(divi4 < nodivi) cout << "No" << endl;
		else cout << "Yes" << endl;
	}


	return 0;
}


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

int main() {
  int H,W,N;
  cin >> H >> W >> N;
  int a[N];
  vector<int> vec;
  for(int i=0;i<N;i++){
    cin >> a[i];
    for(int j=0;j<a[i];j++){
      vec.push_back(i);
    }
  }
  for(int i=0;i<H;i++){
    if(i%2==0){
      for(int j=0;j<W;j++){
        int x=vec.front();
        vec.erase(vec.begin());
        cout << x+1 << ' ';
      }
    }
    else{
      vector<int> veve;
      for(int j=0;j<W;j++){
        veve.push_back(vec.front());
        vec.erase(vec.begin());
      }
      reverse(veve.begin(),veve.end());
      for(int j=0;j<W;j++){
        cout << veve.front()+1 << ' ';
        veve.erase(veve.begin());
      }
    }
    cout << endl;
  }   
}



Measured memory_bytes: 384
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
using namespace std;
typedef long long LL;
typedef double db;
#define pritnf printf
//char buf[1<<24],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
	if (x< 0) putchar('-'),x=-x;
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
int n;
int a[N],f[N]; LL c[N];
LL check (LL x)
{
	for (int i=1; i<=n; i++)
		c[i]=x/f[i];
	reverse (c+1,c+n+1);
	LL g=0;
	for (int i=1; i<=n; i++)
		if (a[i]> c[i]) g+=a[i]-c[i];
	return g;
}
int main ()
{
	// freopen (".in","r",stdin);
	// freopen (".out","w",stdout);
	sc(n);
	LL m; sc(m);
	for (int i=1; i<=n; i++)
		sc(a[i]);
	for (int i=1; i<=n; i++)
		sc(f[i]);
	sort (a+1,a+n+1);
	sort (f+1,f+n+1);
	LL L=-1,R=1e12+1;
	while (L+1< R)
	{
		LL mid=(L+R)>>1;
		if (check (mid)<=m) R=mid;
		else L=mid;
	}
	pr(R);

	return 0;
}


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

int main(){
	int d,t,s;cin>>d>>t>>s;
	if(s*t>=d)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double; using pll = pair<lint, lint>;

int main(void) {
    int n, T;
    cin >> n >> T;
    const int INF = 1e9;
    int ans = INF;
    repeat (i, n) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans == INF) {
        cout << "TLE" << endl;
    }
    else {
        cout << ans << endl;
    }
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

struct Edge{
  int src, dst;
  int cost;
  Edge() {}
  Edge(int src_, int dst_, int cost_) : src(src_), dst(dst_), cost(cost_) {;}
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<Edge> e(M);
  REP(i, M) {
    int src, dst, cost;
    cin >> src >> dst >> cost;
    --src; --dst;
    e[i] = Edge(src, dst, cost);
  }

  vector<vector<int>> dist(N, vector<int> (N, INF));
  REP(i, N) dist[i][i] = 0;
  REP(i, M) {
    dist[e[i].src][e[i].dst] = e[i].cost;
    dist[e[i].dst][e[i].src] = e[i].cost;
  }
  REP(k, N)REP(i, N)REP(j, N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  int ret = 0;
  REP(i, M){
    bool flag = false;
    REP(j, N) if(dist[j][e[i].src] + e[i].cost == dist[j][e[i].dst]) flag = true;
    if(!flag) ++ret;
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
void variance(int *v, int n) {
  int i;
  double sum1 = 0;//??´??°??????????????¨?????????????????????????????????????????????
  double sum2 = 0;
  for(i = 0; i < n; i++) {
	sum1 += v[i];
	sum2 += pow(v[i], 2);
  }
  long double Ave = sum1 / n;
  long double Var = sum2 / n - pow(Ave, 2.0);
  printf("%.8f\n", sqrt(Var));
}
  
int main() {
  int i, n;
  int *p;
  while(cin >> n) {
	if (n == 0) { break; }
	p = new int[1000];
	for(i = 0; i < n; i++) {
	  cin >> p[i];
	}
	variance(p, n);
  }
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<int> d(n);
  rep(i,n)cin>>d[i];
  sort(d.begin(),d.end());
  int m = n/2;
  cout << d[m]-d[m-1] << endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException, NumberFormatException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		if( line != null ){
			String[] parts = line.split(" ");
			int lon = Integer.parseInt(parts[0]);
			int sid = Integer.parseInt(parts[1]);
			System.out.println((lon * sid) + " " + (lon * 2 + sid * 2));
		}
	}

}

Measured memory_bytes: 24184
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n;
    cin>>n;
    ll ans=0;
    rep(i,1,n+1)
    {
        ll x;
        cin>>x;
        if(x%2&&i%2)
            ans++;
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3604
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

import sun.security.krb5.Asn1Exception;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		char a[] = new char[9];

		for (int i = 0; i < 9; i += 3) {
			String input = scan.next();

			a[i] = input.toCharArray()[0];
			a[i + 1] = input.toCharArray()[1];
			a[i + 2] = input.toCharArray()[2];
		}

		String ans = String.valueOf(a[0])
				+ String.valueOf(a[4])
				+ String.valueOf(a[8]);

		System.out.println(ans);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27032
use v5.18;
use warnings;
use List::Util qw( max );
sub read_line { chomp(my $str = <STDIN>); $str }
sub splited_read_line { split / /, read_line }

my ($A, $B) = splited_read_line;
say( max( $A + $B, $A - $B, $A * $B ) );


Measured memory_bytes: 768
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int jewnum, comnum, rx, ry;
		boolean hoge;
		
		int[][] route = new int[21][21];
		
		for(;;){
			jewnum = scanner.nextInt();
			if(jewnum == 0) break;
			int[] jewxpos = new int[jewnum];
			int[] jewypos = new int[jewnum];
			for(int i = 0; i < jewnum; i++){
				jewxpos[i] = scanner.nextInt();
				jewypos[i] = scanner.nextInt();
			}
			
			comnum = scanner.nextInt();
			String[] comdir = new String[comnum];
			int[] comdis = new int[comnum];
			for(int i = 0; i < comnum; i++){
				comdir[i] = scanner.next();
				comdis[i] = scanner.nextInt();
			}
			
			rx = ry = 10;
			for(int i = 0; i < 21; i++){
				for(int j = 0; j < 21; j++){
					route[i][j] = 0;
				}
			}
			for(int i = 0; i < comnum; i++){
				if(comdir[i].equals("N")){
					for(int j = 1; j <= comdis[i]; j++){
						++ry;
						route[rx][ry] = 1;
					}
				}else if(comdir[i].equals("E")){
					for(int j = 1; j <= comdis[i]; j++){
						++rx;
						route[rx][ry] = 1;
					}
				}if(comdir[i].equals("S")){
					for(int j = 1; j <= comdis[i]; j++){
						--ry;
						route[rx][ry] = 1;
					}
				}if(comdir[i].equals("W")){
					for(int j = 1; j <= comdis[i]; j++){
						--rx;
						route[rx][ry] = 1;
					}
				}
			}
			
			hoge = true;
			for(int i = 0; i < jewnum; i++){
				if(route[jewxpos[i]][jewypos[i]] == 0){
					hoge = false;
				}
			}
			
			if(hoge == true)	System.out.println("Yes");
			else System.out.println("No");
		}
	}
}

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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

int32_t main()
{
    fastio;
    int h, w;
    cin >> h >> w;
    int a[h][w], b[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin >> a[i][j];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin >> b[i][j];

    const int N = 2*6400 + 1;
    bool dp[h+1][w+1][N];
    memset(dp, 0, sizeof(dp));
    dp[1][0][0] = 1;
    dp[0][1][0] = 1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            for(int k=0;k<N;k++)
            {
                int x = k + abs(a[i-1][j-1] - b[i-1][j-1]), y = abs(k - abs(a[i-1][j-1] - b[i-1][j-1]));
                if(dp[i-1][j][k])
                {
                    dp[i][j][x] = 1;
                    dp[i][j][y] = 1;
                }
                if(dp[i][j-1][k])
                {
                    dp[i][j][x] = 1;
                    dp[i][j][y] = 1;
                }
                    
            }
        }
    }
    int ans = 0;
    while(dp[h][w][ans] == 0)
        ans++;
    cout << ans <<"\n";
    return 0;
}



Measured memory_bytes: 82432
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)
const int MAX_S = 1e4 + 10;

int main() {
    int n; cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s[i];
    vector<vector<int>> dp(n+1, vector<int>(MAX_S, 0));
    dp[0][0] = 1;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<MAX_S; ++j) {
            dp[i+1][j] |= dp[i][j];
            if (j >= s[i]) {
                dp[i+1][j] |= dp[i][j - s[i]];
            }
        }
    }
    int ans = 0;
    rep(i, MAX_S) {
        if (i%10 == 0) continue;
        if (dp[n][i]) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
using namespace std;
string s;
long K;
main()
{
	cin>>s>>K;
	vector<pair<char,int> >A;
	A.push_back(make_pair(s[0],1));
	for(int i=1;i<s.size();i++)
	{
		if(A.back().first==s[i])A.back().second+=1;
		else A.push_back(make_pair(s[i],1));
	}
	if(A.size()==1)
	{
		long T=K*A[0].second;
		cout<<T/2<<endl;
		return 0;
	}
	long ans=0,T=0;
	ans+=A[0].second/2;
	for(int i=1;i+1<A.size();i++)T+=A[i].second/2;
	ans+=T*K;
	ans+=A.back().second/2;
	if(A[0].first==A.back().first)
	{
		ans+=(K-1)*((A[0].second+A.back().second)/2);
	}
	else
	{
		ans+=(K-1)*(A[0].second/2+A.back().second/2);
	}
	cout<<ans<<endl;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    int N, M;
    cin >> N >> M;

    cout << N * M;
}

signed main()
{

    solve();

    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    string S;
    cin >> S;
    vector<vector<unsigned long>> dp(N + 1, vector<unsigned long>(N + 1));
    unsigned long ans{0};
    for(unsigned long i = 2; i <= N; ++i)for(unsigned long j = 1; j < i; ++j){
        if(S[i - 1] != S[j - 1])continue;
        ans = max(ans, dp[i][j] = min(i - j, dp[i - 1][j - 1] + 1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 195840
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int n;

void dfs(string s, char mx)
{
  if (s.length() == n)
  {
    cout << s << endl;
  }
  else
  {
    for (char c = 'a'; c <= mx; ++c)
    {
      dfs(s + c, (c == mx ? (char)(mx + 1) : mx));
    }
  }
}

int main()
{
  cin >> n;
  dfs("", 'a');

  return 0;
}


Measured memory_bytes: 1536
N = int(input())
flg = 0

for i in range(N//7+1):
    for j in range(N//4+1):
        money = 7*i + 4*j
        if money == N:
            flg = 1
            break
      
if flg == 1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
int main(){
	int arr[100000];
	int n, i;
	bool can=true;
	scanf("%d", &n);
	scanf("%d", &arr[0]);
	for(i=1; i<n; i++){
		scanf("%d", &arr[i]);
		//printf("%d ", arr[i]);
		if(arr[i]-arr[i-1]<0){
			can=false;
		}
		if(arr[i]-arr[i-1]>0){
			arr[i]--;
		}
	}
	printf("%s\n", (can ? "Yes" : "No"));
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');
            int N = int.Parse (str[0]);

            str = Console.ReadLine ().Split (' ');

            int[] A = new int[N + 2];

            A[0] = 300;
            A[N + 1] = 0;
            for (int i = 1; i <= N; i++)
            {
                A[i] = int.Parse (str[i - 1]);
            }

            long m = 1000;
            int tmp = 300;
            for (int i = 1; i <= N; i++)
            {
                if (tmp > A[i]) tmp = A[i];

                if (A[i - 1] < A[i] && A[i] >= A[i + 1])
                {
                    m = (m / tmp) * A[i] + m % tmp;
                    tmp = 300;
                }
            }
            Console.WriteLine (m);

        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

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

typedef long long ll;

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

ll lcm(ll a, ll b) {
  return a/gcd(a, b)*b;
}

int main() {
  ll a, b, d;
  while (true) {
    cin >> a >> b >> d;
    if (a == 0 && b == 0 && d == 0) break;

    ll ansx = 10000000000, ansy = 10000000000;
    for (int i = -100000; i <= 100000; i++) {
      if ((d-b*i)%a != 0) continue;
      ll j = (d-b*i)/a;

      ll tx, ty;
      tx = abs(j); ty = abs(i);
      if (ansx+ansy > tx+ty ||
	  (ansx+ansy == tx+ty && ansx*a+ansy*b > tx*a+ty*b)) {
	ansx = tx;
	ansy = ty;
      }
    }

    cout << ansx << " " << ansy << endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  int ans = 0;
  
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == '1') ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import random
import math
import sys
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("Yes")
no = lambda: print("No")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
s = SI()
t = SI()
print("Yes" if len(s)+1 == len(t) and t[:len(s)] == s else "No")

Measured memory_bytes: 9568
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	ll ret=0;
	for (int i=1; i<=N; i++)
		if(i%3==0 || i%5==0) {
			;
		} else ret+=i;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(){
  int n,W;
  cin >> n >> W;
  long long dp[n+1][W+1];
  for(int i = 0; i <= W; ++i){
    dp[0][i] = 0;
  }
  int a[n][2];
  for(int i = 0; i < n; ++i){
    cin >> a[i][0] >> a[i][1];
  }
  for (int i = 1; i <= n; ++i){
    for(int j = 0; j <= W; ++j){
      if(a[i-1][0] > j){
	dp[i][j] = dp[i-1][j];
      }
      else{
	dp[i][j] = max(dp[i-1][j],dp[i-1][j-a[i-1][0]]+a[i-1][1]);
      }
    }
  }
  cout << dp[n][W];
}


Measured memory_bytes: 79104
n, k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

hands = {'r':p, 's':r, 'p':s}
ans = 0

# k個に分けて,それぞれ貪欲法によって求める
for i in range(k):
    last_hand = ""
    j = i
    while j < n:
        opposite_hand = t[j]
        if opposite_hand != last_hand:#　相手の手がk回前の手と異なる場合、勝ちの手をストレートに出す
            ans += hands[opposite_hand]
            last_hand = opposite_hand
        else:# 相手の手がk回前の手と異なる場合、k回後に勝てるように取っておく
            last_hand = "" #k回後に勝てる手を出すために、リセットしておく
        j += k

print(ans)

Measured memory_bytes: 3444
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void A(){
    ll k,a,b; cin >> k >> a >> b;
    ll i = k;
    while(i<a){
        i+=k;
    }

    if(i<=b) cout << "OK" << endl;
    else           cout << "NG" << endl;
    
}
void B(){
    ll x; cin >> x;
    ll sum = 100;
    ll i = 0;
    while(sum<x){
        sum *=1.01;
        i++;
    }
    cout << i << endl;
    
}

void C(){

}

void D(){
    ll a,b,n; cin >> a >> b >> n;
    cout << (a*min((b-1),n))/b << endl;
}
void e(){}

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

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    ll a,b;cin>>a>>b;
    cout<<(a*b/gcd(a,b))<<endl;    
    return 0;
}


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

int main() {
    string N;
    cin >> N;
    long long K = N.size();
    int total = 0;

    bool nineAll = true;
    for (int i = 1; i < K; ++i) {
        if (N[i] != '9') nineAll = false;
    }

    if (nineAll) {
        total += (int)N[0] - '0';
        total += 9 * (K - 1);
    } else {
        total += (int)N[0] - '0' - 1;
        total += 9 * (K - 1);
    }


    cout << total << endl;
}

Measured memory_bytes: 256
/*
ABC154D - Dice in Line
*/

#include <stdio.h>

int main()
{
	int n, k;
	int p[200000];
	int i;
	double max, karimax;

	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%d", &(p[i]));
	}

	for (i = 0; i < k; i++) {
		if ((p[i] % 2) == 1) {
			max += (p[i] / 2) + 1;
		} else {
			max += (p[i] / 2) + 0.5;
		}
	}
	karimax = max;

	if (k == n) {
		printf("%lf\n", max);
		return 0;
	}

	for (i = k; i < n; i++) {
		if ((p[i] % 2) == 1) {
			karimax += (p[i] / 2) + 1;
		} else {
			karimax += (p[i] / 2) + 0.5;
		}

		if ((p[i - k] % 2) == 1) {
			karimax -= (p[i - k] / 2) + 1;
		} else {
			karimax -= (p[i - k] / 2) + 0.5;
		}

		if (karimax > max) {
			max = karimax;
		}
	}

	printf("%lf\n", max);

	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	const ll MOD = 1e9 + 7;
	int n; cin >> n;
	vector<int>a(n), cum(n+1);
	ll tot = 0, sq = 0;
	for(int i=0;i <n; i++){
		cin >> a[i];
		cum[i+1] = a[i] + cum[i];
		cum[i+1] %= MOD;
	}
	ll ret = 0;
	for(int i=0; i<n-1; i++){
		ll sum = (cum[n]-cum[i+1] + MOD) % MOD;
		ret += (a[i] * sum) % MOD;
		ret %= MOD;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4780
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;
 
int n;
int p=0,dif=0;
char s[N];
 
void dfs(int u){
   if(u==n){
      puts(s);
      return;
   }
  
   for(char i=0;i<=dif;++i){
     s[p++]=i+'a';
     int tmp=dif;
     if(i==dif) dif++;
     dfs(u+1);
     p--;
     dif=tmp;
   }
 
}
 
int main(){
 ios::sync_with_stdio(false);
  cin>>n;
  dfs(0);
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n,m,i,j,d,x,y;
int main()
{
  cin>>x;n=x/100;y=100*n+10*n+n;
  if(x<=y)return cout<<y,0;
  else return n++,cout<<100*n+10*n+n,0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S;
    cin >> S;
    if (S.substr(0, 4) == "YAKI") cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int c[4][4];
int a[4];
int b[4];

int main() {
    int N, A;

    for (int i = 1; i < 4; i++) {
        for (int j = 1; j < 4; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 0; i < 100; i++) {
        a[1] = i;
        b[1] = c[1][1] - a[1];
        b[2] = c[1][2] - a[1];
        b[3] = c[1][3] - a[1];
        a[2] = c[2][2] - b[2];
        a[3] = c[3][3] - b[3];

        bool flag = true;
        for (int i = 1; i < 4; i++) {
            for (int j = 1; j < 4; j++) {
                if (c[i][j] != a[i] + b[j]) {
                    flag = false;
                }
            }
        }

        if (flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    ll N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(2));

    rep(i, N) { cin >> A[i][0] >> A[i][1]; }

    reverse(A.begin(), A.end());

    ll mod_sum = 0;
    ll cnt = 0;
    rep(i, N) {
        ll push = A[i][1] - ((A[i][0] + mod_sum) % A[i][1]);
        if (push == A[i][1])
            continue;
        cnt += push;
        mod_sum += push;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    int sum = 0;
    for(auto e:v){
        while(e%2==0){
            e/=2;
            sum++;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;
	
	int ret;
	if(s == "SUN"){
		ret = 7;
	}
	if(s == "MON"){
		ret = 6;
	}
	if(s == "TUE"){
		ret = 5;
	}
	if(s == "WED"){
		ret = 4;
	}
	if(s == "THU"){
		ret = 3;
	}
	if(s == "FRI"){
		ret = 2;
	}
	if(s == "SAT"){
		ret = 1;
	}
	
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input()) 
idx=[] 
c=0 
for i in range(n):
	x,y=map(int,input().split()) 
	if x==y:
		idx.append(c) 
	c+=1  
if len(idx)<3:
	print('No') 
else:
	flag=False 
	#print(idx)
	for i in range(len(idx)-2): 
		if idx[i]-idx[i+1]==-1 and idx[i+1]-idx[i+2]==-1:
			flag=True  
			break 
	dd={False:'No',True:'Yes'}
	print(dd[flag])









Measured memory_bytes: 62508
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  vector<int> v = {a1, a2, a3};
  sort(v.begin(), v.end());
  cout << v[2]-v[0] << "\n";

}


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

const int MAXN = 3e5 + 10;

struct Node {
	int val, idx;
	bool operator < (const Node & obj) {return val < obj.val || val == obj.val && idx > obj.idx;}
} a[MAXN];
int v[MAXN], vis[MAXN];
map<int, int> mp;

int main (void) {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= 3 * n; i++) {
		scanf("%d", &v[i]);
		a[i].val = v[i];
		a[i].idx = i;
	}
	sort(a+1,a+3*n+1);
	long long sum1 = 0, sum2 = 0;
	for (int i = 1; i <= n; i++) {
		sum1 += v[i];
		mp[v[i]]++;
		vis[i] = 1;
	}
	int cur = 1, cnt = 0;
	for (int i = 1; i <= 3 * n && cnt < n; i++, cur++) {
		if (vis[a[i].idx]) continue;
		sum2 += a[i].val;
		vis[a[i].idx] = 1;
		cnt++;
	}

	long long ans = sum1 - sum2;
	for (int i = n + 1; i <= 2 * n; i++) {
		int val = mp.begin()->first;
		if (v[i] > val) {
			sum1 += v[i] - val;
			mp.begin()->second--;
			if (mp.begin()->second == 0) mp.erase(mp.begin());
			mp[v[i]]++;
		}
		if (vis[i]) {
			sum2 -= v[i];
			for (; cur <= 3 * n; cur++) {
				if (vis[a[cur].idx]) continue;
				sum2 += a[cur].val;
				vis[a[cur].idx] = 1;
				break;
			}
			if (cur == n + 1) break;
		}
		ans = max(sum1 - sum2, ans);
		vis[i] = 1;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 9600
import sys
input=sys.stdin.readline
import math

def main():

    N,K = map(int, input().split())
    ans = 0
    for i in range(N):
        if i+1 >= K:
            ans += 1.0/N
        else:
            ans += 1.0/N * 0.5**math.ceil(math.log2(K/(i+1)))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060