akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n, m; cin >> n >> m;
  Vll h(n); cin >> h;

  VV G(n);
  rep(i, m) {
    int u, v; cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  ll ans = 0;

  rep(u, n) {
    bool ok = true;
    for (auto & v : G[u]) {
      if (h[u] <= h[v]) ok = false;
    }
    if (ok) ++ans;
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 9268
/*
   AtCoder Submission
*/

#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N, D;

    cin >> D >> N;

    ll sol = 0;
    for(int i = 1; i <= N; i++){
        if(i % 100 != 0){
            sol = i * pow(100, D);
        } else N++;
    }

    cout << sol << '\n';

    return 0;
}


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



int main() {
  int N,M,X; cin >> N >> M >> X;
  int a[N+1] = {0};
  for(int i=0;i<M;i++){
    int temp;
    cin >> temp;
    a[temp] = 1;
  }
  int f_1=0;
  for(int i=X;i<=N;i++){
    f_1 += a[i];
  }
  int f_2=0;
  for(int i=0;i<=X;i++){
    f_2 += a[i];
  }
  cout <<min(f_1,f_2) << endl;
  
}

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

std::vector<int> divisor(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


int main()
{
    ifstream fIn("input.txt");
    if (fIn.is_open())
        cin.rdbuf(fIn.rdbuf());

    int n;
    cin >> n;
    for(int i = 1; i <= 9; ++i){
        for(int j = 1; j<= 9;++j){
            if(i * j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  long double ans = 0;
  for(int i=0;i<n;i++){
    long double x;
    string u;
    cin >> x >> u;
    if(u=="JPY"){
      ans += x;
    }else if(u=="BTC"){
      ans += x*380000;
    }
  }

  printf("%.10Lf\n",ans);
}

Measured memory_bytes: 3756
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  res = 0
  for i in range(n-2):
    x = a[i]
    for j in range(i+1,n-1):
      y = a[j] 
      if x == y:
        continue
      for k in range(j+1,n):
        z = a[k]
        if y == z:
          continue
        if abs(x-y) < z < x+y:
          res += 1
  return res



def main():
  N = int(input())
  a = list(sorted(map(int,input().split())))
  print(solve(N,a))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}

bool comp(ll a,ll b){
	return abs(a)>abs(b);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	vl v(n);
	for(ll i=0;i<n;i++)
		cin>>v[i];
	//cout<<(-1%MOD)<<"\n";
	sort(all(v),comp);
	ll c=0;
	for(ll i=0;i<k;i++){
		if(v[i]<0)
			c++;
	}
	if(c%2==0){
		ll ans=1;
		for(ll i=0;i<k;i++)
			ans=(ans*v[i])%MOD;
		cout<<(ans%MOD)<<"\n";
		return 0;
	}
	ll poso=-1;
	for(ll i=k;i<n;i++){
		if(v[i]>0){
			poso=v[i];
			break;	
		}
	}
	ll nego=1;
	for(ll i=k;i<n;i++){
		if(v[i]<0){
			nego=v[i];
			break;	
		}
	}
	if(poso==-1&&c==k){
			ll ans=1;
			for(ll i=0;i<k;i++)
				ans=(ans*v[n-i-1])%MOD;
			cout<<(ans+MOD)%MOD<<"\n";
			return 0;
	}
	ll ans=1;
	ll ans2=1;
	ll remi,remv,remv2;
	remv=1;
	remv2=-1;
	if(poso!=-1){
	
	for(ll i=k-1;i>=0;i--){
		if(v[i]<0){
			remi=i;
			remv=v[i];
			v[i]=poso;
			break;
		}
	}
	for(ll i=0;i<k;i++)
		ans=(ans*v[i])%MOD;
	v[remi]=remv;
	}
	
	if(nego!=1){
		for(ll i=k-1;i>=0;i--){
		if(v[i]>0){
			remv2=v[i];
			v[i]=nego;
			break;
		}
	}
	for(ll i=0;i<k;i++)
		ans2=(ans2*v[i])%MOD;
	}
	if((poso==-1||remv==1)&&(nego!=1&&remv2!=-1))
		cout<<ans2%MOD<<"\n";
	else if((nego==1||remv2==-1)&&(poso!=-1&&remv!=1))
		cout<<ans<<"\n";
	else if((nego!=1&&remv2!=-1)&&(poso!=-1&&remv!=1)){
		if(poso*remv2>nego*remv)
			cout<<ans%MOD<<"\n";
		else
			cout<<ans2%MOD<<"\n";
	}
	else{
		ll ans=1;
			for(ll i=0;i<k;i++)
				ans=(ans*v[n-i-1])%MOD;
			cout<<(ans+MOD)%MOD<<"\n";
	}
}

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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  vector<int> c(0);
  int count=0;
  for(int i=1;i<=min(a,b);i++){
    if(a%i==0&&b%i==0){
      c.push_back(i);
      count++;
    }  
  }
  cout << c[count-k] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    string s, t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s<t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int height, width;

int main() {
	for (;;) {
		scanf("%d %d", &height, &width);
		if (height == 0 && width == 0) break;

		for (int i = 1; i <= height; i++) {
			for (int j = 1; j <= width; j++) {
				if (i % 2 == 1)
					if (j % 2 == 1)
						printf("#");
					else
						printf(".");
				else
					if (j % 2 == 1)
						printf(".");
					else
						printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

string n; 
int len, ku, dsum, pre = -1, inds, ans;
int N[500010], s[500010], ind[500010], zero[500010];

void add1(void){
	int la;
	rep(i, len){
		if(s[i] < 9){
			s[i]++; la = i; dsum++; break;
		}
		dsum -= 9;
		s[i] = 0;
	}
	if(s[len-1] == 0){
		len++; dsum++; s[len-1] = 1;
		rep(i, len-2) zero[i] = i+1;
		zero[len-2] = len; zero[len-1] = len;
		ind[0] = len;
		inds = ind[0];
		ans += 10;
		return;
	}
	if(la==0){
		if(s[0]==1){
			inds -= ind[0];
			ind[0] = 0;
			if(zero[0] <= ind[0] - 1){
				inds -= ind[zero[0]];
				ind[zero[0]] = ind[0] - zero[0];
				inds += ind[zero[0]];
			}
		}
	}else{
		rep(i, la-1) zero[i] = i+1;
		zero[la-1] = zero[la];
		if(s[la] == 1){
			ind[0] = la + ind[la];
			inds += ind[0] - ind[la];
			ind[la] = 0;
		}else{
			ind[0] = la;
			inds += ind[0];
		}
	}
	ans += 10;
}

int main(){
	cin >> n;
	len = n.size();
	rep(i, len) N[i] = n[len-i-1] - '0';
	N[len] = 0;
	rep(i, len+1){
		if(i==0){
			ku = 1+(N[i]*9)/10;
			ans = 10 - (N[i]*9)%10;
		}else{
			s[i-1] = (N[i]*9+ku) % 10;
			dsum += s[i-1];
			ku = (N[i]*9+ku)/10;
		}
	}
	if(s[len-1] == 0) len--;
	for(int i=len-1; i>=0; i--){
		if(i==len-1) zero[i] = i+1;
		else if(s[i+1] == 0) zero[i] = i+1;
		else zero[i] = zero[i+1];
	}
	rep(i, len){
		if(pre != -1){
			if(s[i] <= 1) ind[pre]++;
			else pre = -1;
		}else{
			if(s[i] == 0){ pre = i; ind[pre] = 1; }
		}
	}
	rep(i, len) inds += ind[i];
	while(1){
		if(dsum + 9*inds >= ans && ans >= dsum){
			cout << (ans+8)/9 << endl;
			return 0;
		}
		add1();
	}
	return 0;
}


Measured memory_bytes: 8708
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 998244353;
const int INF = 0x3f3f3f3f;
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}
ll s[N],pre[N];

int main()
{
	ll a,b;
	sl(a);sl(b);
	cout<<(a-1)*(b-1)<<endl;
}

Measured memory_bytes: 256
N, M, C = (map(int, input().split()))
B = list(map(int, input().split()))
counter = 0
for i in range(N):
	tmp = list(map(int, input().split()))
	total = C
	for j in range(M):
		total += B[j] * tmp[j]
	if total > 0:
		counter += 1
			
print(counter)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > p(N);
  for (int i=0; i<N; i++) {
    std::cin >> p[i];
    p[i]--;
  }
  std::vector<int > a(N), b(N);
  for (int i=0; i<N; i++){
    a[i] = 30000 * (i+1);
    b[N-1-i] = 30000 * (i+1);
   }
  for (int i=0; i<N; i++) {
    a[p[i]]+=i;
    b[p[i]]+=i;
  }
  for (int i=0; i<N; i++){
    printf("%d%c", a[i], (i==N-1)?'\n':' ');
  }
  for (int i=0; i<N; i++){
    printf("%d%c", b[i], (i==N-1)?'\n':' ');
  }
   return 0;
}

Measured memory_bytes: 3488
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
  SS(ll,n,k)
  SV(ll,a,k)
  sort(a.rbegin(),a.rend());
  p(max(a[0]-1-(n-a[0]),0LL));
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,t;
    scanf("%d\n",&n);
    char s[n];
    gets(s);
    t=0;
    for(i=0;i<n;i++)
    {
        if(s[i]!=s[i+1])
        {
            t++;
        }
    }
    printf("%d\n",t);
    return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vl A(n),B(n),C(n);
    rep(i,n) cin >> A[i];
    rep(i,n) cin >> B[i];
    rep(i,n) cin >> C[i];
    sort(all(A));
    sort(all(C));
    ll ans = 0;
    rep(i,n){
        ll x = lower_bound(all(A), B[i]) - A.begin();
        ll y = n - (upper_bound(all(C), B[i]) - C.begin());
        ans += x * y;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
require 'matrix'
n = gets.to_i
shops = []
n.times do
  shops << Vector.elements(gets.chomp.split(' ').map(&:to_i),true)
end
profits = []
n.times do
  profits << gets.chomp.split(' ').map(&:to_i)
end
i = 1
max = -10**10
while i < 2**10
  string = i.to_s(2)
  pattern = ("0" * (10 - string.length) + string).chars.map(&:to_i)
  sum = 0
  j = 0
  while j < n
    sum += profits[j][shops[j].inner_product(pattern)]
    j += 1
  end
  if max < sum
    max = sum
  end
  i += 1
end
puts max

Measured memory_bytes: 15044
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    char ch;

    while (1) {
        scanf("%c", &ch);
        if (islower(ch)) {
            cout << (char)toupper(ch);
        } else if (isupper(ch)) {
            cout << (char)tolower(ch);
        } else {
            cout << ch;
        }
        if (ch == '\n') break;
    }
}
int main() {
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();

		int n = stdIn.getValue();
		List<Integer> values = stdIn.getLine();

		insertionSort(values, n);

		stdIn.close();
	}

	public static void insertionSort(List<Integer> values, int n) {
		StringBuilder sb2 = new StringBuilder();
		for(int k = 0; k < values.size();k++) {
			sb2.append(values.get(k) + " ");
		}
		System.out.println(sb2.delete(sb2.length()-1, sb2.length()));
		for (int i = 1; i < values.size(); i++) {
			StringBuilder sb = new StringBuilder();
			int v = values.get(i);
			int j = i - 1;
			for (; j >= 0 && values.get(j) > v; j--) {
			}
			values.remove(i);
			values.add(j+1, v);

			for(int k = 0; k < values.size();k++) {
				sb.append(values.get(k) + " ");
			}
			System.out.println(sb.delete(sb.length()-1, sb.length()));
		}
	}
}

class Input {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public Input() {
	}

	public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	}

	public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

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

    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << 'A' << endl;
    } else {
        cout << 'B' << endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    
    ll ans = 0;
    rep(i,n-1){
        if(a[i] / 2 > 0){
            ans += a[i]/2;
            a[i] %= 2;
        }
        ll tmp = min(a[i], a[i+1]);
        ans += tmp;
        a[i] -= tmp;
        a[i+1] -= tmp;
    }
    ans += a[n-1]/2;
    
    cout << ans << endl;
    
    //cout << endl;
    //rep(i,n)cout << a[i] << ((i < n-1)?" ":"\n");
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	char c;
	cin >> c;
	
	if( c == 'A' ) cout << 'T' << endl;
	if( c == 'T' ) cout << 'A' << endl;
	if( c == 'G' ) cout << 'C' << endl;
	if( c == 'C' ) cout << 'G' << endl;
	
	return 0;
}


Measured memory_bytes: 3564
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

struct BinaryIndexedTree {
    tree: Vec<isize>,
}
impl BinaryIndexedTree {
    #[allow(dead_code)]
    fn new(n: usize) -> Self {
        BinaryIndexedTree {
            tree: vec![0; n + 1],
        }
    }
    #[allow(dead_code)]
    fn add(&mut self, a: usize, w: isize) {
        let mut x = a as isize + 1;
        while x < self.tree.len() as isize {
            self.tree[x as usize] += w;
            x += x & (-x);
        }
    }
    #[allow(dead_code)]
    fn sum(&self, n: usize) -> isize {
        let mut x = n as isize;
        let mut ret = 0;
        while x > 0 {
            ret += self.tree[x as usize];
            x -= x & (-x);
        }
        ret
    }
    #[allow(dead_code)]
    fn sum_with(&self, l: usize, r: usize) -> isize {
        if l == 0 {
            self.sum(r)
        } else {
            self.sum(r) - self.sum(l - 1)
        }
    }
}

macro_rules ! max { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ z : expr ) ,+ ) => { { std :: cmp :: max ( $ x , max ! ( $ ( $ z ) ,* ) ) } } }
macro_rules ! min { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ z : expr ) ,+ ) => { { std :: cmp :: min ( $ x , min ! ( $ ( $ z ) ,* ) ) } } }

