akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int n, wlim;
  cin >> n >> wlim;

  vi w(n), v(n);
  rep(i, 0, n) cin >> w[i] >> v[i];

  vvi dp(n+1, vi(wlim+1));
  rep(i, 0, n){
    rep(j, 0, wlim+1){
      chmax(dp[i+1][j], dp[i][j]);
      if(j+w[i] <= wlim){
        chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
      }
    }
  }

  cout << dp[n][wlim] << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

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

  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int pos = -1;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] + a[i + 1] < L) continue;
    pos = i + 1;
  }

  if (pos < 0) {
    cout << "Impossible\n";
  } else {
    cout << "Possible\n";
    for (int i = 1; i < pos; i++) {
      cout << i << endl;
    }
    for (int i = n - 1; i > pos; i--) {
      cout << i << endl;
    }
    cout << pos << endl;
  }

  return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;
int n, k, cnt;
char c[100000];

int main()
{
    cin >> n >> k>>c[0];
    for(int i = 1; i < n; i++){
        cin >> c[i];
        if(c[i]==c[i-1]){
            cnt++;
        }
    }
    /// 3 -> 5 -> 7 ->9 (k=3 ture)
    cout << min(n-1, cnt+k*2);
    return 0;
}


Measured memory_bytes: 384
from collections import deque
n,m = map(int, input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
que = deque()
que.append(1)
rote = [0]*(n+1)
rote[1] = -1
while que:
    now = que.popleft()
    nx = g[now]
    for next_room in nx:
        if  rote[next_room] == 0:
            rote[next_room] = now
            que.append(next_room)

flag = True
for i in range(2,n+1):
    if rote[i] == 0:
        flag = False
if flag:
    print("Yes")
    for j in range(2,n+1):
        print(rote[j])
    exit()
else:
    print("No")

Measured memory_bytes: 33908
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <climits>


using namespace std;

int main()
{
	int H,W,m=0;
	char a[105][105];
	cin >> H >> W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> a[i][j];
		}
	}
	int n=0;
	while(m < H+1){
		if(m==0){
			for(int j=0;j<W+2;j++){
				cout << '#';
			}
			cout << endl;
		}
		if(n<H){
			cout << '#';
			for(int k=0;k<W;k++){
				cout << a[n][k];
			}cout << '#' << endl;
		}
		m++;
		n++;
		if(m==H+1){
			for(int c=0;c<W+2;c++){
				cout << '#';
			}
			break;
		}
	}
	return 0;
}

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

char s[40], l[20], r[20];

