akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	//	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	s := stringLineScan()
	t := stringLineScan()
	if check(s, t) && check(t, s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
func check(s, t string) bool {
	x := map[byte]byte{}
	for i := 0; i < len(s); i++ {
		si, ti := s[i], t[i]
		sv, sok := x[si]
		if !sok {
			x[si] = ti
		} else if sv != ti {
			return false
		}
	}
	return true
}


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

namespace ABC115B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int [10];
            int s = 0;
            a[0] = int.Parse(Console.ReadLine());
            int b  = a[0] ;
            s += a[0];
            for (int i = 1; i <= n - 1; i ++ )
            {
                a[i] = int.Parse(Console.ReadLine());
                s += a[i];
                if (b <= a[i])
                {
                    b = a[i];
                }
            }

            if (b < a[0])
                b = a[0];

            s  = s - b / 2;



            Console.WriteLine(s);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const ll MOD = 1e9+7;

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

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

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

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

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

class RMQ{
	int n;
	vector<int> dat;
public:
	RMQ(int n_){
		n = 1;
		while(n < n_) n *= 2;
		REP(i, n*2-1){
			dat.push_back(INF);
		}
	}

	void update(int x, int i){
		i += n-1;
		dat[i] = x;
		while(i > 0){
			i = (i-1)/2;
			dat[i] = min(dat[i*2+1], dat[i*2+2]);
		}
	}

	int query(int a, int b, int l, int r, int x){
		if(a <= l && r <= b) return dat[x];
		if(r <= a || b <= l) return INF;

		int res = INF;
		res = min(query(a, b, l, (l+r)/2, x*2+1), query(a, b, (l+r)/2, r, x*2+2));
		return res;
	}
	int query(int a, int b){
		return query(a, b, 0, n, 0);
	}
};

const ll mod = 1e9+7;

ll x[114514] = {}, y[114514] = {};
ll sumx[114514] = {}, sumy[114514] = {};
ll ssx[114514] = {}, ssy[114514] = {};
int main(void){
	int n, m;
	cin >> n >> m;
	ll xs = 0, ys = 0;
	REP(i, n){
		cin >> x[i];
	}
	ll ss = 0;
	FOR(i, 1, n){
		sumx[i] = x[i]-x[i-1];
		sumx[i] += sumx[i-1];
		xs += sumx[i]*i-ss;
		ss += sumx[i];
		xs %= mod; ss %= mod;
	}
	ss = 0;
	REP(i, m){
		cin >> y[i];
	}
	FOR(i, 1, m){
		sumy[i] = y[i]-y[i-1];
		sumy[i] += sumy[i-1];
		ys += sumy[i]*i-ss;
		ss += sumy[i];
		ys %= mod; ss %= mod;
	}
	cout << (ys*xs)%mod << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>

using namespace std;
int N;
int t, x, y;

int main() {
  cin >> N;
  int startx = 0;
  int starty = 0;
  int startt = 0;
  for (int i=0; i<N; i++) {
    cin >> t >> x >> y;
    int dist = abs(x-startx) + abs(y-starty);
    int time = t - startt;
    if (time < dist || time%2 != dist%2) {
      cout << "No" << endl;
      return 0;
    }
    startx = x;
    starty = y;
    startt = t;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int a,b;
  cin>>a>>b;
  if(a==1) a=MOD;
  if(b==1) b=MOD;
  cout<<(a==b?"Draw":((a>b)?"Alice":"Bob"))<<Endl;
  return 0;
}


Measured memory_bytes: 256
package main
 
import (
  "fmt"
)

func main() {
  
  var n,m int
  fmt.Scan(&n)
  
  //奇数の数
  m = n-n/2
  
  //確率
  var p float64
  p = float64(m)/float64(n)
  
  fmt.Printf("%.10f\n",p)  
}


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

using namespace std;

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

void solve() {
    string s;
    cin >> s;
    s = "@" + s;

    const int n = s.size();

    long long dp[n + 1][4];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= 3; j++) {
            dp[i][j] = 0;
        }
    }

    // 0 - просто пустой символ
    // 1 - A
    // 2 - B
    // 3 - C

    for (int i = 1; i <= n; i++) {
        if (s[i] == 'A') {
            dp[i][1] = dp[i - 1][1] + 1;
        } else if (s[i] == '?') {
            dp[i][1] = 3 * dp[i - 1][1] + 1;
        } else {
            dp[i][1] = dp[i - 1][1];
        }
    }

    for (int ch = 2; ch <= 3; ch++) {
        for (int i = 1; i <= n; i++) {
            if (s[i] - 'A' == ch - 1) {
                dp[i][ch] = dp[i - 1][ch - 1] + dp[i - 1][ch];
            } else if (s[i] == '?') {
                dp[i][ch] = dp[i - 1][ch - 1] + 3 * dp[i - 1][ch];
            } else {
                dp[i][ch] = dp[i - 1][ch];
            }
        }
    }

    cout << dp[n][3];

}

long long dp[200000][4];
typedef long long ll;
void k1() {
    dp[0][0]=1;

    string st;
    cin>>st;

    for (int i=1;i<=st.size();i++)
        for (int j=0;j<=3;j++){
            if (st[i-1]=='?')
            {
                if (j!=0)
                    dp[i][j]=dp[i-1][j]*ll(3)+dp[i-1][j-1]; else
                    dp[i][j]=dp[i-1][j]*ll(3);
                dp[i][j]%=md;
            } else
            if (st[i-1]-'A'==j-1)
            {
                dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
                dp[i][j]%=md;
            } else
            {
                dp[i][j]=dp[i-1][j];
                dp[i][j]%=md;
            }
        }

    cout<<dp[st.size()][3];
}

int main() {
    k1();
//    string s;
//    cin >> s;
//    int n = s.size();
//
//    int ans = 0;
//    for (int i = 0; i < n; i++) {
//        for (int j = i + 1; j < n; j++) {
//            for (int k = j + 1; k < n; k++) {
//                if (s[i] == 'A' && s[j] == 'B' && s[k] == 'C') {
//                    cout << i << " " << j << " " << k << endl;
//                    ans++;
//                }
//            }
//        }
//    }
//    cout << ans;
    return 0;
}

Measured memory_bytes: 4608
/**
 * @author torith
 * @date 2018-10-24
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    ll X,Y;
    cin >> X >> Y;

    int ans = 0;
    while(X <= Y){
        X *= 2; ans ++;
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
N, M = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

sum = 0
0.upto(M-1).each do |i|
  sum += A[i]
end

if (N >= sum)
  p N - sum
else
  p (-1)
end


Measured memory_bytes: 14756
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ss = s.split(" ");
		Stack stack = new Stack();
		for(int i = 0; i < ss.length; i++){
			if(ss[i].equals("+")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a + b);
			}else if(ss[i].equals("-")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(b - a);
			}else if(ss[i].equals("*")){
				int a = stack.pop();
				int b = stack.pop();
				stack.push(a * b);
			}else{
				stack.push(Integer.parseInt(ss[i]));
			}
		}
		System.out.println(stack.pop());
		in.close();
	}
}

class Stack {
	int[] data;
	int top = 0;
	Stack(){
		data = new int[101];
		top = 0;
	}
	void push(int x){
		data[top++] = x;
	}
	int pop(){
		return data[--top];
	}
	boolean isEmpty(){
		return top == 0;
	}
	boolean isFull(){
		return top == data.length;
	}
}

Measured memory_bytes: 26060
#include<bits/stdc++.h>
#include<stdint.h>
#define ff first
#define ss second

using namespace std;


#define MOD 1e9+7
#define ll long long int
int ans=0;
pair<pair<int,int>,pair<int,int> > p[100];
int a[100];
int n,m,q;

void dfs(int giv,int pos)
{
	if(pos==n+1)
	{
		int mxm=0;
		for(int i=0;i<q;i++)
		{
			if(a[p[i].ff.ss]-a[p[i].ff.ff] == p[i].ss.ff)
				mxm+=p[i].ss.ss;
		}
		ans=max(ans,mxm);
		return ;
	}

	for(int i=giv;i<=m;i++)
	{
		a[pos] = i;
		dfs(i,pos+1);
	}
}

void solve()
{
	
	cin>>n>>m>>q;

	for(int i=0;i<q;i++)
		cin>>p[i].ff.ff>>p[i].ff.ss>>p[i].ss.ff>>p[i].ss.ss;
	
	dfs(1,1);

	cout<<ans<<'\n';
}


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	#ifndef ONLINE_JUDGE 
      	freopen("_input.txt", "r", stdin); 
  	freopen("_output.txt", "w", stdout); 
  	#endif 
	

    solve();

	
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

pair<int, int> game(int t, int ao) {
  if (t % 2 != 0) {
    --t;
  }
  t /= 2;
  ao += t;
  return make_pair(t, ao);
}

pair<int, int> solve(int a, int b, int k) {
  int t = a, ao = b;
  REP(i, k) {
    if (i % 2 == 0) {
      auto p = game(t, ao);
      t = p.first;
      ao = p.second;
    } else {
      auto p = game(ao, t);
      t = p.second;
      ao = p.first;
    }
  }
  return make_pair(t, ao);
}

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  auto p = solve(a, b, k);
  cout << p.first << " " << p.second << endl;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
// typedef long long double long double;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

long double calcCircleOf2Point(long double x1, long double y1, long double x2, long double y2, long double x3, long double y3, long double *cx, long double *cy, long double *r)
{
	long double 	ox, oy, a, b, c, d ;
	long double 	r1, r2, r3 ;
	long double		stat ;

	a = x2 - x1 ;
	b = y2 - y1 ;
	c = x3 - x1 ;
	d = y3 - y1 ;

	stat = -1 ;

	if  ((a && d) || (b && c)) {
		ox = x1 + (d * (a * a + b * b) - b * (c * c + d * d)) / (a * d - b * c) / 2.0 ;
		if  (b) {
			oy = (a * (x1 + x2 - ox - ox) + b * (y1 + y2)) / b / 2.0 ;
		} else {
			oy = (c * (x1 + x3 - ox - ox) + d * (y1 + y3)) / d / 2.0 ;
		}
		r1   = sqrtl((ox - x1) * (ox - x1) + (oy - y1) * (oy - y1)) ;
		r2   = sqrtl((ox - x2) * (ox - x2) + (oy - y2) * (oy - y2)) ;
		r3   = sqrtl((ox - x3) * (ox - x3) + (oy - y3) * (oy - y3)) ;
		*cx = ox ;
		*cy = oy ;
		*r  = (r1 + r2 + r3) / 3.0 ;
		stat = 0 ;
	}

	return stat ;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(16);
    cout << fixed;

    int n;
    cin>>n;
    vector<long double> x(n), y(n);
    rep(i, n) {
        cin>>x[i]>>y[i];
    }

    long double xans, yans, rans = 0;
    rans = DBL_MAX;
    long double delta = 0.00000000001;
    rep(i, n) for(int j = i + 1; j < n; j++) {
        long double cr = sqrtl(powl(x[j] - x[i], 2) + powl(y[j] - y[i], 2)) / 2.0;
        long double cx = (x[j] + x[i]) / 2.0;
        long double cy = (y[j] + y[i]) / 2.0;
        bool ok = true;
        rep(l, n) {
            long double dist = sqrtl(powl((x[l]-cx), 2) + powl(y[l]-cy, 2));
            if (cr + delta < dist) {
                ok = false;
                break;
            }
        }

        if (ok and rans > cr) {
            rans = cr;
        }
    }

    rep(i, n) for(int j = i + 1; j < n; j++) for(int k = j + 1; k < n; k++) {
        long double cx,cy,cr;
        int res = calcCircleOf2Point(x[i],y[i],x[j],y[j],x[k],y[k],&cx,&cy,&cr);

//        cout << cx << " " << cy << " " << cr << endl;
        bool ok = true;
        rep(l, n) {
            long double dist = sqrtl(powl((x[l]-cx), 2) + powl(y[l]-cy, 2));
            if (cr + delta < dist) {
                ok = false;
                break;
            }
        }

        if (res == 0 and ok and rans > cr and cr > 0) {
            rans = cr;
            xans = cx;
            yans = cy;
        }
    }

    cout << rans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int m = 0;	//中間試験
		int f = 0;	//期末試験
		int r = 0;	//再試験
		int sum;//中間試験と期末試験の点数の合計
        while(true){
			 m = Integer.parseInt(scan.next());
			 f = Integer.parseInt(scan.next());
			 r = Integer.parseInt(scan.next());
			 sum = m + f;
			 if(m == -1 && f ==-1 && r == -1){
				 break;
			 }else{
				 if(m == -1 || f == -1){
					 System.out.println("F");
				 }else if(sum >= 80){
					 System.out.println("A");
				 }else if(sum >= 65 && sum <= 80){
					 System.out.println("B");
				 }else if(sum >= 50 && sum <= 65){
					 System.out.println("C");
				 }else if(sum >= 30 && sum <= 50){
					 if(r >= 50){
						 System.out.println("C");
					 }else{
						 System.out.println("D");
					 }
				 }else{
					 System.out.println("F");
				 }//if
			 }//if
		 }//while 
	}
}

Measured memory_bytes: 17320
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<set>
#include<map>
#include<queue>
#include<vector>
#define ll long long int
#define INF 0x7fffffff
#define me(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int x=(a-c)/(b+c);
    cout<<x<<endl;
}


Measured memory_bytes: 256
n=int(input())
s=input()
l=0
r=n
while r-l!=1:
  mid=(r+l)//2
  dic={}
  flag=False
  for i in range(n-mid+1):
    tmp=s[i:i+mid]
    if tmp not in dic:
      dic[tmp]=i+mid
    else:
      if dic[tmp]<=i:
        flag=True
        break
  if flag==True:
    l=mid
  else:
    r=mid
print(l)

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

const int MOD = 1000000007;

const int N = 100005;
char s[N];

int main() {
	scanf("%s", s);
	printf("%s\n", (strlen(s) + (s[0] == s[strlen(s) - 1])) % 2 ? "First" : "Second");
	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

							  //ライブラリ？
typedef vector<ll> vec;
typedef vector<vec> mat;

//A*Bの計算
mat mul(const mat& A, const mat& B) {
	mat C(A.size(), vec(B[0].size()));
	REP(i, A.size())REP(k, B.size())REP(j, B[0].size())
		C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
	return C;
}

//A^Kの計算
mat pow(mat A, ll N) {
	mat B(A.size(), vec(A.size()));
	REP(i, A.size())B[i][i] = 1;
	while(N > 0) {
		if(N & 1)B = mul(B, A);
		A = mul(A, A);
		N >>= 1;
	}
	return B;
}



//メイン関数
int main()
{
	ll N, K;
	cin >> N >> K;
	vector<vector<ll>> a(N, vector<ll>(N));
	REP(i, N)REP(j, N) cin >> a[i][j];

	auto res = pow(a, K);
	ll ans = 0;
	for(auto row : res)for(auto col : row)ans = (ans + col) % MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
require 'prime'

N, K = gets.chomp.split(' ').map(&:to_i)
a_array = gets.chomp.split(' ').map(&:to_i)

# print a_array
# print "\n"


# まずは divisors を全て出す
# sum = a_array.inject(:+)
sum = 0
a_array.each{|x| sum += x}
primes, powers = sum.prime_division.transpose
exponents = powers.map{|i| (0..i).to_a}
divisors = exponents.shift.product(*exponents).map do |powers|
  primes.zip(powers).map{|prime, power| prime ** power}.inject(:*)
end

divisors = divisors.sort.reverse

# print divisors
# print "\n"

@output = 0

# 次に mod を出す
divisors.each do |d|
  mod_array = a_array.map do |a|
    a % d
  end

  cnt = 0
  sort_mod_array = mod_array.sort.reverse
  # print "sort_mod_array\n"
  # print sort_mod_array

  sort_mod_array.each_with_index do |m, idx|
    break if sort_mod_array.inject(:+) == 0
    sort_mod_array[idx] = m - d
    cnt += d - m
    break if cnt > K
  end

  # print "mod_array\n"
  # print sort_mod_array
  # printf "cnt: %d\n", cnt
  

  if cnt > K
    next
  else
    @output = d
    break
  end
end

puts @output

Measured memory_bytes: 10744
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main(){
    string s;
    int k;
    cin>>s>>k;
    int64_t a=0;
    int count=0;
    bool b=false;
    bool bunnki=true;

    for(int i=0;i<s.size()-1;i++){
        if(s.at(i)!=s.at(i+1)){
            bunnki=false;
            break;
        }
    }
    if(bunnki){
        if(s.size()%2==1&&k%2==1){
            a=s.size()*k/2;
        }
        else{
        a=(s.size()*k+1)/2;
        }
        cout<<a<<endl;
    }
else{
    vector<int> vec(s.size()-1);
    for(int i=0;i<s.size()-2;i++){
        if(b){
            break;
        }
        for(int j=count;j<s.size()-1;j++){
            if(s.at(j)==s.at(j+1)){
                vec.at(i)++;
                if(j==s.size()-2){
                    b=true;
                }
            }
              else{
                  count=j+1;
                  break;
               }
        }
    }


        for(int i=0;i<vec.size();i++){
            if(vec.at(i)>0&&vec.at(i)%2==0){
                a+=vec.at(i)/2;
            }
            else if(vec.at(i)>0&&vec.at(i)%2==1){
                a+=(vec.at(i)+1)/2;
            }
        }

        a=a*k;

int first=vec.at(0);
int end=0;

reverse(vec.begin(),vec.end());
for(int i=0;i<vec.size();i++){
    if(vec.at(i)>0){
        end=vec.at(i);
        break;
    }
}
        if(s.at(0)==s.at(s.size()-1)){
            if((first+end)%2==0){
                a+=(k-1);
            }
        }
        cout<<a<<endl;
}
}


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

using namespace std;

int main() {
  vector<int> antennas;
  
  for (int i = 0; i < 5; i++) {
    int _in;
    
    cin >> _in;
    
    antennas.push_back(_in);
  }
  
  int k;
  
  cin >> k;
  
  bool ans = antennas[4] - antennas[0] <= k;
  
  cout << (ans ? "Yay!" : ":(") << endl;
  
  return 0;
}


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


#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    ll n;
    cin >> n;

    map<ll, ll> counter;
    rep(i, n) {
        ll a;
        cin >> a;
        counter[a]++;
    }
    vector<ll> ls(2);
    rep(i, 2) {
        ll mx = 0;
        for (pair<ll, ll> e : counter) {
            if (e.second < 2) {
                continue;
            }
            cmax(mx, e.first);
        }
        if (mx == 0) {
            cout << 0 << endl;
            return 0;
        }
        ls[i] = mx;
        counter[mx] -= 2;
    }

    cout << ls[0] * ls[1] << endl;
}

Measured memory_bytes: 6528
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int a, b, k;
    cin >> a >> b >> k;

    for (int i = min(a, b); i > 0; --i) {
        if(a % i == 0 && b % i == 0) {
            k--;
        }
        if(k == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[225816],x[225816],g[225816];
set<int> st,ans;

int main(void){
	int n,i,l,r,k;
	bool flag = false;
	cin >> n >> k;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<k; ++i){
		st.insert(a[i]);
	}
	for(i=1; i<n; ++i){
		x[i] = x[i-1];
		if(a[i-1] < a[i]){
			++x[i];
		}
	}
	if(x[k-1]-x[0] == k-1){
		g[k-1] = n;
	}else{
		g[k-1] = k-1;
	}
	ans.insert(g[k-1]);
	for(i=k; i<n; ++i){
		st.insert(a[i]);
		l = *(st.begin());
		r = *(--st.end());
		g[i] = i;
		if(x[i]-x[i-k+1] == k-1){
			g[i] = n;
		}else if(a[i-k]==l && a[i]==r){
			g[i] = g[i-1];
		}
		st.erase(a[i-k]);
		ans.insert(g[i]);
	}
	cout << ans.l_ength() << endl;
	return 0;
}


Measured memory_bytes: 12032
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int N;
vector<ll> A,B;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N;
    A.resize(N);
    rep(i,N) cin >> A[i];

    B.resize(N+1);
    rep(i,N) B[i+1] = B[i] + A[i];

    ll ans = 1e18;
    for (int i = 2; i <= N-2; i++) {
        int k = lower_bound(all(B),B[i]/2LL) - B.begin();
        if (2LL*B[k]-B[i] > B[i]-2LL*B[k-1]) k--; 
        int l = lower_bound(all(B),(B[N]-B[i])/2LL+B[i]) - B.begin();
        if (2LL*(B[l]-B[i])-(B[N]-B[i]) > (B[N]-B[i])-2LL*(B[l-1]-B[i])) l--;
        ll val = max({B[N]-B[l],B[l]-B[i],B[i]-B[k],B[k]}) - min({B[N]-B[l],B[l]-B[i],B[i]-B[k],B[k]});
        chmin(ans,val);
    }

    cout << ans << endl;
} 


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

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////


#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;

int v[MAXN];


int main () {

	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i) {
		scanf("%d", &v[i]);
		if (v[i] > v[i - 1])
			--v[i];
	}

	for (int i = 1; i <= n; ++i) {
		if (v[i] < v[i-1]) {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");



	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, int> m;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= i;
        m[A[i]]++;
    }
    ll ans = 0;
    REP(i, N){
        ans += m[-A[i]-(i*2)];
    }
    pr(ans);
}

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

using namespace std;

int main() {
	int n,k,q, p;
	cin >> n >> k >> q;
	vector<int> v(n+1, k-q);
	
	while (q--) {
		scanf("%d", &p);
		v[p]++;
	}

	for (int i=1; i<n+1; i++)
		if (v[i] <= 0)
			cout << "No\n";
		else cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void){
    unsigned long long int a = 0;
    unsigned long long int b = 0;
    unsigned long long int c = 0;
    unsigned long long int d = 0;
    unsigned long long int ans =0;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    ans = b-(a-1);

    unsigned long long int tmp1 = (b/c) - ( (a-1) /c );
    unsigned long long int tmp2 = (b/d) - ( (a-1) /d );

    unsigned long long int lcm = c * d;
    if(c<d){
       unsigned int long long tmp = c;
       c = d;
       d = tmp;
      }
      /* ユークリッドの互除法 */
      unsigned int long long r = c % d;
    while(r!=0){
    c = d;
    d = r;
    r = c % d;
    }
    lcm = lcm / d;


    unsigned long long int tmp3 = (b/lcm) - ( (a-1) /lcm );

    ans += tmp3;
    ans -= tmp1;
    ans -= tmp2;


    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

const int inf=1000000009;

typedef double db;
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

const int N=100000+35;

int sg[N],n;
vector<int>E[N];

void dfs(int x,int fa) {
	int y;
	For (i,0,E[x].size()-1)
		if ((y=E[x][i])!=fa) {
			dfs(y,x);
			sg[x]^=(sg[y]+1);
		}
}

int main() {
	n=rd();
	For (i,2,n) {
		int x=rd(),y=rd();
		E[x].pb(y),E[y].pb(x);
	}
	dfs(1,-1);
	puts(sg[1]?"Alice":"Bob");
	return 0;
}






Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n,k,val;
  int tot=0;
  cin>>n>>k;
  vector<int>reps(202020);
  int groups=0;
  for(int i=0;i<n;i++){
  	cin>>val;
  	if(reps[val]==0){
  		groups++;
  	}
  	reps[val]++;
  }
  sort(reps.begin(),reps.end());
  for(int i=0;i<reps.size();i++){
  	if(groups>k&&reps[i]!=0){
  		tot+=reps[i];
  		groups--;
  	}
  }
  cout<<tot<<endl;
}