fn main() {
    input! {
        n: usize,
        k: usize,
        mut a: [isize;n],
    }

    for _ in 0..k {
        let mut bit = BinaryIndexedTree::new(n);
        for i in 0..n {
            bit.add(max!(i as isize - a[i], 0) as usize, 1);
            bit.add(min!(i as isize + a[i] + 1, n as isize) as usize, -1);
        }
        let mut flag = false;
        for i in 0..n {
            a[i] = bit.sum(i + 1);
            if a[i] < n as isize {
                flag = true;
            }
        }
        if !flag {
            break;
        }
    }
    for i in 0..n {
        print!("{} ", a[i]);
    }
    println!("");
}


Measured memory_bytes: 6320
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

vector<int> graph[500000];
int n, m, q, a, b, color[500000];
int v[500000], d[500000];
int call[11][500000];

void qq(int v, int d, int color)
{
    if (call[d][v] != 0) return;
    call[d][v] = color;
    if (d == 0) return;
    for (auto u : graph[v]) qq(u, d - 1, color);
    qq(v, d - 1, color);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    cin >> q;
    for (int i = 1; i <= q; i++)
    {
        cin >> v[i] >> d[i] >> color[i];
    }
    for (int i = q; i >= 1; i--)
    {
        qq(v[i], d[i], i);
    }
    for (int i = 1; i <= n; i++)
    {
        cout << color[call[0][i]] << "\n";
    }
}


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