int main() {
    int N;
    scanf("%d", &N);
    scanf("%s", s);
    for (int i = 0; i < N; i++) l[i] = s[i]; 
    for (int i = 0; i < N; i++) r[N-1-i] = s[i+N];

    string srr, srb, slr, slb;
    long long ans = 0;
    map<pair<string, string>, long long> cnt;
    for (int i = 0; i < 1 << N; i++) {
        slr = slb = "";
        for (int j = 0; j < N; j++) {
            if ((i & (1 << j)) == 0 ) slr += l[j];
            else slb += l[j];
        }
        cnt[make_pair(slr, slb)]++;       
    }

    for (int i = 0; i < 1 << N; i++) {
        srr = srb = "";
        for (int j = 0; j < N; j++) {
            if ((i & (1 << j)) == 0 ) srr += r[j];
            else srb += r[j];
        }
        ans += cnt[make_pair(srb, srr)]; 
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 91904
#include <stdio.h>

int main(void) {
    
    int a;
    int b;

    scanf("%d %d", &a, &b);

    if(a >= b) {
        if(a == b) {
            printf("a == b\n");
            return 0;
        }
        printf("a > b\n");
        return 0;
    }
    printf("a < b\n");
    return 0;
}

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

int n, m;
char arr1[110], arr2[110];

int main(){
	int i, j, now, flag = 0;
	scanf("%s %s", arr1, arr2);
	n = strlen(arr1);
	for(i = 0; i < n; i++){
		now = 0;
		for(j = 0; j < n; j++){
			if(arr1[j] == arr2[(i + j) % n]) now++;
		}
		if(now == n) flag = 1;
	}
	if(flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

#define LIM (int)(10e6+1)
bool nprm[LIM];

int main() {
	nprm[0] = nprm[1] = true;
	for (int i = 2; i <= LIM; i++) {
		if (nprm[i] == 0) for (int j = i * 2; j < LIM; j += i) nprm[j] = true;
	}
	while (true) {
		int a, d, n, cnt = 0; cin >> a >> d >> n;
		if (a == 0 && d == 0 && n == 0)break;
		for (int i = a; i < LIM; i += d)	{
			if (nprm[i] == 0)cnt++;
			if (cnt == n) {
				cout << i << endl;
				break;
			}
		}
	}
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 1 && a <= 100 && b >= 1 && b <= 100) {
		cout << a*b << " " << 2 * a + 2 * b << endl;
	}
	else {
		cout << "error" << endl;
	}
}


Measured memory_bytes: 3096
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
using namespace std;
int changecolour(char *c, int N, int pos, int colour){
	char *d = (char *)malloc(sizeof(char) * N);
	for(int i = 0; i < N; i++)
		d[i] = c [i];
	d[pos] = colour;

	bool changed = true;
	while(changed){
		int last = 0, cnt = 1;
		changed = false;
		for(int i = 0; i <= N; i++){
			if(last == (i != N ? d[i] : 0)){
				cnt++;
			}else{
				if(cnt > 3){
					for(int j = i - cnt; j < N - cnt; j++){
						d[j] = d[j + cnt];
					}
					N -= cnt;
					changed = true;
					break;
				}
				last = d[i];
				cnt = 1;
			}
		}
	}
	free(d);
	return N;
}
inline char shouldchange(int x, char *c, int N){
	// There are following patterns which should  be changed:
	/* x??? */ if((N - x - 1) >= 3) if(c[x + 1] == c[x + 2] && c[x + 1] == c[x + 3]) return c[x + 1];
	/* ?x?? */ if((N - x - 1) >= 2 && (x >= 1)) if(c[x - 1] == c[x + 1] && c[x - 1] == c[x + 2]) return c[x - 1];
	/* ??x? */ if((N - x - 1) >= 1 && (x >= 2)) if(c[x - 2] == c[x - 1] && c[x - 2] == c[x + 1]) return c[x - 2];
	/* ???x */ if(x >= 3) if(c[x - 3] == c[x - 2] && c[x - 3] == c[x - 1]) return c[x - 3];
	return 0;
	
}
int main()
{
	int N;
	while(scanf("%d\n", &N), N){
		int M = N;
		char c[10000];
		for(int i = 0; i < N; i++)
			scanf("%hhd\n", &c[i]);
		if(N > 3){
			for(int i = 0, colour = 0; i < N; i++)
				if((colour = shouldchange(i, c, N)) != 0)
					M = min(M, changecolour(c, N, i, colour));

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

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

int main(void) {
  string S;
  cin >> S;
  
  if(S=="SUN") cout << 7 << endl;
  else if(S=="MON") cout << 6 << endl;
  else if(S=="TUE") cout << 5 << endl;
  else if(S=="WED") cout << 4 << endl;
  else if(S=="THU") cout << 3 << endl;
  else if(S=="FRI") cout << 2 << endl;
  else cout << 1 << endl;
  
  return 0;
}

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

typedef long long ll;

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

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

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

    ll ans = 1;
    ll t;
    
    for(int i = 0; i < n; i++){
        cin >> t;
        ans = lcm(ans,t);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
 
#define INF 1e18
#define MAX 200005

using mint = modint998244353;

vector<mint> ones, tens;
void init(int n) {
  ones.assign(n+1,0);
  tens.assign(n+1,0);
  mint tmp1 = 0, tmp2 = 1;
  rep(i,n+1) {
    ones[i] = tmp1;
    tens[i] = tmp2;
    tmp1 = tmp1*10+1;
    tmp2 *= 10;
  }
}

struct S {
  mint num;
  int size;
};

S op(S a, S b) {
  return S{a.num*tens[b.size]+b.num, a.size+b.size};
}
S e() {
  return S{0,0};
}
struct F {
  mint num;
  bool use;
};
S mapping(F f, S s) {
  if (!f.use) return s;
  return S{f.num*ones[s.size],s.size};
}
F composition(F f, F g) { return f.use?f:g; }
F id() { return F{0,false}; }

int main() {
  int n, q;
  cin >> n >> q;
  init(n);
  vector<mint> ans;
  lazy_segtree<S,op,e,F,mapping,composition,id> seg(vector<S>(n,S{1,1}));
  rep(i,q) {
    int l, r, d;
    cin >> l >> r >> d;
    seg.apply(l-1,r,F{d,true});
    ans.push_back(seg.all_prod().num);
  }
  for (auto a : ans) cout << a.val() << endl;

  return 0;
}

Measured memory_bytes: 12684
#include<iostream>
#include<cstdio>
using namespace std;
inline char gc()
{
	static const int SIZE=1<<23;
	static char buf[SIZE],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;
}
//#define getchar gc
template<typename T>
inline T read(T &x)
{
	x=0;
	char ch;
	bool flag=false;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar())
		if(ch=='-') flag=true;
	while(ch>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	if(flag) x=-x;
	return x;
}
template<typename T>
inline void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
	return;
}
template<typename T>
inline void writeln(T x)
{
	write(x);
	putchar('\n');
	return;
}
const int N=200005;
int n;
int a[N];
bool isbig(int pos,int k)
{
	return a[pos]>k;
}
bool small(int i,int j,int k)
{
	return a[i]<=k&&a[j]<=k;
}
bool big(int i,int j,int k)
{
	return a[i]>k&&a[j]>k;
} 
int check(int k)
{
	for(int i=0;i<n-1;i++)
	{
		if((isbig(n+i,k)&&isbig(n+i+1,k))) return false;
		if((isbig(n-i,k)&&isbig(n-i-1,k))) return false;
		if(small(n+i,n+i+1,k) || small(n-i,n-i-1,k)) return 1;
	}
	return small(1,1,k);
}
int main()
{
	read(n);
	for(int i=1;i<=2*n-1;i++)
		read(a[i]);
	int l=1,r=2*n-1,ans;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	write(ans);
	return 0; 
}

Measured memory_bytes: 1024
import Control.Monad
import Data.List

main::IO()
main=do
  (n:t:[])<-(return.(map read).words)=<<getLine
  dat<-forM [1..n] (\_->(return.(\(x:y:_)->(x,y)).(map read).words)=<<getLine)
  putStr (solver dat t)

solver::[(Int,Int)]->Int->String
solver d t = case ((sortBy (\ (c1,_) -> \ (c2,_) -> compare c1 c2)).(filter (\(_,t_)->t_<=t))) d of
              []         -> "TLE\n"
              (cost,_):_ -> (show cost)++"\n"

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

long long GCD(long long a, long long b){
	if(b==0) return a;
  else return GCD(b, a%b);
}


int main (){
  bool flg=0;
  int n,m;
  cin >> n >> m;
  int a[100010];
  int b[100010];
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]%2!=0) flg=1;
    b[i]=a[i]/2;
  }
  
  long count=0, c;
  for(int i=0; i<n; i++){
    while(a[i]%2==0){
    	a[i]/=2;
      count++;
    }
  if(i){
    if(c!=count) flg=1;
  }
    c=count;
    count=0;
  }
  long d=1;
  if(flg) cout << 0 << endl;
  else{
    for(int i=0; i<n; i++){
      d=b[i]*d/GCD(b[i],d);
    }
  cout << (m/d+1)/2 << endl;
  }
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> data(5);
    int ANS;
    int flg = 0;

    for (int i = 0; i < data.size(); i++) {
        cin >> data.at(i);
    }

    //基準値
    cin >> ANS;


    //判定
    for (int i = 0; i < data.size(); i++) {
        if (i < data.size() - 1) {
            for (int j = i + 1; j < data.size(); j++) {
                if (data.at(j) - data.at(i) > ANS) {
                    flg  = 1;
                }
            }
        }
        if (flg == 1) {
            break;
        }
    }

    if (flg == 0) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] and s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define debug(s) cout << #s << " = " << s << endl
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define endl '\n'
#define mod 1000000007

int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	int n;
	cin >> n;
	float a,t;
	cin >> t >> a;
	int pos = -1;
	float diff = -1;
	forn(i,n){
		float h;
		cin >> h;
		float here = t-h*(0.006);
		if(pos==-1 || abs(here-a)<diff){
			diff = abs(here-a);
			pos = i+1;
		}
	}
	cout << pos << endl;
	return 0;
}

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

using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    int ans=1e5;
    for(int n=0; n<N; n++) {
        int c, t;
        cin >> c >> t;
        
        if(t<=T) {
            ans = min(ans, c);
        }
    }
    
    if(ans==1e5) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }


    return 0;
    
}

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