Measured memory_bytes: 1024
n = int(input())
As = list(map(int, input().split()))

if As[0] > 0:
    acc0s = [As[0], -1]
    num0s = [0, As[0] + 1]
elif As[0] < 0:
    acc0s = [As[0], 1]
    num0s = [0, -As[0] + 1]
else:
    acc0s = [1, -1]
    num0s = [1, 1]

ans = float('inf')
for acc0, num0 in zip(acc0s, num0s):
    acc = acc0
    num = num0
    for a in As[1:]:
        if acc * (acc + a) < 0:
            acc += a
        else:
            if acc > 0:
                num += a - -(acc + 1)
                acc = -1
            else:
                num += -(acc - 1) - a
                acc = 1

    ans = min(ans, num)

print(ans)


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

using namespace std;

bool bo[100001];
int di[100001];
vector<pair<int, int>> vp[100001];
string ans;

void f(int a, int b) {
	if (bo[a]) {
		if (di[a] != b) {
			ans = "No";
		}
		return;
	}
	bo[a] = true;
	di[a] = b;
	for (auto e : vp[a]) {
		f(e.first, b + e.second);
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, d;
		cin >> l >> r >> d;
		vp[l].push_back(make_pair(r, d));
		vp[r].push_back(make_pair(l, -d));
	}
	ans = "Yes";
	for (int i = 0; i < n; i++) {
		if (!bo[i]) {
			f(i, 0);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    ll cnt = 0;
    ll lr[200010] = {};
    rep(i,0,2*N){
        if(S[i] == 'B'){
            if(cnt % 2 == 0){
                lr[i] = 1;
                cnt = 1;
            }else{
                cnt = 0;
            }
        }else{
            if(cnt % 2 == 1){
                lr[i] = 1;
                cnt = 0;
            }else{
                cnt = 1;
            }
        }
    }
    ll ans = 1;
    rep(i,0,N){
        ans *= (i+1);
        ans %= MOD;
    }
    ll l_cnt = 0;
    rep(i,0,2*N) l_cnt += lr[i];
    if(l_cnt != N){
        print(0);
        return 0;
    }
    ll tt = 0;
    rep(i,0,2*N){
        if(lr[i] == 1){
            tt++;
        }else{
            ans *= tt;
            ans %= MOD;
            tt--;
        }
        if(tt < 0){
            print(0);
            return 0;
        }
    }
    print(ans);
    



    
}

Measured memory_bytes: 2196
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin>>n;
  float a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  float ans=a[0];
  for(int i=1;i<n;i++)
  {
  	ans=(ans+a[i])*1.0/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
k = int(input())

nums = []
def inc(num):
    if num > 3234566667:
        return None
    if num <= 3234566667:
      nums.append(num)

    end = str(num)[-1:]
    end_num = int(end)

    if end_num < 9:
        inc(num * 10 + end_num + 1)

    inc(num * 10 + end_num)

    if end_num > 0:
        inc(num * 10 + end_num - 1)

for i in range(1, 10):
    inc(i)

sort_nums = sorted(nums)
print(sorted(nums)[k - 1])

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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;
}

ll modpow(ll a, ll p) {
    if (p == 0) return 1;
    if (!(p % 2)) {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else {
        return a * modpow(a, p-1) % mod;
    }
}

ll comb(int a, int b) {
    if (b > a - b) return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++) {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod-2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

int main() {
    int N, L; cin >> N >> L;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int pl = -1;
    rep(i, N-1) if (A[i] + A[i+1] >= L) pl = i;
    if (pl == -1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    rep(i, pl) cout << i + 1 << endl;
    for (int i = N - 2; i > pl; --i) cout << i + 1 << endl;
    cout << pl + 1 << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
signed main(){
	int h,w,k;cin >> h >> w >> k;
	int sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
	sx--;sy--;gx--;gy--;
	vector<string> f(h);
	rep(i,h)cin >> f[i];
	vector<vector<int>> dist(h,vector<int>(w,-1));
	queue<P> q;
	dist[sx][sy] = 0;
	q.emplace(sx,sy);
	while(q.size()){
		auto now = q.front();q.pop();
		int x = now.first,y = now.second;
		rep(i,4){
			for(int j = 1;j <= k;j++){
				int nx = x + dx[i]*j,ny = y+dy[i]*j;
				if(nx < 0 || ny < 0 || nx > h-1 || ny > w-1)break;
				if(f[nx][ny] == '@')break;
				if(dist[nx][ny] != -1 && dist[nx][ny] != dist[x][y]+1)break;
				if(dist[nx][ny] != -1)continue;
				dist[nx][ny] = dist[x][y] + 1;
				q.emplace(nx,ny);
			}
		}
	}
	cout << dist[gx][gy] << endl;
	return 0;
}


Measured memory_bytes: 19972
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FUP(i, a, b) for(int i = a; i <= b; i++)
#define FDOWN(i, a, b) for(int i = a; i >= b; i--)
#define MS(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define CIN(a) cin >> a;
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a
#define COUT2(a, b) cout << a << ' ' << b
#define COUT3(a, b, c) cout << a << ' ' << b << ' ' << c
#define ENDL cout << '\n'
int dy[4] = { -1, 1, 0, 0 };
int dx[4] = { 0, 0, 1, -1 };
#define MOD 1000000007

long long int N, arr[200001], sum[200001], ans = 0;

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

	arr[0] = sum[0] = 0;
	CIN(N);
	FUP(i, 1, N)
	{
		CIN(arr[i]);
		sum[i] = sum[i - 1] + arr[i];
		sum[i] %= MOD;
	}
	FDOWN(i, N, 2)
	{
		ans += (arr[i] * sum[i - 1]);
		ans %= MOD;
	}
	COUT(ans);

	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  string ans = "Yes";
  vector<char> x(26, '*'), y(26, '*');
  for(int i = 0; i < s.size(); i++){
    if(x.at(s.at(i) - 'a') == '*'){
      x.at(s.at(i) - 'a') = t.at(i);
    }
    else{
      if(x.at(s.at(i) - 'a') == t.at(i)){
        continue;
      }
      else{
        ans = "No";
        break;
      }
    }
  }
  for(int i = 0; i < t.size(); i++){
    if(y.at(t.at(i) - 'a') == '*'){
      y.at(t.at(i) - 'a') = s.at(i);
    }
    else{
      if(y.at(t.at(i) - 'a') == s.at(i)){
        continue;
      }
      else{
        ans = "No";
        break;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 776
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a_vec: [i32; n]
    }
    let mut break_count = 0;
    let mut countup = 1;
    for i in 0..n {
        if a_vec[i] == countup {
            countup += 1;
        } else {
            break_count += 1;
        }
    }
    println!("{}", if countup == 1 {-1} else {break_count});
}


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

int main() {
    int n,m,k;cin>>n>>m>>k;
    for(int i=0;i<=n;++i){
        for(int j=0;j<=m;++j){
        if(k-m*i - j*(n - 2*i)==0){
//          cout<<i<<" "<<j<<endl;
         cout<<"Yes"<<endl;
         return 0;
        }
        }
    }
    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, a[100000], ta = 0, mu = 0;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			ta++;
		}
		else {
			if (ta % 2 == 0)mu++;
			ta = 0;
		}
	}
	if (ta % 2 == 0)mu++;
	cout << mu << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define forn(i,n) for(int i=0;i<n;i++)
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)



void solve() {
	int n; cin >> n;
	int a[n];
	forn(i, n)cin >> a[i];
	int ans = 0;
	for (int i = 1; i < n; ++i)
	{	if (a[i - 1] > a[i]) {
			ans += (a[i - 1] - a[i]);
			a[i] = a[i] + (a[i - 1] - a[i]);
		}
	}

	cout << ans << endl;
}







int32_t main() {

	fastio;

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

	// int t; cin >> t;
	int t = 1;

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

	return 0;
}



Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
};

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll x;
  cin >> x;

  ll y = (x / 500) * 1000;
  x %= 500;
  y += (x / 5) * 5;

  cout << y << en;

  return 0;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n;
	cin >> n;

	ll prod = 1, ip;
	ll limit = 1000000000000000000;

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

		if (prod == 0 || ip == 0) {
			prod = 0;

		} else if (prod == -1) {

		} else {
			if (ip > ((limit/prod) + 1)) {
				prod = -1;
			} else {
				prod *= ip;

				if (prod > limit)
					prod = -1;
			}
		}
	}

	cout << prod << endl;

	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(a>=b)cout<<"delicious"<<endl;
	else if(b-a<=x)cout<<"safe"<<endl;
	else cout<<"dangerous"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    # import sys
    # readline = sys.stdin.readline
    # readlines = sys.stdin.readlines
    N, Ma, Mb = map(int, input().split())
    med = [tuple(map(int, input().split())) for _ in range(N)]
    INF = float('inf')
    M = 110
    dp = [[INF] * (M + 1) for _ in range(M + 1)]
    dp[0][0] = 0

    for a, b, c in med:
        for i in range(M, a - 1, -1):
            for j in range(M, b - 1, -1):
                here = dp[i - a][j - b]
                dp[i][j] = min(dp[i][j], here + c)

    ans = INF
    ma = Ma; mb = Mb
    while ma < M and mb < M:
        ans = min(ans, dp[ma][mb])
        ma += Ma
        mb += Mb
    
    if ans < INF:
        print(ans)
    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42352