int main(){
	while(true){
		int  N;
		cin>>N;
		if(N==0){
			break;
		}
		int n[10]={0};
		int m=0;
		for(int i=0;i<100;i++){
			char c;
			cin>>c;
			n[i%N]++;
			if(c=='S'){
				m+=n[i%N];
				n[i%N]=0;
			}else if(c=='L'){
				n[i%N]+=m;
				m=0;
			}
		}
		sort(n,n+N);
		for(int i=0;i<N;i++){
			cout<<n[i]<<' ';
		}
		cout<<m<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long int
#define pb push_back
#define bpc __builtin_popcount
#define f first
#define s second

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong a[mxn], p[mxn], n, k, cnt = 1, ans = 0;

int main(){
    cin >> n;
    for (int i = 1; i <= n; i ++){
        cin >> a[i];
    }for (int i = 1; i <= n; i ++){
        if(a[i] == a[i + 1]){
            cnt ++;
        }else{
            ans += (cnt / 2);
            cnt = 1;
        }
    }cout << ans + (cnt / 2);
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







template<class T> class SegmentTreeMax{
    int n = 0;
    std::vector<T> dat;
    T fill = INF;
public:
    SegmentTreeMax(){}
    SegmentTreeMax(int m, T fil = -INF){
        fill = fil;
        int i = 1;
        while(i < m) i *= 2;
        n = i;
        dat.resize(2*i - 1);
        for(int j(0), j_len(2*i-1); j < j_len; ++j)
            dat[j] = fill;
    }
 
    void update(int k, T a){
        k += n - 1;
        int moto = dat[k];
        dat[k] = a;
        while(k){
            k = (k - 1) / 2;
            dat[k] = std::max(dat[2*k+1], dat[2*k+2]);
        }
    }
 
    T getMax(int a, int b, int k=0, int l=0, int r=-1){
        //[a, b[であることに注意
        if(r < 0) r = n;
        if(r <= a || b <= l) return fill;
        if(a <= l && r <= b) return dat[k];
 
        int vl = getMax(a, b, 2*k+1, l, (l+r)/2);
        int vr = getMax(a, b, 2*k+2, (l+r)/2, r);
        return std::max(vl, vr);
    }
 
    T getvalue(int k){
        return dat[k+n-1];
    }
};

int main(){
    int N, K; std::cin >> N >> K;
    SegmentTreeMax<int> seg(300001, 0);
    {
        int A;
        for(int i(0); i < N; ++i){
            std::cin >> A;
            seg.update(A, seg.getMax(std::max(0, A - K), 
                                     std::min(300000, A + K) + 1) + 1);
        }
    }
    std::cout << seg.getMax(0, 300001) << std::endl;

    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> data(M);
  for (int i = 0; i < M; i++) {
    int kk; cin >> kk;
    for (int l = 0; l < kk; l++) {
      int ss; cin >> ss;
      data.at(i).push_back(ss - 1);
    }
  }
  
  vector<int> pm(M);
  for (int i = 0; i < M; i++) cin >> pm.at(i);
    
  int count = 0, cnt = 1;
  vector<int> sw(N, 0);
  for (int i = 0; i < N; i++) cnt *= 2;
  while(cnt) {  
    int jd = 1;
    for (int i = 0; i < M; i++) {
      int sum = 0;
      for (int x: data.at(i)) {
        sum += sw.at(x);
      }
      
      
      if (!(sum%2 == pm.at(i))) {
        jd = 0;
        break;
      }
    }
    if (jd) count++;
    
    for (int i = 0; i < N; i++) {
      if (sw.at(i) == 0) {
        sw.at(i) = 1;
        break;
      } else {
        sw.at(i) = 0;
      }
    }
    
    cnt--;
  }
  
  cout << count << endl;
}
    

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-9;

void solve() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    s += s;
    bool ans = false;
    for(ll i = 0; i < n; i++) {
        string u = s.substr(i, n);
        if(u == t) {
            ans = true;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int h, w, n;
  cin >> h >> w >> n;
  
  int m = max(h, w);
  int ans = (n + m - 1) / m;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;
char s[100005];
int flag[30];

int main()
{
    int i;

    while(scanf("%s",s) != EOF)
    {
        for(i = 0;i < 30;i++) flag[i] = 0;
        for(i = 0;s[i] != '\0';i++)
        {
            flag[s[i]-'a'] = 1;
        }
        for(i = 0;i < 26;i++)
        {
            if(flag[i] == 0)
            {
                printf("%c\n",i+'a');
                break;
            }
        }
        if(i == 26) printf("None\n");
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        bool temp=true;
        for(int j=0;j<i;j++)
        {
            if(h[j]>h[i])
            {
                temp=false;
                break;
            }
        }
        if(temp)
        {
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3596
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n=0;
	cin>>n;
	auto GET=[&](int x, int y, int z)
	{
		return (x*x+y*y+z*z+x*y+y*z+z*x);
	};
	vector<int> a(n+1,0);
	for(int i=1;i<=100;++i)
		for(int j=1;j<=100;++j)
			for(int k=1;k<=100;++k)
				if(GET(i,j,k)<=n)
					++a[GET(i,j,k)];
	for(int i=1;i<=n;++i)
		cout<<a[i]<<endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
ll dp[1LL << 20] = {0};

bool solve() {
  int n;
  cin >> n;
  if (n == 0) return false;
  map<string, int> mp;
  vector<string> name(n);
  vector<vector<string>> ene(n);
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> name[i];
    mp[name[i]] = i;
    cin >> v[i];
    int c;
    cin >> c;
    ene[i].resize(c);
    for (int j = 0; j < c; j++) cin >> ene[i][j];
  }
  vector<ll> p(n);
  for (int i = 0; i < n; i++) {
    for (auto &s : ene[i]) {
      p[i] |= 1LL << mp[s];
      p[mp[s]] |= 1LL << i;
    }
  }
  for (int i = 0; i < (1LL << 20); i++) dp[i] = 0;
  for (int i = 0; i < (1LL << max(0, n - 20)); i++) {
    ll ng = 0;
    for (int j = 0; j < max(0, n - 20); j++) {
      if (i & (1LL << j)) {
        ng |= p[j + 20] >> 20;
      }
    }
    for (int j = 0; j < max(0, n - 20); j++) {
      if (i & (1LL << j)) continue;
      int next = i | (1LL << j);
      int nextng = ng | (p[j + 20] >> 20);
      dp[next] = max(dp[next], dp[i]);
      if (nextng & next) continue;
      dp[next] = max(dp[next], dp[i] + v[j + 20]);
    }
  }

  ll ans = 0;
  for (ll i = 0; i < (1 << min(n, 20)); i++) {
    ll temp = 0;
    ll ng = 0;
    if (i % 2 == 0) continue;
    for (int j = 0; j < min(n, 20); j++) {
      if (i & (1LL << j)) {
        temp += v[j];
        ng |= p[j];
      }
    }
    if (ng & i) continue;
    int bit = ((1LL << 20) - 1) & (~(ng >> 20));
    ans = max(ans, temp + dp[bit]);
  }
  cout << ans << endl;
  return true;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  while (solve());
  return 0;
}



Measured memory_bytes: 11500
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

// #include "../l/mod.h"

class C {
public:
	void solve(istream& cin, ostream& cout) {
		int N; cin >> N;
		int B; cin >> B;
		ll A[3] = {B, -1000000000000000LL, -1000000000000000LL};
		for (int i = 0; i < N-1; ++i) {
			char c; cin >> c;
			cin >> B;

			bool m = c == '-';
			A[2*m] = max(A[m], A[m+1]);
			A[0] += B * (1-2*m);

			A[1] -= B;
			A[2] += B;
			if (m) A[1] = max(A[0], A[1]);
		}

		cout << max(A[0], max(A[1], A[2])) << endl;
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	lint n,sum=0;
	cin>>n;
	vector<lint>a(n);
	rep(i,n)cin>>a.at(i);
	rep(i,n)sum+=a.at(i)-1;
	cout<<sum<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
# グラフの最長経路が-1か-2かを選べる
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)


def f(x):
  opposite = 0
  max_dist = 0
  # 最離点と距離とを返す
  d = [None]*N
  q = [(x,0)]
  while q:
    x,dx = q.pop()
    d[x] = dx
    if dx > max_dist:
      max_dist = dx
      opposite = x
    for y in edge[x]:
      if d[y] is None:
        q.append((y,dx+1))
  return opposite,max_dist

if N != 1:
  # 0からの距離
  v,_ = f(0)
  _,max_dist = f(v)

  ans = 'First' if max_dist%3 != 1 else 'Second'
  print(ans)
else:
  print('First')


Measured memory_bytes: 56752
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 100;
int b[N][10], a[N];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n ; ++i) {
    int x;
    for (int j = 0; j < 10; ++j) {
      cin >> x;
      if (x) a[i] |= 1 << j;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> b[i][j];
    }
  }
  int64 ret = -(1LL << 60);
  for (int k = 1; k < (1 << 10); ++k) {
    int64 sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += b[i][__builtin_popcount(a[i] & k)];
    }
    ret = max(ret, sum);
  }
  cout << ret << endl;
  return 0;
}


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

bool isFourCards(int* cards) {
    return cards[0] == cards[3] || cards[1] == cards[4];
}

bool isFullHouse(int* cards) {
    return cards[0] == cards[1] && cards[3] == cards[4] && (cards[2] == cards[1] || cards[2] == cards[3]);
}

bool isStraight(int* cards) {
    return cards[1] + 1 == cards[2] && cards[2] + 1 == cards[3] && cards[3] + 1 == cards[4]
        && (cards[0] + 1 == cards[1] || (cards[0] == 1 && cards[4] == 13));
}

bool isThreeCards(int* cards) {
    return (cards[0] == cards[1] && cards[1] == cards[2])
        || (cards[1] == cards[2] && cards[2] == cards[3])
        || (cards[2] == cards[3] && cards[3] == cards[4]);
}

bool isTwoPairs(int* cards) {
    return (cards[0] == cards[1] && cards[2] == cards[3])
        || (cards[0] == cards[1] && cards[3] == cards[4])
        || (cards[1] == cards[2] && cards[3] == cards[4]);
}

bool isOnePair(int* cards) {
    return cards[0] == cards[1] || cards[1] == cards[2] || cards[2] == cards[3] || cards[3] == cards[4];
}

int main() {
    const char* hands[] = {
        "four card", "full house", "straight", "three card", "two pair", "one pair", "null",
    };
    int cards[5];
    while (scanf("%d,%d,%d,%d,%d", &cards[0], &cards[1], &cards[2], &cards[3], &cards[4]) != EOF) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4 - i; j++) {
                if (cards[j] > cards[j + 1]) {
                    int temp = cards[j];
                    cards[j] = cards[j + 1];
                    cards[j + 1] = temp;
                }
            }
        }
        int ret = 6;
        if (isFourCards(cards)) {
            ret = 0;
        } else if (isFullHouse(cards)) {
            ret = 1;
        } else if (isStraight(cards)) {
            ret = 2;
        } else if (isThreeCards(cards)) {
            ret = 3;
        } else if (isTwoPairs(cards)) {
            ret = 4;
        } else if (isOnePair(cards)) {
            ret = 5;
        }
        cout << hands[ret] << endl;
    }
}

Measured memory_bytes: 0
#include "stdio.h"
int main(){
    int L, A, B, C,D,E,F,G,max = 0;
    scanf("%d",&L);
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);
    
    if(A % C != 0){
        F = A/C + 1;

    }else{ F = A/C;

    }
    if(B % D != 0){
        G = B/D + 1;

    }else{ G = B/D;

    }
    
    if(F >= G){
    max = L - F;
    }else if(F < G){
    max = L - G;
    }
    printf("%d\n",max);
}

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

using namespace std;

int main() 
{
    int N,K;
    cin >>N;
    cin >>K;

    vector<bool> okasi(N,false);

    for(int j=0;j<K;++j)
    {
        int d;
        cin >>d;
        for(int i=0;i<d;++i)
        {
            int kasi;
            cin >>kasi;
            if(okasi[kasi-1]==false)
            {
                okasi[kasi-1]=true;
            }
        }
    }

    int itazura=0;
    for(auto o:okasi)
    {
        if(!o)
        {
            ++itazura;
        }
    }

    cout << itazura <<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
using namespace std;
int main() {
	string str;
	cin >> str;
	int a,z;

	for (a = 0;str[a] != '\0';a++) {
		if (str[a] == 'A') {
			break;
		}
	}

	for (int i = 0;str[i] != '\0';i++) {
		if (str[i]=='Z')
			z = i;
	}
	cout << z - a + 1 << endl;

	return 0;
}

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

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = RLong();
        }

        var dp = new List<long>() { A[0] };
        
        for (int i = 1; i < N; i++)
        {
            if (dp.Last() >= A[i])
            {
                dp.Add(A[i]);
                
            }
            else
            {
                var (lb, ub) = (-1, dp.Count);
                while (ub - lb > 1)
                {
                    var mid = (lb + ub) / 2;
                    if (dp[mid]>=A[i]) lb = mid;
                    else ub = mid;
                }
                dp[ub] = A[i];
                
            }
        }
        WriteLine(dp.Count);
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 35084