int main(void)
{

  int i,j;
  int fmoney,lmoney;
  int r;
  int year;
  int b,cost;
  double per;
  int m,n;
  int *a;

  scanf("%d",&m);
  while(1)
    {
      if(m==0)break;
      scanf("%d",&fmoney);
      scanf("%d",&year);
      scanf("%d",&n);
      a=(int *)malloc(sizeof(int)*n);

      for(i=0;i<n;i++)
	{
	  scanf("%d %lf %d",&b,&per,&cost);
	  lmoney = fmoney;
           r=0;
	  if(b==0)
	    {
	      for(j=0;j<year;j++)
		{
		  r += (int)(lmoney*per);
		  lmoney-=cost;
		}
	      a[i] = lmoney + r;
	    }

	  if(b==1)
	    {
	      for(j=0;j<year;j++)
		{
		  r = (int)(lmoney*per);
                  lmoney = lmoney +r - cost;
		}
	      a[i] = lmoney;
	    }
	}
      for(i=1;i<n;i++)
	{
	  if(a[0]<a[i]){a[0]=a[i];}
	}
      printf("%d\n",a[0]);
      m--;
    }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int n; cin >> n;
    string a,b;
    for(int i = 0;i < n;i++){
        char e; cin >> e; a+=e;
    }
    for(int i = 0;i < n;i++){
        char e; cin >> e; b+=e;
    }
    string s = a; sort(s.begin(),s.end());
    vector<string> v;
    
    int x = 0,y = 0;
    do{
        v.push_back(s);
    }while(next_permutation(s.begin(),s.end()));
    sort(v.begin(),v.end());
    for(int i = 0;i < v.size();i++){
        if(v[i] == a) x = i;
        if(v[i] == b) y = i;
    }
    cout << abs(x-y);
}


