akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}
bool check(int diff, int time) {
  if (diff < 0) return true;
  return rand() >= diff * (clock()-time)*1.4;
}
int main() {
  int n;
  cin >> n;
  vector<int> c(26), last(26, -1);
  vector<array<int, 26>> s(n);
  
  for (int i = 0; i < 26; ++i) cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1), max_score(-1e9);
    for (int j = 0; j < 26; ++j) neg -= c[j] * (i - last[j]);
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  // stochastic
  time_t time = clock();
  while ((clock()-time)<=1.98*CLOCKS_PER_SEC) {
    int dd = rand() % n;
    int tt = rand() % 26;
    int ot = options[dd];
    while (ot == tt) tt = rand() % 26;
    long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                        options, dd, tt, ot);
    if (!check(-ns,time)) {
      options[dd] = ot;
    } else {
      total += ns;
    }
  }
  for (const int& i: options) cout << i + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3692
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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


using Graph = vector<vector<int>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> fib(100);
    for (int i = 0; i < 100; i++) {
        
        if(i<=1) fib[i] = 1;
        else{
            fib[i] = fib[i-1] + fib[i-2];
        }
    }
    cout << fib[n] << endl;
}



signed main() {
    solve();
    return 0;
}




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

int main(){
  int N,SUM=0;
  cin >> N;
  vector<int> W(N),D(N,0);
  for(int i=0; i<N; i++){
    cin >> W.at(i);
    SUM+=W.at(i);
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<i+1; j++){
      D.at(i)+=W.at(j);
    }
    D.at(i)=max(SUM-2*D.at(i),(-1)*(SUM-2*D.at(i)));
  }
  sort(D.begin(),D.end());
  cout << D.at(0) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	string vowel = "aeiou";
	char c;
	cin >> c;
	for (int i = 0; i < vowel.size(); i++) {
		if (c == vowel[i]) {
			cout << "vowel" << endl;
			return 0;
		}
	}
	cout << "consonant" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

int n;

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