Measured memory_bytes: 5252
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<string>
#include<climits>
#include<deque>

using namespace std;

int m,INF=30000000;
stack<int,vector<int> >A,B,C;

int func(string p){
  
  int cnt=0;

  for(int i=0;i<m;i++){
    
    if(B.empty() && (C.empty()||A.empty()))return cnt;
    
    if(!A.empty() && (B.empty() || A.top()>=B.top()) && p!="BA"){
      B.push(A.top());
      A.pop();
      cnt++,p="AB";
    }
    
    if(!B.empty() && (C.empty() || B.top()>=C.top()) && p!="CB"){
      C.push(B.top());
      B.pop();
      cnt++,p="BC";
    }
    
    if(!B.empty() && (A.empty() || B.top()>=A.top()) && p!="AB"){
      A.push(B.top());
      B.pop();
      cnt++,p="BA";
    }
    
    if(!C.empty() && (B.empty() || C.top()>=B.top()) && p!="BC"){
      B.push(C.top());
      C.pop();
      cnt++,p="CB";
    }
    
  }

  return INF;
}

int main(void){
  int n,ans,s,t;
  
  while(cin >> n >> m,n|m){

    stack<int,vector<int> >Ain,Bin,Cin;

    cin >> s;
    for(int i=0;i<s;i++){
      cin >> t;
      Ain.push(t);
    }
    cin >> s;
    for(int i=0;i<s;i++){
      cin >> t;
      Bin.push(t);
    }
    cin >> s;
    for(int i=0;i<s;i++){
      cin >> t;
      Cin.push(t);
    }
    
    A=Ain,B=Bin,C=Cin;
    ans=func("CB");
    
    A=Ain,B=Bin,C=Cin;
    ans=min(ans,func("AB"));
    
    A=Ain,B=Bin,C=Cin;
    ans=min(ans,func("BA"));
    
    A=Ain,B=Bin,C=Cin;
    ans=min(ans,func("BC"));
    
    if(ans==INF)cout << -1 << endl;
    else cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    ll maxW;
    cin >> maxW;
    vector<ll> w, v;
    for (int i = 0; i < N; ++i) {
        ll tw, tv;
        cin >> tw >> tv;
        w.push_back(tw);
        v.push_back(tv);
    }
    vector<vector<ll>> dp(N, vector<ll>(maxW+1));
    for (int j = 0; j <= maxW; ++j) {
        dp[0][j] = j >= w[0] ? v[0] : 0;
    }
    for (int i = 1; i < N; ++i) {
        for (int j = 1; j <= maxW; ++j) {
            dp[i][j] = dp[i-1][j];
            if(w[i] <= j){
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp.back().back() << endl;
}

int main(int argc, char *argv[]) {
    string FileName("EDPC"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int X = 100000;
int my[X]={};

int main()
{
    int w,h,n;
    cin >>w >>h >>n;
    rep(i,n)
    {
        int x,y;
        cin >>x >>y;

        my[x] = max(my[x],y);
    }

    int yy = 0;
    int ans = w-1;
    for(int i=w-1; i>0; --i)
    {
        yy = max(yy,my[i]);
        ans = min(ans, i-1+yy);
    }

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

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

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(100005);

mint f(int n, int k) {
  if (n < 0) return 0;
  // nPk = nCk * k!
  mint res = comb(n,k);
  res *= comb.fact[k];
  return res;
}

int k;
mint ans;
vector<int> to[100005];
void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u,v);
  }
  int nk = (p==-1) ? k : k-2;
  int c = (p==-1) ? to[v].size()+1 : to[v].size()-1;
  ans *= f(nk,c);
}

int main() {
  int n;
  cin >> n >> k;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = 1;
  dfs(0);
  cout<<ans.x<<endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    int P = 0, W = 0, G = 0, Y = 0;
    rep(i, N) {
        string S;
        cin >> S;
        if (S == "P") P++;
        else if (S == "W") W++;
        else if (S == "G") G++;
        else Y++;
    }
    if (P == 0 || W == 0 || G == 0 || Y == 0) cout << "Three" << endl;
    else cout << "Four" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    long long a, b, c, x;
    scanf("%lld %lld %lld", &a, &b, &c);
    x = (c - a - b);
    if(x <= 0){
        printf("No\n");
        return 0;
    }
    if(a * b < x * x / 4){
        printf("Yes\n");
    }
    else if(a * b == x * x / 4 && x % 2 == 1){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }


    return 0;
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,int> check;
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    if(check.count(a.at(i)))
    {
      cout<<"NO"<<endl;
      exit(0);
    }
    else
    {
      check[a.at(i)]=1;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 10368
# -*- coding: utf-8 -*-
N = int(input())
S = input()

import collections
n_frq_dict = collections.defaultdict(int)
for s in S:
    n_frq_dict[s] += 1

mod=10**9+7
ret = 1
for frq in n_frq_dict.values():
    ret *= frq + 1
    ret %= mod
    
print(ret - 1)










Measured memory_bytes: 39408
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SP << " " <<
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>


int main(){
  long long int a_i, b_i, x_i;
  scanf("%lld%lld%lld", &a_i, &b_i, &x_i);
  
  double a, b, x, V, l, theta;
  a = a_i * 1.0;
  b = b_i * 1.0;
  x = x_i * 1.0;
  V = a*a*b;
  
  if(x >= 0.5*V){
    l = 2.0 * (V - x)/(a*a);
    theta = std::atan(l/a) * (180.0/M_PI);
  }
  else{
    l = 2.0*x/(a*b);
    theta = atan(b/l) * (180.0/M_PI);
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << std::setprecision(12) << theta << std::endl;
  
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,a,b;
  cin>>n>>a>>b;
  if(b<a){
    cout<<0<<'\n';
  }
  else if(n<abs(a-b)){
    cout<<0<<'\n';
  }
  else{
    ll min=a*(n-1)+b;
    ll max=b*(n-1)+a;
    cout<<max-min+1<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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



int main(){
  int H ,W;
  int h, w;
  cin >> H >> W >> h >> w;
  cout << (H-h)*(W-w) << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
i = 0
tmp = 0
tmpura = 0
while(i < n):
    tmp += a[i]
    i+=1
tmp=tmp **2
i = 0
while (i < n):
    tmpura += a[i]**2
    i+=1
tmpura=tmpura
ans = ((tmp - tmpura)//2)%(10**9+7)
print(ans)

Measured memory_bytes: 31596
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;

int main(){
  int N,K;
  cin>>N>>K;
  if(!(0<=K && K<=(N-2)*(N-1)/2)){
    cout<<-1<<endl;
    return 0;
  }
  
  
  vector<P>ans;
  //ウニの構築
  for(int i=2;i<=N;i++){
    ans.push_back(P(1,i));
  }
  //ちょうどK個になるよう減らす
  vector<P>ve;
  for(int i=2;i<=N;i++){
    for(int j=i+1;j<=N;j++){
      ve.push_back(P(i,j));
    }
  }
  for(int i=0;i<(N-2)*(N-1)/2-K;i++){
    ans.push_back(ve[i]);
  }
  
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].first<<" "<<ans[i].second<<endl;
  } 
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}

//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	llint ans=0, n=0,m,count,sum=0,ch=0;
	llint s;
	bool check = false;
	vector<llint> a;
	vector<llint> r,b;
	char c,d,e;
	cin >>n;
	rop(i, n) {
		rop(j, n) {
			rop(k, n) {
				ans += GCD(GCD(i, j), k);
			}
		}
	}
	cout << ans << endl;
	please AC;
}


Measured memory_bytes: 3700
#include <iostream>
#define INF 1e+9
using namespace std;

int main(){
	int n,p[5000],mi = INF;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> p[i];
	for(int i = 0;i <= p[0];i++){
		int cnt = i,tmp[5000];
		for(int k = 0;k < n;k++) tmp[k] = p[k];
		tmp[0] -= i;
		for(int k = 0;k < n - 1;k++){
			int d = max(0,tmp[k]);
			cnt += 2 * d;
			tmp[k] -= d;
			tmp[k + 1] -= d;
		}
		cnt += max(0,tmp[n - 1]);
		mi = min(cnt,mi);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
    cin >> N;
	int k=0;
	vector<int> vec(N);
	for(int i=0; i< N; i++){
		cin >> vec.at(i);
	}
	sort(vec.begin(),vec.end());
	vector<int> sa(N-1);
	for(int i=0;i<N-1;i++){
		sa.at(i)=vec.at(i)-vec.at(i+1);
	}
	for (int j = 0; j < N-1; ++j)
	{
		if(sa.at(j)==0){
			k++;
			break;
		}
	}
  
	if(k==0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

	
	
	

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll rec(ll v){
  if(v==1) return 1;
  else return rec(v/2)*2+1;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h; cin>>h;
  cout<<rec(h)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100001]={};
  int sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i==0) sum+=abs(a[i]);
    else sum+=abs(a[i]-a[i-1]);
  }
  sum+=abs(a[n-1]);
  for(int i=0;i<n;i++){
    if(i==0){
      if((0<a[i]&&a[i]<a[i+1])||(0>a[i]&&a[i]>a[i+1])){
        cout<<sum<<endl;
      }else{
        cout<<sum-(abs(a[i])+abs(a[i+1]-a[i]))+abs(a[i+1])<<endl;
      }
    }else{
      if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i]-1>a[i]&&a[i]>a[i+1])){
        cout<<sum<<endl;
      }else{
        cout<<sum-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1])<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;

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

    int n;
    cin >> n;
    string s[55];
    for( int i = 0; i < n; ++i ) cin >> s[i];

    vector< int > res;
    int tmp[n];
    for( int i = 0; i < s[0].size(); ++i ) {
        char comp = s[0][i];

        bool flg = true;
        for( int j = 1; j < n; ++j ) {
            int pos = s[j].find( comp );
            if( pos == -1 ) {
                flg = false;
                tmp[j] = -1;
            } else tmp[j] = pos;
        }

        if( flg ) {
            for( int j = 1; j < n; ++j ) {
                if( tmp[j] != -1 ) s[j][tmp[j]] = '-';

            }
            res.pb( comp );
        }
    }

    sort( res.begin(), res.end() );
    for( int i = 0; i < res.size(); ++i ) cout << (char)res[i];
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using Number = System.Int32;

namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			var s = rs;
			Console.WriteLine(new string('x', s.Length));
		}
		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = true });
		var solver = new Program.Solver();
		//* 
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		t.Start();
		t.Join();
		//*/
		// solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion


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

int main() { int a; int b; cin >> a >> b;
int i;
i = b - a - 1;
int ans = -1 * a;
for(int t = 1; t < i + 1; t++){
  ans += t;
}

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

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

int main() {
    int N; cin >> N;
    int mn = 1, mnv = 1e9 + 10;
    rep(i, 0, N) {
        int a, b;
        cin >> a >> b;
        if(mnv > b) {
            mnv = b;
            mn = a;
        }
    }
    cout << mn + mnv << endl;
    return 0;
}


Measured memory_bytes: 256
read K
printf %d\\n {1{,0{{0..8}999999999999,99{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9}}}}}}}}}}}},{1..8}99{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9}}}}}}}}}}}},2{,{0..8}999{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9}}}}}}}}}}},3{,{0..8}9999{,9{,9{,9{,9{,9{,9{,9{,9{,9}}}}}}}}}},4{,{0..8}99999{,9{,9{,9{,9{,9{,9{,9{,9}}}}}}}}},5{,{0..8}999999{,9{,9{,9{,9{,9{,9{,9}}}}}}}},6{,{0..8}9999999{,9{,9{,9{,9{,9{,9}}}}}}},7{,{0..8}99999999{,9{,9{,9{,9{,9}}}}}},8{,{0..8}999999999{,9{,9{,9{,9}}}}},9{,{0..8}9999999999{,9{,9{,9}}}},{1..9}9{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9{,9}}}}}}}}}}}}}} | sort -n | head -$K


Measured memory_bytes: 860
s = list(input())
f = 1 
h = {-1:"First", 1:"Second"}
r = True
while r:
        p = 0 
        r = False 
        for i in s:
                if p+2 < len(s):
                        if s[p] != s[p+2]:
                                del s[p+1]
                                r = True
                                f = -f
                        else:
                                p += 1
print(h[f])

Measured memory_bytes: 4084
from collections import defaultdict
x=int(input())
s=set()
d=defaultdict(int)
for i in range(1,x+1):
    p=str(i)
    k=p[0]+p[len(p)-1]
    d[k]+=1
    s.add(k)
a=0    
for i in s:
    c=i[::-1]
    a+=d[i]*d[c]
    
print(a)    

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N, K;
    cin >> N >> K;
    vector<int> length(N);
    for (int i = 0; i < N; i++) cin >> length.at(i);
    sort(length.begin(), length.end());
    reverse(length.begin(), length.end());
    int max = 0;
    for (int i = 0; i < K; i++) {
        max += length.at(i);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
H, W, N = map(int, input().split())
S = {}
for i in range(N):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  for i in range(max(0, a-1), min(H, a+2)):
    for j in range(max(0, b-1), min(W, b+2)):
      if (i, j) not in S: S[(i, j)] = 0
      S[(i, j)] += 1
rs = [0]*10
rs[0] = (H-2)*(W-2)
for (i, j) in S:
  if i > 0 and j > 0 and i < H-1 and j < W-1:
    n = S[(i, j)]
    #print(i, j, n)
    rs[0] -= 1
    rs[n] += 1
for j in range(0, 9+1):
  r = rs[j]
  print(r)


Measured memory_bytes: 151680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int a[10] = { 111,222,333,444,555,666,777,888,999 };
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int n; sf(n);
	vector<int> tmp;
	f(i, 0, 8)tmp.push_back(a[i]);
	sort(all(tmp));
	cout << *lower_bound(all(tmp), n);
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        h: usize,
        m: usize,
        hh: usize,
        mm: usize,
        k: usize,
    }

    let start_min = h * 60 + m;
    let end_min = hh * 60 + mm;


    println!("{}", end_min - start_min - k);
}