int main() {
	cin >> n;
	dfs("", 'a'-1);
	return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long min = Long.MAX_VALUE;
		long N = sc.nextLong();
		int max = (int) Math.sqrt(N);
		for (int i=1;i<=max;i++) {
			if (N%i==0) {
				long x = i;
				long y = N/i;
				long temp = x+y;
				if (temp-2<min) {
					min = temp-2;
				}
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 23892
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int main(void){
	llint x,y,ans=1;cin>>x>>y;
	while(x*2<=y){x*=2;ans++;}
	cout<<ans<<endl;
	RE;
}

Measured memory_bytes: 888
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
using namespace std;
  
  
const double EPS = 1e-9;
  
int main(){
 
	int p, q;
	while(cin >> p >> q){
		vector<int> rest;
		vector<int>::iterator l;
		bool loop = false;
		for(int i = 0; p != 0; i++){
			if((l = find(rest.begin(), rest.end(), p)) != rest.end()){
				loop = true;
				break;
			}
			rest.push_back(p);
			p*=10;
			cout << p/q;
			p%=q;
		}
		cout << endl;
		if(loop){
			vector<int>::iterator it;
			for(it = rest.begin(); it != rest.end(); it++){
				cout << ((it>=l)?'^':' ');
			}
			cout << endl;
		}
	}
  
    return 0;
}

Measured memory_bytes: 1220
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> table(h);
    for (int i = 0; i < h; i++)
    {
        cin >> table[i];
    }

    vector<vector<uint64_t>> dp(h, vector<uint64_t>(w, 0));
    dp[0][0] = 1;

    for (int i = 1; i < w; i++)
    {
        if (table[0][i] == '.')
        {
            dp[0][i] = dp[0][i - 1];
        }
    }

    for (int i = 1; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (table[i][j] == '.')
            {
                dp[i][j] = dp[i - 1][j];
                if (j > 0)
                {
                    dp[i][j] += dp[i][j - 1];
                }
                dp[i][j] %= 1000000007;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 9216
def dfs(nums, length, min_lim):
    ans = 0
    if length == n:
        score = 0
        for a, b, c, d in req:
            if nums[b] - nums[a] == c:
                score += d
        return score
    else:
        for next_num in range(min_lim, m + 1):
            nums[length + 1] = next_num
            s = dfs(nums, length + 1, next_num)
            ans = max(ans, s)
    return ans


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

# 添字がわかりづらくなるので、n+1個のリストを用意します
nums = [0] * (n + 1)

ans = dfs(nums, 0, 1)
print(ans)


Measured memory_bytes: 76916
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, a[500]; double x[500];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < n; i++) {
		x[i] = a[i] * 2.0;
		for(int j = 0; j < i; j++) x[i] = max(x[i], x[j] - a[j] + a[i] + sqrt(pow(a[i] + a[j], 2) - pow(a[i] - a[j], 2)));
	}
	printf("%.9f\n", *max_element(x, x + n));
	return 0;
}

Measured memory_bytes: 2744
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second




int main() {
	ll n, a[200010], ans = 0;
	bool b[200010] = { 0 };
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	if (a[0]) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = n - 1;i > 0;i--) {
		if (a[i] - a[i - 1] > 1) {
			cout << -1 << endl;
			return 0;
		}
		else if (a[i] - a[i - 1] == 1) {
			ans++;
		}
		else {
			ans += a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{

   int a,b;
   while(cin>>a>>b)
   {
       long long sum=0;
       sum=a*b;
       if(sum%2==0)
       {
           cout<<"Even"<<endl;
       }
       else
       {
           cout<<"Odd"<<endl;
       }
   }

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
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 long long INF = 1LL << 60;


int main() {
    int N;
    long long dp[100010][3];
    cin >> N ;
    int a[N], b[N], c[N];
    
    for (int i = 0; i < N; i++)
	cin >> a[i] >> b[i] >> c[i];

    // 初期条件
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;

    // ループ
    for (int i = 0; i < N; i++) {
	dp[i+1][0] = a[i] + max(dp[i][1], dp[i][2]);
	dp[i+1][1] = b[i] + max(dp[i][2], dp[i][0]);
	dp[i+1][2] = c[i] + max(dp[i][0], dp[i][1]);
    }

    // 答え
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}


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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int n;
int X[200000],Y[200000];
char D[200000];
vector<P>xs[300000],ys[300000];
vector<P>V[1000000];

int calc(){
	rep(i,1000000){
		V[i].clear();
	}
	rep(i,n){
		//~ cout<<X[i]+Y[i]<<endl;
		if(D[i]=='R'){
			V[X[i]+Y[i]+500000].push_back(P(X[i]*100,1));
		}
		if(D[i]=='U'){
			V[X[i]+Y[i]+500000].push_back(P(X[i]*100,-1));
		}
	}
	int Min=INT_MAX;
	rep(i,1000000){
		if(V[i].empty())continue;
		sort(V[i].begin(),V[i].end());
		rep(j,V[i].size()-1){
			if(V[i][j].second==1&&V[i][j+1].second==-1){
				Min=min(Min,(V[i][j+1].first-V[i][j].first));
			}
		}
	}
	return Min;
}

int main(){
	cin>>n;
	rep(i,n){
		int x,y;
		char u[2];
		scanf("%d%d%s",&x,&y,u);
		X[i]=x;Y[i]=y;D[i]=u[0];
		char dir=u[0];
		if(dir=='U'){
			xs[x].push_back(P(y*100,1));
		}
		else if(dir=='D'){
			xs[x].push_back(P(y*100,-1));
		}
		else if(dir=='R'){
			ys[y].push_back(P(x*100,1));
		}
		else{
			ys[y].push_back(P(x*100,-1));
		}
	}
	int Min=INT_MAX;
	rep(i,300000){
		if(xs[i].empty())continue;
		sort(xs[i].begin(),xs[i].end());
		rep(j,xs[i].size()-1){
			if(xs[i][j].second==1&&xs[i][j+1].second==-1){
				Min=min(Min,(xs[i][j+1].first-xs[i][j].first)/2);
			}
		}
	}
	rep(i,300000){
		if(ys[i].empty())continue;
		sort(ys[i].begin(),ys[i].end());
		rep(j,ys[i].size()-1){
			if(ys[i][j].second==1&&ys[i][j+1].second==-1){
				Min=min(Min,(ys[i][j+1].first-ys[i][j].first)/2);
			}
		}
	}
	rep(loop,4){
		Min=min(Min,calc());
		rep(i,n){
			if(D[i]=='U')D[i]='L';
			else if(D[i]=='R')D[i]='U';
			else if(D[i]=='D')D[i]='R';
			else if(D[i]=='L')D[i]='D';
			int xx=X[i],yy=Y[i];
			X[i]=-yy;Y[i]=xx;
		}
	}
	if(Min==INT_MAX)puts("SAFE");
	else cout<<Min/10<<endl;
}

Measured memory_bytes: 61460
#define _GLIBCXX_DEBUG
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>//"geometry.cpp"
#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
#include<queue>
#include<string>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<algorithm>
#include<functional>//"greater<T>" Ex. sort(a,a+n,greater<int>());
#include<cmath>//"abs", "sqrt"
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
#define is insert	//tentative
typedef pair<int,int> pii;//Add other types in the same way.

void solve(int n){
	int r[1000],w[1000],m=0,rs=0,ws=0;
	for(int i=0;i<n;++i){
		cin>>r[i]>>w[i];
		if(r[m]<r[i]){
			m=i;
		}
		rs+=r[i];
		ws+=w[i];
	}
	if(2*r[m]<=rs){
		cout<<ws+rs<<endl;
	}else{
		bool f[1001];
		int k=2*r[m]-rs;
		fill(f,f+k+1,false);
		f[0]=true;
		for(int i=0;i<n;++i){
			if(i==m){
				continue;
			}
			for(int j=k;j>0;--j){
				if(j>=w[i]&&f[j-w[i]]){
					f[j]=true;
				}
			}
			if(f[k]){
				break;
			}
		}
		for(int j=0;j<=k;++j){
			if(f[k-j]){
				cout<<ws+rs+j<<endl;
				break;
			}
		}
	}
}

int main(){	
	while(true){
		int n;
		cin>>n;
		if(n==0) break;
		solve(n);
	}
}

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

#define REP(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;

// constexpr ll mod = 1e9+7;



int main(){
  int N; ll K;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> before(N), after(N);
  REP(i, N){
    cin >> A[i];
    before[i] = A[i]-1;
  }
  int v = 0;
  REP(i,60){
    if(K>>i & 1){
      v = before[v];
    }
    REP(j, N){
      after[j] = before[before[j]];
    }
    before = after;
  }
  cout << v+1 << endl;
  return 0;
}


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

int main(void) {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	int cnt = 0;
	rep(i, n) {
		if (p[i] != i + 1) cnt++;
	}
	if (cnt <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

LL N;
LL g[15];
int ans[15];

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
	g[0] = 0;
	LL x = 1;
	for (int i = 1; i <= 10; i++)
    {
        x *= 26;
        g[i] = g[i-1]+x;
    }
    g[11] = INF;
    scanf("%lld", &N);
    int p = upper_bound(g, g+11, N)-g-1;
    if (N == g[p])
    {
        for (int i = 1; i <= p; i++) putchar('z');
        putchar('\n');
        return 0;
    }
    N -= g[p]+1;
    for (int i = 0; i <= p; i++)
    {
        ans[i] = N%26;
        N /= 26;
    }
    for (int i = p; i >= 0; i--)
    {
        putchar('a'+ans[i]);
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e3+5;
int n,p,ans=0,po[maxn*maxn],pp[maxn],f[maxn][maxn],g[maxn],fac[maxn],inv[maxn];
int qpow(int i,int x,int p){
	int res=1;
	while(i){
		if(i&1){res=1ll*res*x%p;}
		x=1ll*x*x%p;i/=2;
	}
	return res;
}
int C(int x,int y,int p){return 1ll*fac[x]*inv[y]%p*inv[x-y]%p;}
int main(){
	scanf("%d%d",&n,&p);
	fac[0]=1;for(int i=1;i<=n;i++){fac[i]=1ll*fac[i-1]*i%p;}
	inv[n]=qpow(p-2,fac[n],p);for(int i=n;i>=1;i--){inv[i-1]=1ll*inv[i]*i%p;}
	po[0]=1;for(int i=1;i<=n*n;i++){po[i]=1ll*po[i-1]*2%p;}
	pp[0]=1;for(int i=1;i<=n;i++){pp[i]=1ll*pp[i-1]*2%(p-1);}
	for(int i=0;i<=n;i++){pp[i]=qpow(pp[i],2,p);}
	for(int i=0;i<=n;i++){f[i][0]=1;}
	for(int i=1;i<=n;i++){for(int j=1;j<=i;j++){f[i][j]=(1ll*f[i-1][j]*(j+1)%p+f[i-1][j-1])%p;}}
	for(int i=0;i<=n;i++){for(int j=0;j<=i;j++){g[i]=(g[i]+1ll*f[i][j]*po[j*(n-i)]%p*pp[n-i]%p)%p;}}
	for(int i=0,opt=1;i<=n;i++,opt*=-1){ans=(ans+p+1ll*opt*g[i]*C(n,i,p)%p)%p;}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 69504
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define INF 1000000
using namespace std;
typedef pair<double, int> P;

vector<P> V;

int main() {
  P temp;
  bool r=false;
  for(int i=0;i<24;i++) {
    cin >> temp.second >> temp.first;
    V.push_back(temp);
  }

  for(int i=0;i<3;i++) {
    sort(V.begin()+ (8 * i) ,V.begin()+(8 * i + 8));
    for(int j=0;j<2;j++) {
      temp = V[8*i+j];
      printf("%d %.2lf\n",temp.second,temp.first);
      vector<P>::iterator it = V.begin() + (8 * i+j);
      it = V.erase(it);
      temp.first = INF;
      V.insert(it,temp);
    }
  }
  sort(V.begin(),V.end());
  for(int i=0;i<2;i++) {
    temp = V[i];
    printf("%d %.2lf\n",temp.second,temp.first);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	int ans1, ans2 = 0;
	for (int i = 0; i < s.length(); i++) {
		if (i % 2 == 0 && s[i] == '1') {
			ans1++;
		}
		if (i % 2 == 1 && s[i] == '0') {
			ans1++;
		}
		if (i % 2 == 0 && s[i] == '0') {
			ans2++;
		}
		if (i % 2 == 1 && s[i] == '1') {
			ans2++;
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
typedef pair<LL, LL> LLP;
const int INF=1<<30;
const LL MAX=1e9+7;

int main() {
  int N;
  cin >> N;
  int ans;
  if (N % 2 == 0) {
    ans = N / 2 - 1;
  }
  else {
    ans = (N-1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

void out(int s){
	int i;
	for(i=6;i>=0;i--){
		printf("%d",s>>i&1);
	}
	printf("\n");
}
int main(){
	int p[10]={077,06,0133,0117,0146,
		0155,0175,047,0177,0157};
	int n,s,a;
	while(scanf("%d",&n)==1&&n!=-1){
		s=0;
		while(n--){
			scanf("%d",&a);
			out(s^p[a]);
			s=p[a];
		}
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    string s,t;

    cin >> s >> t;

    vector<string> ans[50];
    int n = s.length();
    int l = t.length();
    int cnt =0;

    bool w=false;

    rep(i,n-l+1){
        string copy = s.substr(n-l-i,l);
        rep(j,l){
            if((copy[j]==t[j])||(copy[j]=='?')){
                // cout << j << copy[j] << endl;
                w = true;

                continue;
            }  
            else{
                w =false;
                break;
            }
        }
        if(w){
            rep(k,n-l-i){
                if(s[k]=='?'){
                    cout << 'a';
                    // cout << s[i] << endl;
                }
                else{
                    cout << s[k];
                }

            }
            cout << t;
            for(int h=n-i;h<n;h++){
                if(s[h]=='?'){
                    cout << 'a';
                }
                else{
                    cout << s[h];
                }
            }
            return 0;
        }
    }

    cout << "UNRESTORABLE" ;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()
count = 0
for i in range(n):
    if a[i] == b[i] and b[i] == c[i]:
        continue
    elif a[i] == b[i] or b[i] == c[i] or a[i] == c[i]:
        count += 1
    else:
        count += 2
print(count)

Measured memory_bytes: 3060
n, m ,l = map(int, input().split())

A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for j in range(m)]

C = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
	for j in range(l):
		for k in range(m):
			C[i][j] += (A[i][k] * B[k][j])

Cp = [print(" ".join(map(str, C[i]))) for i in range(n)]

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

int main(){
	string s;
	cin >> s;
	
	for(int i = 0; i < s.size(); i += 2){
		if( s[i] == '0' ){
			if( s[i+1] == 'T' ){
				cout << "wa";
			}
			else if( s[i+1] == 'D' ){
				cout << "wo";
			}
			else{
				cout << "nn";
			}
		}
		else{
			if( s[i] != '1' ){
				cout << "kstnhmyrw"[s[i] - '2'];
			}
			
			char c = 0;
			switch( s[i+1] ){
				case 'T':
					c = 'a';
					break;
				case 'L':
					c = 'i';
					break;
				case 'U':
					c = 'u';
					break;
				case 'R':
					c = 'e';
					break;
				case 'D':
					c = 'o';
					break;
			}
			cout << c;
		}
	}
	cout << '\n';
}

Measured memory_bytes: 1164
#include<iostream>
#include <stdlib.h>
using namespace std;

int main(void) {
	long long int n, sum;
	cin >> n;
	sum = 0;
	for (long long int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3196
use std::io;


fn main() {
    let x = read_one::<usize>();
    println!("{}", x.pow(3));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 5036
#include <iostream>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    if(a==b) {
        cout<<"Draw";
    }
    else if(a==1){
        cout<<"Alice";
    }
    else if(b==1){
        cout<<"Bob";
    }
    else if(a>b){
        cout<<"Alice";
    }
    else{
        cout<<"Bob";
    }
    system("pause");
}


Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

void draw(int H,int W){
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout << "#";
		}
		cout << endl;
	}
	return;
}

int main(){
	int H,W;
	for(int i=0;;i++){
		cin >> H >> W;
		if(H==0&&W==0)return 0;
		draw(H,W);
		cout <<endl;
	}

	return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;

  int A,B;
  cin >> A >> B;
  
  string U;
  cin >> U;
  
  if (S == U) {
      cout << A-1 << ' '<< B << endl;
  }
  
  else if (T == U) {
      cout << A << ' '<< B-1 << endl;
  }

}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int n,m;
  cin >>n>>m;
  
  cout << (n-1)*(m-1) << endl;  
  
}
      

Measured memory_bytes: 3636
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		boolean ans = true;
		int px = 0, py = 0;
		for(int i = 0; i < N; i++){
			int t = in.nextInt();
			int x = in.nextInt();
			int y = in.nextInt();
			int dist = Math.abs(x - px) + Math.abs(y - py);
			
			if(t < dist || (t - dist) % 2 != 0){
				ans = false;
				break;
			}
		}
		
		System.out.println(ans ? "Yes" : "No");
	}
}


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

int main() {
    int n,k;cin>>n>>k;
    int p[n],c[n];
    rep(i,n) cin>>p[i],p[i]--;
    rep(i,n) cin>>c[i];
    ll ans=-1e9;
    rep(i,n) {
        int cu=i,a=0;
        ll sm=0;
        while (1) {
            cu=p[cu];
            a+=1;
            sm+=c[cu];
            if (cu==i) break;
        }
        sm=max(0LL,sm);
        ll s=0;
        rep(j,a) {
            cu=p[cu];
            s+=c[cu];
            ans=max(ans,sm*((k-j-1)/a)+s);
            if (j+1==k||cu==i) break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
class Edge{
public:
//int s;
int t;
long long len;
};
class Node{
    public:
    int num;//node番号
    long long dist;//startからの距離
    vector<Edge> edge;//自分から生えている辺
    bool comp;//dijkstra中で到達しているかどうか
    void in_edge(int t,int len){
      Edge edge_in;
      edge_in.t=t;
      edge_in.len=len;
      edge.push_back(edge_in);
    }  
};
bool operator >(const Node& a,const Node &r){
        return a.dist > r.dist;
    }
void dijkstra(vector<Node> &node,int s,int n){
    //n個のノードでできたグラフのsからtまでの最短距離を計算する
    //この時各要素のdistの値はsからの最短距離となる
    for(int i=0;i<n;i++){
        //初期化
        node[i].dist=inf;
        node[i].num=i;
        node[i].comp=true;
    }
    node[s].dist=0;
    priority_queue<Node,vector<Node>,greater<Node>> que;
    que.push(node[s]);
    while(!que.empty()){
        Node buf;
        buf=que.top();//
        que.pop();
        int k=buf.num;
        if(node[k].comp){
            node[k].comp=false;
            int edge_num=buf.edge.size();
            for(int i=0;i<edge_num;i++){
                int buf_t=node[k].edge[i].t;
                int buf_len=node[k].edge[i].len;
                if(node[buf_t].dist>node[k].dist+buf_len){
                node[buf_t].dist=node[k].dist+buf_len;
                que.push(node[buf_t]);
                }
            }
        }
    }
}
signed main(){
  int h,w;cin>>h>>w;
  vector<Node> node(10);
  rep(i,10){
    rep(j,10){
      int c;cin>>c;
      node[j].in_edge(i,c);
    }
  }
  dijkstra(node,1,10);
  int res=0;
  rep(i,h){
    rep(j,w){
      int buf;cin>>buf;
      if(buf!=-1){
        res+=node[buf].dist;
      }
    }
  }
  cout<<res<<endl;
  return 0;
}


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

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) rep(j, m) cin >> a[i][j];
    int ans = 0;
    rep(i, n)
    {
        int s = c;
        rep(j, m)
        {
            s += a[i][j] * b[j];
        }
        if (s > 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

inline int read(){
    char ch=getchar();int x=0,f=1;
    while(ch>'9' || ch<'0'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

int n,a[20000015];

int small(int i,int j,int k) {
    return a[i]<=k && a[j]<=k;
}

int 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(big(n+i,n+i+1,k) || big(n-i,n-i-1,k)) return 0;
        if(small(n+i,n+i+1,k) || small(n-i,n-i-1,k)) return 1;
    }
    return small(1,1,k);
}

int main(){
    n=read();
    for(int i=1;i<=2*n-1;i++){
        a[i]=read();
    }
    int l=1,r=2*n-1,ans;
    while(l<r){
        int mid=l+r>>1;
        if(check(mid)) {
            r=mid;
        }
        else l=mid+1;
    }
    cout<<r;
    return 0; 
}

Measured memory_bytes: 1152
use std::io::*;
use std::str::FromStr;

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

fn dfs(n: usize, m: usize, depth: usize, swithces: &Vec<usize>, ons: usize) -> usize {
    if depth == n {
        if ons == 0 {
            return 1;
        }
        return 0;
    }
    let mut ret = 0;
    let nons = ons;
    ret += dfs(n, m, depth + 1, swithces, nons);
    let nons = ons ^ swithces[depth];
    ret += dfs(n, m, depth + 1, swithces, nons);
    return ret;
}
fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut switches = vec![0; n];
    let mut ons = 0;
    for i in 0..m {
        let k = read::<usize>();
        for _j in 0..k {
            let s = read::<usize>() - 1;
            switches[s] |= 1 << i;
        }
    }
    for i in 0..m {
        let p = read::<usize>();
        ons |= p << i;
    }
    let ans = dfs(n, m, 0, &switches, ons);
    println!("{}", ans);
}


Measured memory_bytes: 4352
H, W = map(int, input().split())
grid = [input() for _ in range(H)]

left   = [[0] * 2005 for i in range(2005)]
right  = [[0] * 2005 for i in range(2005)]
top    = [[0] * 2005 for i in range(2005)]
bottom = [[0] * 2005 for i in range(2005)]

for h in range(H):
	cur = 0
	for w in range(W):
		if grid[h][w] == '#':
			left[h][w] = -1
			cur = 0
		else:
			left[h][w] = cur
			cur += 1
	cur = 0
	for w in range(W-1, -1, -1):
		if grid[h][w] == '#':
			right[h][w] = -1
			cur = 0
		else:
			right[h][w] = cur
			cur += 1

for w in range(W):
	cur = 0
	for h in range(H):
		if grid[h][w] == '#':
			top[h][w] = -1
			cur = 0
		else:
			top[h][w] = cur
			cur += 1

	cur = 0
	for h in range(H-1, -1, -1):
		if grid[h][w] == '#':
			bottom[h][w] = -1
			cur = 0
		else:
			bottom[h][w] = cur
			cur += 1

ans = 0
for h in range(H):
	for w in range(W):
		if grid[h][w] == '.':
			ans = max(ans, left[h][w] + right[h][w] + top[h][w] + bottom[h][w] + 1)
print(ans)

Measured memory_bytes: 180356
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

int n,m,x,date,count1 = 0,count2 = 0;
vector <int> a;

cin >> n >> m >> x;
rep(i,m) {
    cin >> date; 
    a.push_back(date);
}
for (int i = 0; i < x; i++)
{   
    rep(j,m){
        if (a[j] == i)
    {
        count1++;
    }
    }
    
}
for (int i = x; i < n+1; i++)
{
    rep(j,m){
        if (a[j] == i)
    {
        count2++;
    }
    }
}

if (count1 >= count2)
{
    cout << count2 << endl;
}else
{
    cout << count1 << endl;
}








//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
int n,k,ans;
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
inline void Cinit(){// limit is 5e6 /// write pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<5e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 0;if(k<0)return 0;
  if(!Factorial[0])Cinit();
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}

signed main(){
  cin>>n>>k;
  for(int i=0;i<=min(n,k);i++)ans+=nCk(n,i)*nCk(i+n-i-1,n-i-1)%MOD;
  cout<<ans%MOD<<endl;
}


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

int main() {
	int x, sum=0;
	cin >> x;
	if(x>=500){
	    sum+=(x/500)*1000;
	    x=x-(x/500)*500;
	}
	if(x>=5){
	    sum+=(x/5)*5;
	    cout << sum;
	    return 0;
	}
	else
	   cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll func(ll n, ll k, vector<ll>&arr){
    vector<ll>dp(n, 0);
    dp[0] = 0;
    for(ll i = 1; i < n ; i++){
        ll ans = LONG_MAX;
        for(ll j = 1 ;j<= k ;j++){
            if(i-j>=0){
                ans = min(ans, dp[i-j]+abs(arr[i]-arr[i-j]));
            }
        }
        dp[i]=ans;
    }
    return dp[n-1];
}
int main(){
    ll n, k;
    cin>>n>>k;
    vector<ll>arr(n);
    for(ll i = 0 ; i < n ; i++){
        cin>>arr[i];
    }
    cout<<func(n, k, arr);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int N, M, A,B, count=0;
	cin>>N>>M;
	vector<set<int>> vect(N+1);
	int ele[N+1];
	for(int i=1; i<=N;i++)
	{
		cin>>ele[i];
	}	
	for(int i=0; i<M;i++)
	{
		cin>>A;
		cin>>B;
		vect[A].insert(B);
		vect[B].insert(A);
	}
	for(int i=1;i<=N;i++)
	{
		bool pos = true;
		for(auto itr = vect[i].begin();itr!=vect[i].end();itr++)
		{
			if(ele[i]<=ele[*itr])
			{
				pos = false;
				break;
			}
		}
		if(pos)
		{
			count++;
		}
	}
	cout<<count<<"\n";
}

Measured memory_bytes: 17724
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
//k以上である要素のうち最小のもののインデックスを求める
int n;
vector<int> a;
int upper_bound(int k){
  int left=-1,right=a.size();
  while(right-left>1){
    int mid=(right+left)/2;
    if(a[mid]>=k) right=mid;
    else left=mid;
  }
  return a[right];
}

int main()
{
  int m;cin >> n >> m;
  string s;cin >> s;
  rep(i,n+1) {
    if(s[i] == '0') a.push_back(i);
  }
  int index = n;
  vector<int> res;
  while(index > 0) {
    int next = upper_bound(index - m);
    if(next >= index) {
      cout << -1 << "\n";
      return 0;
    }
    else {
      res.push_back(index - next);
    }
    index = next;
  }
  reverse(res.begin(), res.end());
  rep(i,res.size()) cout << res[i] << " ";
  cout << "\n";
  return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        cout << s[i] << endl;
        cout << s[i] << endl;
    }


    return 0;
}


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

using namespace std;

int n,h[100009],b[100009],c=0;

int calc(int idx)
{
    if(idx>=n)
        return 100000;
    if(idx==n-1)
        return 0;
        //pick
        int x=100000,y=100000;
        if(b[idx]!=-1)
            {
                c++;
                return b[idx];
            }
            x=abs(h[idx+1]-h[idx])+calc(idx+1);
            y=abs(h[idx+2]-h[idx])+calc(idx+2);

             return b[idx]= min(x,y);



}

int main()
{
    for(int i=0;i<100005;i++)
    {
        b[i]=-1;
    }
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    cout<<calc(0);
    /*for(int i=0;i<n;i++)
        cout<<b[i]<<" ";
    cout<<endl<<c;*/
    return 0;
}


Measured memory_bytes: 4096
import math
K = int(input())
ans = 0
result = 0
dp = [[[0 for i in range(K+1)] for i in range(K+1)]for i in range(K+1)]
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            if dp[i][j][k] == 0:
                x = math.gcd(i,j)
                y = math.gcd(j,k)
                ans = math.gcd(x,y)
                dp[i][j][k] = ans
                dp[j][i][k] = ans
                dp[k][i][j] = ans
                dp[k][j][i] = ans
                result += ans
            else:
                result += max(dp[i][j][k],dp[j][i][k],dp[k][i][j],dp[k][j][i])
print(result)

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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
ll d[110][110];

int main(void) {
  int n, K;
  while (cin >> n >> K, n) {
    fill(d[0], d[110], INF);
    for (int i = 0; i < n; i++) {
      d[i][i] = 0;
    }

    for (int i = 0; i < K; i++) {
      int p;
      cin >> p;

      if (p) {
        int u, v;
        ll w;
        cin >> u >> v >> w;
        u--, v--;

        if (w >= d[u][v]) continue;
        d[u][v] = d[v][u] = w;
        for (int j = 0; j < n; j++) {
          for (int k = 0; k < n; k++) {
            d[j][k] = d[k][j] = min(d[j][k], min(d[j][u] + d[v][k], d[j][v] + d[u][k]) + d[u][v]);
          }
        }
      } else {
        int u, v;
        cin >> u >> v;
        u--, v--;

        cout << (d[u][v] == INF ? -1 : d[u][v]) << endl;
      }
    }
  }

  return 0;
}


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

using namespace std;

int main() {
	string s, t;

	cin >> s >> t;

	int n = s.length();

	int ans = 0;
	
	for (int i = 0; i < n; i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3916
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <type_traits>
#include <limits>
#include <random>
#include <iomanip>

using namespace std;

using ll = long long;

typedef pair<int, int> P;

#define rep(i,N) for(long long i = 0;i < (long long)N; ++i)

static int mod = 1000000007;
static int large = 1000000000;

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

int N, Y;

int main() {
	cin >> N >> Y;
	for (int a = 0; a <= N; a++) {
		for (int b = 0; b <= N - a; b++) {
			if (Y == a * 10000 + b * 5000 + 1000 * (N - a - b)) {
				cout << a << ' ' << b << ' ' << N - a - b << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
  string s;
  cin >> s;
  int n = s.size();
  int n1 = (n-1)/2;
  int n2 = (n+3)/2;

  function<bool(string)> ispal = [&](string t)->bool{
    int l = 0, r = t.size()-1;
    while(l <= r){
      if(t[l] == t[r]){
        l++;
        r--;
      }else{
        return false;
      }
    }
    return true;
  };

  bool ans = true;
  ans = ispal(s) && ispal(s.substr(0, n1)) && ispal(s.substr(n2-1));

  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}     

Measured memory_bytes: 256
n = int(input())
 
a = {i+1: list(map(int, input().split())) for i in range(n)}
ret = 1
pair = []
keys = a.keys()
while True:
    for k in keys:
        v = a[k][0]
        if a[v][0] == k:
            pair.append(k)
            if v not in keys:
                pair.append(v)
    for p in pair:
        if len(a[p]) > 1:
            a[p] = a[p][1:]
        else:
            a.pop(p)
    if len(a) == 0:
        break
    if len(pair) == 0:
        ret = -1
        break
    ret = ret + 1
    keys = [k for k in pair if k in a]
    pair = []
 
print(ret)

Measured memory_bytes: 159112