Measured memory_bytes: 2120
#include <stdio.h>
#define SENTINEL 1000000000
#define N 500000
int array[N], count = 0;

void Marge(int left, int mid, int right){
  int n1, n2, i, j;
  n1 = mid - left;
  n2 = right - mid;

  int L[n1+1], R[n2+1];
  for(i = 0; i < n1; i++){
    L[i] = array[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = array[mid + i];
  }
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;

  int k;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      count++;
      array[k] = L[i];
      i++;
    }else{
      array[k] = R[j];
      j++;
      count++;
    }
  }
}

void MargeSort(int left, int right){
  int mid;
  if((left + 1) < right){
    mid = (left + right) / 2;
    MargeSort(left, mid);
    MargeSort(mid, right);
    Marge(left, mid, right);
  }
}

main(){
  int i, n;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &array[i]);
  }
  MargeSort(0, n);
  
  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    printf("%d", array[i]);
  }
    printf("\n");
    printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 4504
n = int(input())
a = list(map(int, input().split()))
cnt = [0 for _ in range(max(a))]
for i in range(n):
  cnt[a[i]-1] += 1
ans = 0
d = 0
for i in range(len(cnt)):
  if cnt[i] > 0:
    ans += 1
    if cnt[i] % 2 == 0:
      d += 1
print(ans - d%2)

Measured memory_bytes: 14388
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

struct edge{
  int to, cost;
};
using namespace std;
const int INF=2e9;

int main(){
  int V, E, r;
  cin >> V >> E >> r;
  vector< vector<edge> > G(V);
  rep(i,E){
    int s, t, d;
    cin >> s >> t >> d;
    edge e;
    e.to=t, e.cost=d;
    G[s].push_back(e);
  }
  vector<int> dist(V);
  rep(i,V) dist[i]=INF;
  dist[r]=0;
  priority_queue< int, vector<int>, greater<int> > q;
  q.push(r);
  while(!q.empty()){
    int n=q.top(); q.pop();
    rep(i,G[n].size()){
      int next=G[n][i].to;
      int new_dist=dist[n]+G[n][i].cost;
      if(dist[next]<=new_dist) continue;
      q.push(next);
      dist[next]=new_dist;
    }
  }
  rep(i,V){
    if(dist[i]==INF) cout << "INF" << endl;
    else cout << dist[i] << endl;
  }

  return 0;
}



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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    int H, A;
    cin >> H >> A;
    PRINT(UP(H,A));
}


Measured memory_bytes: 256
n = int(input().split()[0])
c = list(filter(lambda x:x <= n,map(int,input().split())))
m = len(c)

minimum = [ i for i in range(n+1) ]
for i in c:
    minimum[i] = 1

for i in range(1,n+1):
    if minimum[i] <= 2:
        continue
    for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1

print(minimum[n])

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

using namespace std;

int main(){
  int n;
  cin>>n;
  
  int data,cnt=0;
  for(int i=0; i<n; i++){
    	cin>>data;
		if((i+1)%2 != 0 and data%2 !=0){
				cnt++;
        }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

int main()
{

  string S;
  cin >> S;

  int oddW = 0;
  int oddB = 0;
  int evenW = 0;
  int evenB = 0;

  rep(i, S.size())
  {
    if (i % 2 == 0)
    {
      if (S[i] == '1')
        evenW++;
      else if (S[i] == '0')
        evenB++;
    }
    else if (i % 2 == 1)
    {
      if (S[i] == '1')
        oddW++;
      else if (S[i] == '0')
        oddB++;
    }
  }

  int p1 = oddW + evenB;
  int p2 = oddB + evenW;
  if (p1 > p2)
    cout << p2 << endl;
  else
    cout << p1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

set<ll> enumDiv(ll n)
{
    set<ll> v;
    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            v.insert(i);
        while (n % i == 0)
            n /= i;
    }
    if (n > 1)
        v.insert(n);

    return v;
}

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

    ll a, b;
    cin >> a >> b;

    set<ll> ap = enumDiv(a);
    set<ll> bp = enumDiv(b);

    int res = 1;

    for (ll i : ap)
        res += bp.count(i);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256