akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(5*1e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int from, to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/

int n, m;
edge as[2005];
int d[1005];
int bellman_ford() {
	REP(i, n + 1)d[i] = -inf;
	d[1] = 0;
	for (int i = 0; i < n; i++) {
		bool update = false;
		rep(j, m) {
			edge e = as[j];
			if (d[e.from] == -inf)continue;
			if (d[e.to] < d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if (i == n - 1 && e.to == n)return inf;
			}
		}
		if (!update)break;
	}
	return d[n];
}
signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> as[i].from >> as[i].to >> as[i].cost;
	}
	if (bellman_ford() != inf) {
		cout << bellman_ford() << endl;
	}
	else {
		cout << "inf" << endl;
	}
	endre;
}


Measured memory_bytes: 256
//Coin Chaining Problem
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int C[m];
    for(int i=0; i<m; i++) cin >> C[i];
    
    int dp[n+1];
    for(int i=0; i<n+1; i++) {
        dp[i] = i;
        for(int j=0; j<m; j++) {
            if(i-C[j]>=0) dp[i] = min(dp[i], dp[i-C[j]]+1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vs a(9);

int main(){
	a[0]=".,!? ";
	a[1]="abc";
	a[2]="def";
	a[3]="ghi";
	a[4]="jkl";
	a[5]="mno";
	a[6]="pqrs";
	a[7]="tuv";
	a[8]="wxyz";
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		int res=0;
		for(int i=1;i<n;i++){
			int t=i,x=i+1;
			do{
				t+=x;
				x++;
			}while(t<n);
			if(t==n) res++;
		}
		cout<<res<<endl;
	}
}


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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int dp[100010];
const int MOD = (int)1e9+7;

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

    for (int i = 0; i < m; ++i) {
        int a;
        cin>>a;
        dp[a]=-1;
    }

    dp[0]=1;

    for (int i = 0; i <= n; ++i) {
        if(dp[i]==-1)continue;
        if(i+1<=n && dp[i+1]!=-1)(dp[i+1]+=dp[i])%=MOD;
        if(i+2<=n && dp[i+2]!=-1)(dp[i+2]+=dp[i])%=MOD;
    }
    cout<<dp[n]<<endl;


    return 0;
}

Measured memory_bytes: 640
/**
*    author:  yuya1234
*    created: 24.06.2020 15:22:37
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    ll ans=k;

    FOR(i,2,n)
    {
        ans*=k-1;
    }

    cout<<ans<<endl;

    return 0;
}

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

int main()
{
  ll n, m;
  cin >> n >> m;
  ll sum = 0;
  for (ll i = 0; i < m; i++)
  {
    ll a;
    cin >> a;
    sum += a;
  }
  ll ans = n - sum;
  if (ans >= 0)
  {
    cout << ans << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3604
//agc29e remember to finish!
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define nn 200008
#define ll long long
struct favouritethingofhaoo{
	int pa[nn];int siz[nn];
	void build()
	{
		for(int i=1;i<nn;i++)
			pa[i]=i,siz[i]=1;
	}
	void merge(int x,int y)
	{
		x=fin(x);y=fin(y);
		siz[y]+=siz[x];
		pa[x]=y;
	}
	int fin(int x)
	{
		if(pa[x]==x) return x;
		return pa[x]=fin(pa[x]);
	}
}trcyx;
struct fenwicktree{
	int tree[nn];
	void upd(int x,int y)
	{
		x++;
		for(x;x<nn;x+=(x&-x)) tree[x]+=y;
	}
	int ask(int x)
	{
		x++;
		int y=0;
		for(x;x;x-=(x&-x)) y+=tree[x];
		return y;
	}
	int query(int l,int r)
	{
		return ask(r)-ask(l-1);
	}
}bit;
int pa[nn],grandpa[nn];int roadmax[nn];
vector<int> v[nn];
int n;int dfn[nn],siz[nn];int DFN;int dep[nn];
void dfs(int x,int p)
{
	dep[x]=dep[p]+1;
	pa[x]=p;grandpa[x]=pa[p];siz[x]=1;dfn[x]=++DFN;
	roadmax[x]=max(roadmax[p],x);
	for(int i=0;i<v[x].size();i++) if(v[x][i]!=p) dfs(v[x][i],x),siz[x]+=siz[v[x][i]];
}
vector<int> sl[nn];int val[nn];int lit[nn];
void letsinsert(int x)
{
	for(int i=0;i<v[x].size();i++)
	{
		if(lit[v[x][i]])
		{
			if(v[x][i]==pa[x]);
			else trcyx.merge(v[x][i],x);
		}
	}
	int cy=trcyx.siz[x];//cout<<x<<" "<<cy<<"  ";
	if(lit[pa[x]]) trcyx.merge(x,pa[x]);
	int p=trcyx.fin(x);
	lit[x]=1;
//	cout<<dfn[x]<<"  "<<dfn[pa[p]]<<":"<<cy<<"\n";
	bit.upd(dfn[x],+cy);bit.upd(dfn[pa[p]],-cy);
}
int ans[nn];
void efs(int x,int p,int alr)
{
	int sum=0;
	for(int i=0;i<v[x].size();i++) if(v[x][i]!=p)sum+=val[v[x][i]];
	for(int i=0;i<v[x].size();i++)
	{
		if(v[x][i]!=p)
		efs(v[x][i],x,alr+sum-val[v[x][i]]);
	}
//	if(x==6) cout<<sum<<" "<<alr<<"\n";
	ans[x]=alr+sum;
}
int main()
{	
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		v[x].push_back(y);v[y].push_back(x);
	}
	dfs(1,0);trcyx.build();
	for(int i=2;i<=n;i++)
//	cout<<i<<","<<grandpa[i]<<":"<<roadmax[i]<<"\n",
		sl[roadmax[grandpa[i]]].push_back(i);//if grandpa is 0 then no need
	for(int ii=1;ii<=n;ii++)
	{
		letsinsert(ii);//cout<<ii<<":";
		for(int i=0;i<sl[ii].size();i++)
		{
			int x=sl[ii][i];
		//	cout<<x<<":"<<dfn[x]<<"  "<<dfn[x]+siz[x]-1<<"  "<<bit.query(dfn[x],dfn[x]+siz[x]-1)<<"\n";
			if(x<ii) val[x]=bit.query(dfn[x],dfn[x]+siz[x]-1);
		}//cout<<"\n";
	}
//	for(int i=1;i<=n;i++) cout<<val[i]<<" ";
	efs(1,0,0);
	for(int i=2;i<=n;i++) printf("%d ",ans[i]+dep[i]-1);
    return 0;
}

Measured memory_bytes: 43128
#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>
#include <complex>
#include <bitset>

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-12;
ld PI = acos(-1.0);

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1] == 's') s += "es";
    else s += 's';
    cout << s << endl;
    return;
}

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

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int n = S.length();
		long mod = (long)Math.pow(10, 9) + 7;
		long[][] dp = new long[n + 1][4];
		dp[0][0] = 1;
		for(int i = 1; i <= n; i++) {
			char c = S.charAt(i - 1);
			for(int j = 0; j < 4; j++) {
				dp[i][j] = dp[i - 1][j];
				dp[i][j] %= mod;
				if(c == '?') {
					dp[i][j] *= 3;
				}
			}
			if(c == '?') {
				for(int j = 1; j < 4; j++) {
					dp[i][j] += dp[i - 1][j - 1];
				}
			}else {
				dp[i][(int)(c - 'A') + 1] += dp[i - 1][(int)(c - 'A')];
			}
		}
		System.out.println(dp[n][3] % mod);
	}
}

Measured memory_bytes: 30972
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
const int N=1e6+10;
int n,m,k;
int main()
{
	double r;
	cin >> r;
	cout <<2*r*M_PI<<endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >>N;
    string  W[110];
    string  memo[110];
    for(int i = 0;i < N;i++) cin >> W[i];
    bool frag = 1;
    memo[0] = W[0];
    
    for(int i = 1;i < N;i++){
        bool frag2 = 1;
        for(int j = 0;j < i;j++){
            if(memo[j] == W[i]) frag = 0;
        }
        memo[i] = W[i];
        if(W[i-1][W[i-1].size() - 1] != W[i][0]) frag2 = 0;
        if(frag2 == 0) frag = 0;
    }
    if(frag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef signed long long ll;
typedef long double ld;

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

#define DEBUG

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

	ll min = (ll)1e18;
	for(ll i = 1; i <= sqrt(n); i++)
	{
		if((n % i) == 0 && ((n/i) + i - 2) < min)
		{
			//cout << i << "\t" << n/i << endl;
			min = (i + (n/i)) - 2;
		}
	}
	cout <<	min << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//#define MOD 1000000007
//#define MOD 998244353
#define MOD 2019
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

void add(int &a, int b){
  a = ((a+b) % MOD + MOD) % MOD;
}

inline int mul(int a, int b) {
    add(a,0); add(b,0);
    #if !defined(_WIN32) || defined(_WIN64)
      return (int) ((long long) a * b % MOD);
    #endif
      unsigned long long x = (long long) a * b;
      unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
      asm(
        "divl %4; \n\t"
        : "=a" (d), "=d" (m)
        : "d" (xh), "a" (xl), "r" (MOD)
      );
      return m;
}

inline int modpow(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
      }
      a = mul(a, a);
      b >>= 1;
  }
  return res;
}

inline int inv(int a) {
    a %= MOD;
    if (a < 0) a += MOD;
    int b = MOD, u = 0, v = 1;
    while (a) {
      int t = b / a;
      b -= t * a; swap(a, b);
      u -= t * v; swap(u, v);
    }
    assert(b == 1);
    if (u < 0) u += MOD;
    return u;
}

inline int modstoll(string s){
  int ans = 0;
  RREP(i, (int)ceil(s.length() / 17.0)){
    int t = min((int)s.length() - i * 17, 17ll);
    ans += stoll(s.substr(i * 17, t % MOD)) * modpow(10, i * t);
  }
  return ans;
}
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  string s;
  cin >> s;

  vec a(2019, 0);
  a[0]++;//Tn mod 2019 == 0
  
  int t = 0;
  REP(i, s.length()){
    const char c = s[s.length() - i - 1];
    t += atoll(&c) * modpow(10, i);
    a[t % 2019]++;
  }

  int ans = 0;
  REP(i, a.size()){
    ans += a[i] * ( a[i] - 1 ) / 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3736
N=int(input())

def calc_factors(N):
    n = int(N**.5)
    arr = []
    tmp = N
    for i in range(2,n+1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp = int(tmp/i)
    if tmp != 1: arr.append(tmp) 
    return list(set(arr))
if calc_factors(N) == [N]:
    print(N-1)
else:
    res = N
    for i in calc_factors(N):
        res = res*(1 - i**(-1))
    print(int(res))



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

int main(){
  int64_t n;
  cin >> n;
  
  int k = to_string(n).length();
  int sum = 0;
  int tmp = n;
  
  int64_t d;
  for(int i = k; i > 0; i--){
    d = (int64_t) pow(10, i - 1);
    sum += tmp / d;
    tmp %= d;
  }
  string val = n % sum == 0 ? "Yes" : "No";
  cout << val << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())


def f(x):
    xx = bin(x)[2:]
    res = ''
    for c in xx[:-1]:
        if c == '1':
            if xx[-1] == '1':
                res += '0'
            else:
                res += '1'
        else:
            res += '0'
    if (x - 1) % 4 < 2:
        res += '1'
    else:
        res += '0'
    return res


a = f(a - 1)
b = f(b)
n = max(len(a), len(b))
a = a.rjust(n, '0')
b = b.rjust(n, '0')
c = ''
for x, y in zip(a, b):
    if x == y:
        c += '0'
    else:
        c += '1'
print(int(c, 2))

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

int main(){
  int n, k;
  cin >> n >> k;
  ll ans = 0;
  for(int i=k+1; i<=n; ++i){
    int x = n /i *i;
    ans += x /i * (i-k);
    if(x != n) ans += max(0, (n-x) -max(1,k) +1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int r;
  cin >> r;
  if (r <= 1199)
    cout << "ABC" << endl;
  else if (r <= 2799)
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

int s[20000],p[150][150];

int main ()
{ 
	int h,w,n,o=1,q=0,a; 
	scanf ("%d%d%d",&h,&w,&n); 
	for (int i=1;i<=n;i++)
		scanf ("%d",&s[i]);
	for (int i=1;i<=h;i++) 
	{  
		for (int j=1;j<=w;j++)
		{
			if (i%2)
				p[i][j]=o;
			else
				p[i][w-j+1]=o;
			s[o]--;
			if (s[o]==0) o++;
		} 
	}
	for (int i=1;i<=h;i++)
	{
		for (int j=1;j<=w;j++)
			printf ("%d ",p[i][j]);
		printf ("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int q;
  cin>>q;
  set<int> s;
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    if(a==0){
    s.insert(b);
    cout<<s.size()<<endl;
    }
    if(a==1){
      if(s.find(b)!=s.end()) cout<<"1"<<endl;
      else cout<<"0"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 12472
//close stdin
//https://codeforces.com/problemset?order=BY_RATING_ASC&tags=binary+search%2C1300-
#include <bits/stdc++.h>
using namespace std;
long long  gcd(long long  a, long long b){ 
	if (a == 0) 
		return b;  
	return gcd(b % a, a);  
	} 
long long lcmm(long long a,long long b){
	
return (a*b)/gcd(a, b);
}
	
int mod=998244353;
long long summ(long long x){
	long long ans=0;
	while(x!=0){
		ans+=(x%10);
		x=x/10;
	}
	return ans;
	
}
bool prime[1000003]; 
void SieveOfEratosthenes() 
{ 
	int n=1000002;
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 

} 



long long INF=1000000000000;
//long long INF=1000;
int main(){
//	freopen ("t.txt","r",stdin);
	string s,t;
	cin>>s;
	cin>>t;
	//cout<<s<<"\n";
	//cout<<t;
	int ss=s.size(),tt=t.size();
	vector<vector<long long >> cost(ss+1,vector<long long >(tt+1,0));
	//int curr=0;
	int n=min(ss,tt);
	vector<char> ans; 
	//int curr=0;
	for(int i=0;i<ss+1;i++){
		for(int j=0;j<tt+1;j++){
			if(i==0 || j==0){
				//cout<<cost[i][j];
				continue;
			}

				
			if(s[i-1]==t[j-1]){
				cost[i][j]=cost[i-1][j-1]+1;
				//cout<<s[i-1]<<t[j-1];
				//ans.push_back(make_pair(i-1,j-1));
				//cout<<cost[i][j]<<;
					
			}

			else{
				cost[i][j]=max(cost[i-1][j],cost[i][j-1]);
			}	
		//cout<<cost[i][j];		
		}
		//cout<<"\n";
	}
	int j=tt;
	for(int i=ss;i>=1 && j>=1;){
		if(j==0 || i==0)
			break;

		// cout<<i<<" "<<j<<"\n";
		// if(i==0)
		// 	break;
		if(s[i-1]==t[j-1]){
			ans.push_back(s[i-1]);
			
			i--;
			j--;
		}
		else{
			if(cost[i-1][j]>cost[i][j-1]){
				i--;
			}
			else
			{
				j--;
			}
			
		}

	}
	for(int i=ans.size()-1;i>=0;i--)
		cout<<ans[i];



	

	



return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    
    if(n==m ){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 120
using namespace std;

int a[N];

int main(void)
{
    int n;
    int i, o;

    cin >> n;
    for(i = 1; i < n; i ++)
        cin >> a[i];

    for(i = 1, o = 0; i <= n; i ++)
        if(i == 1)
            o += a[i];
        else if(i == n)
            o += a[n - 1];
        else
            o += min(a[i - 1], a[i]);
    cout << o << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int n,x;
int count;
int main()
{
	while(1)
	{
		count=0;
		cin>>n>>x;
		if(n==0)break;
		rep2(i,1,n+1)
		{
			rep2(j,i+1,n+1)
			{
				rep2(k,j+1,n+1)
				{
					if(i+j+k==x)count++;
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

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

int main()
{
    long long n, s, mid;
    cin >> n;
    mid = n / 2;
    for (long long i = 1; i <= mid; i++) {
        long long k = n / i;
        s += k * (k + 1) / 2 * i;
    }
    s += (mid + 1 + n) * (n - mid) / 2;
    cout << s << endl;
    return 0;
}

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

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll x,y;

int main() {
    std::cin >> x>>y;
    std::cout << x + y/2 << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;


int n, t = 0;
vector<int> g[105];
bool seen[105];
int d[105], f[105];

void dfs(int v){
    seen[v] = true;
    d[v] = t;
    for(int nv : g[v]){
        if(seen[nv]) continue;
        t++;
        dfs(nv);
    }
    t++;
    f[v] = t;
}

int main(){
    cin >> n;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        rep(j, b){
            int c;
            cin >> c;
            g[a].push_back(c);
        }
    }
    rep(k, n) g[0].push_back(k + 1);

    memset(seen, 0, sizeof(seen));
    dfs(0);

    for (int i = 1; i <= n; i++){
        cout << i << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
            int n = Integer.parseInt(in.readLine());
            double x[] = Arrays.stream(in.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
            double y[] = Arrays.stream(in.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();

            double abs[] = new double[n];
            for (int i = 0; i < n; i++) {
                abs[i] = Math.abs(x[i] - y[i]);
            }

            double p1 = Arrays.stream(abs).sum();
            double p2 = Math.sqrt(Arrays.stream(abs).map(d -> Math.pow(d, 2)).sum());
            double p3 = Math.pow(Arrays.stream(abs).map(d -> Math.pow(d, 3)).sum(), 1.0 / 3.0);
            double pInf = Arrays.stream(abs).max().getAsDouble();

            System.out.printf("%.6f\n", p1);
            System.out.printf("%.6f\n", p2);
            System.out.printf("%.6f\n", p3);
            System.out.printf("%.6f\n", pInf);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 31784
#include"bits/stdc++.h"
using namespace std;

int main() {

	int N;
	cin >> N;

	int p,price[10],ans;
	int sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> p;
		price[i] = p;
	}

	sort(price, price + N);

	for (int i = 0; i < N - 1; i++) {
		sum += price[i];
	}

	ans = sum + (price[N - 1] / 2);

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define forn(i,n) for(int i=0;i<int(n);i++)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
typedef long long int ll;
void solve()
{
	ll s=0;
	int n;
	cin>>n;
	fora(i,1,n)
	{
		if(i%3==0&&i%5==0);
		else if(i%3==0);
		else if(i%5==0);
		else s+=i;
	}
	cout<<s<<endl;
}
int main()
{
   
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
   	solve();
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int large = Math.max(A, B);
      int small = Math.min(A, B);
      int X = large--;

      if (large < small) {
          X += small;
      } else {
          X += large;
      }

      System.out.println(X);
    }
  }
}

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

using namespace std;

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

  int a, b;
  cin >> a >> b;
  for (int it = 1; it < 1e6; ++it) {
    if (int(it * 0.08) == a and int(it * 0.1) == b) {
      cout << it;
      return 0;
    }
  }
  cout << -1;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lint;
int main() {
	vector<int>vec(3);
	for (int ia = 0; ia < 3; ia++) {
		cin >> vec.at(ia);
	}
	sort(vec.begin(), vec.end());
	int K;
	cin >> K;
	cout << vec.at(0) + vec.at(1) + vec.at(2)*pow(2, K) << endl;
}



	


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

using namespace std;

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

	long long A[N];

	for (int n=0; n<N; n++){
		cin >> A[n];
	}

	int BIT_MAX = 64;

	vector<int> zero_count(BIT_MAX, 0);
	vector<int> one_count(BIT_MAX, 0);

	for (int n=0; n<N; n++){
		for (int b=0; b<BIT_MAX; b++){
			if(A[n] & (1ull << b)){
				one_count[b] += 1;
			}
			else{
				zero_count[b] += 1;
			}
		}
	}
	vector<int> K_bit(BIT_MAX);
	for (int b=0; b<BIT_MAX; b++){
		if(K & (1ull << b)){
			K_bit[b] = 1;
		}
		else{
			K_bit[b] = 0;
		}
	}

	bool flag = false;

	long long ans = 0;

	for (int b=BIT_MAX-1; b>=0; b--){
		if (flag){
			ans += (1ull << b) * max(zero_count[b], one_count[b]);
		}
		else{
			if (K_bit[b] == 0){
				ans += (1ull << b) * one_count[b];
			}
			else{
				if (zero_count[b] > one_count[b]){
					ans += (1ull << b) * zero_count[b];
				}
				else{
					ans += (1ull << b) * one_count[b];
					flag = true;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <set>

using namespace std;

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

	vector<vector<int>> cumuls(n + 1, vector<int>(3, 0));

	for (int i = 1; i <= n; i++) {
		cumuls[i] = cumuls[i-1];
		switch (s[i-1]) {
			case 'R': cumuls[i][0]++; break;
			case 'G': cumuls[i][1]++; break;
			case 'B': cumuls[i][2]++; break;
			default: break;
		}
	}

	// for (int i = 0; i <= n; i++) {
	// 	for (int j = 0; j < 3; j++) {
	// 		printf("%2d ", cumuls[i][j]);
	// 	}
	// 	printf("\n");
	// }

	set<char> base = {'R', 'G', 'B'};
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j]) {
				continue;
			}

			auto check = base;
			check.erase(s[i]);
			check.erase(s[j]);

			int idx = 0;
			char c = *check.begin();
			switch (c) {
				case 'R': idx = 0; break;
				case 'G': idx = 1; break;
				case 'B': idx = 2; break;
				default: break;
			}

			ans += cumuls[n][idx] - cumuls[j+1][idx];

			int y = j + j - i;
			if (y < n && s[y] == c) {
				ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3392
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL s;
    cin >> s;
    vector<LL> a(2010,0);
    a[0]=1;
    a[1]=0;
    a[2]=0;
    a[3]=1;
    a[4]=1;
    a[5]=1;
    for(LL i=6; i<=s; i++){
        for(LL j=0; j<=i-3; j++){
            a[i]=(a[i]+a[j])%MOD;
        }
    }

    cout << a[s] << endl;

    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a==1) a+=13;
		if(b==1) b+=13;
		if(a==b) System.out.println("Draw");
		else if(a>b ) System.out.println("Alice");
		else System.out.println("Bob");
		

	}

}


Measured memory_bytes: 27028
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}
int num[100000];
bool fl[100000];
int main(void){
    int n, m; cin >> n >> m; fill(num, num+n, 1); fill(fl, fl+n, false);
    fl[0] = true;
    for(int i = 0;i < m;i++){
        int x, y; cin >> x >> y; x--; y--;
        num[x]--; num[y]++;
        if(fl[x]){
            fl[y] = true;
            if(num[x] == 0)fl[x] = false;
        }
    }
    int ans = 0;
    for(int i = 0;i < n;i++)if(fl[i])ans++;
    cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 768
N, T = map(int, input().split())

Times = list(input().split())
time = 0

for i in range(N - 1):
    if int(Times[i]) + T <= int(Times[i + 1]):
        time += T
    else:
        time = time + (int(Times[i + 1]) - int(Times[i]))

print(time + T)


Measured memory_bytes: 20856
#include <stdio.h>

int main(){
    int n,d;
    int x[101]={0};
    int ans=0;

    scanf("%d",&n);

    for (int i=0;i<n;i++){
	scanf("%d",&d);
	if (x[d] == 0){
	    x[d]=1;
	    ans++;
	}
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
	
	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int n,k;
			int index;
			String s,s1,c,c2,s2,result;
			n = sc.nextInt();
			k = sc.nextInt();
			s = sc.next();
			s1=s.substring(0,k-1);
			c=s.substring(k-1,k).toLowerCase();
			s2=s.substring(k,s.length());
			result=s1.concat(c).concat(s2);
			// 出力

			System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  ll n,count =0;
  cin >> n ;
  string s;
  cin >> s;
  for(ll i=0;i<s.size()-2;i++){
    if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C')){
      count++ ;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
use std::io;


fn main() {
    let n = read_one::<usize>();

    let mut w = Vec::new();
    for _ in 0..n {
        let s = read_one::<String>();
        w.push(s.chars().collect::<Vec<char>>());
    }

    let mut ans = true;
    for i in 0..n {
        for j in 0..n {
            if i == j { continue; }
            if w[i] == w[j] { ans = false; }
        }
        if i > 0 {
            if w[i][0] != w[i - 1][w[i - 1].len() - 1] { ans = false; }
        }
    }

    if ans { println!("Yes"); }
    else { println!("No"); }
}

#[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: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ll n,m;
  cin >> n >> m;
  ll i;
  for (i = m/n; i > 0; i--)
  {
    if (!(m%i))
      break;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
def solve(k, length, MOD, div, dp):
    for i in range(1, k + 1):
        dp[0] = dp[0] * 25 * div * (length + i - 1) * pow(i, -1, MOD) % MOD
        dp[1] = (dp[1] + dp[0]) % MOD

    return(dp[1])


k = int(input())
s = input()
length = len(s)
MOD = 10**9 + 7
div = pow(26, -1, MOD)

dp = [pow(26, k, MOD)] * 2

print(solve(k, length, MOD, div, dp))

Measured memory_bytes: 10932
import scala.io.Source.stdin

object Main {

  def count(n:Double,a:Array[Int]) = {
                if(n >= 1.1) a(0) += 1
                else if(n < 1.1 && n >= 0.6) a(1) += 1
                else if(n < 0.6 && n >= 0.2) a(2) += 1
                else if(n < 0.2) a(3) += 1
  }

  def main(args:Array[String]) = {
    val r = new Array[Int](4)
    val l = new Array[Int](4)
    stdin.getLines.foreach { s=>
      val n = s.split(" ").map(_.toDouble)
      count(n(0),r)
      count(n(1),l)
    }
    (0 to 3).foreach { i => println(r(i) + " " + l(i)) }
  }
}

Measured memory_bytes: 43764
x, k, d = map(int, input().split())
x = abs(x)
n = x // d

if n <= k:
    k -= n
    x -= n * d
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x - d), abs(x + d)))
else:
    print(abs(x - (k * d)))

Measured memory_bytes: 9112
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a1[110000];
int a2[110000];
int aa1[110000];
int aa2[110000];
map<int,set<int> > mp;
set<int> used;

int main()
{
  int i,j,k,n,xo1,xo2,f,x,ans;
  vector<int> q;
  scanf("%d",&n);
  xo1=0;
  for (i=0;i<n;i++)
  {
    scanf("%d",&a1[i]);
    xo1^=a1[i];
  }
  xo2=0;
  for (i=0;i<n;i++)
  {
    scanf("%d",&a2[i]);
    xo2^=a2[i];
  }
  a1[n]=xo1;
  a2[n]=xo2;
  memcpy(aa1,a1,sizeof(a1));
  memcpy(aa2,a2,sizeof(a2));
  sort(aa1,aa1+n+1);
  sort(aa2,aa2+n+1);
  for (i=0;i<=n;i++)
    if (aa1[i]!=aa2[i])
    {
      printf("-1\n");
      return 0;
    }
  n++;
  mp.clear();
  ans=0;
  for (i=0;i+1<n;i++)
  {
    if (a1[i]!=a2[i])
    {
      mp[a1[i]].insert(a2[i]);
      mp[a2[i]].insert(a1[i]);
      ans++;
    }
  }
  //cout<<ans<<endl;
  used.clear();
  for (map<int,set<int> >::iterator it=mp.begin();it!=mp.end();it++)
  {
    if (used.find(it->first)==used.end())
    {
      q.clear();
      q.push_back(it->first);
      if (used.find(a1[n-1])==used.end()) f=1;
      else f=0;
      used.insert(it->first);
      for (i=0;i<q.size();i++)
      {
        x=q[i];
        for (set<int>::iterator it2=mp[x].begin();it2!=mp[x].end();it2++)
        {
          if (used.find(*it2)==used.end())
          {
            used.insert(*it2);
            q.push_back(*it2);
          }
        }
      }
      if (q.size()>1)
        ans++;
      if ((f==1)&&(used.find(a1[n-1])!=used.end()))
        ans--;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 25720
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int x;
    cin >> x;
    for (auto n : {3, 5, 7}) {
        if (x == n) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void) {
	int x1, y1;
	int x2, y2;
	int x3, y3;
	int x4, y4;
	int d;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x3 - (x2 - x1);
	y4 = y3 - (y2 - y1);
	printf("%d %d %d %d", x3, y3, x4, y4);

	return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
l = []
for i in range(n):
    a = list(map(int, input().split()))
    l.append(a)
l.sort()
ans = 0

for i in range(n):
    if l[i][1] <= m:
        m -= l[i][1]
        ans += l[i][0] * l[i][1]
    else:
        ans += m * l[i][0]
        break

print(ans)


Measured memory_bytes: 27760
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int n;
string s[100];
string ans="Yes";
int main()
{
	cin >> n;
	string first;
	for (int i = 0; i < n; i++) {

		cin >> s[i];
		if (i > 0 && first != s[i].substr(0, 1))ans = "No";
		first = s[i].substr(s[i].length() - 1);
		for (int j = 0; j < i; j++) {
			if (s[i] == s[j])ans = "No";
		}
	}

	cout << ans << endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL h(n);
	cin >> h;
	for (int i = 1; i < n; i++) {
		if (h[i-1] > h[i]) {
			h[i]++;
		}
 	}
	for (int i = 0; i < n-1; i++) {
		if (h[i] > h[i+1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1024
import math

def lp_norm(x,y,p):
    if p==float("inf"):
        z=[]
        for i in range(len(x)):
            z.append(abs(x[i]-y[i]))
        return max(z)
        
    else:
        z=[]
        for i in range(len(x)):
            z.append(math.pow(abs(x[i]-y[i]),p))
            
        s=sum(z)
            
        return math.pow(s,1.0/p)
        

def run():
    
    n=input()
    x=list(map(float,input().split()))
    y=list(map(float,input().split()))
    
    p=float("inf")
    print(f"{lp_norm(x,y,1.0)}")
    print(f"{lp_norm(x,y,2.0)}")
    print(f"{lp_norm(x,y,3.0)}")
    print(f"{lp_norm(x,y,p)}")
        
run()


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

static const int N = 100;

int main() {
  int M[N][N];
  int n, u, k, v;

  cin >> n;

  for (int i = 0; i < n; i ++) {
    for (int j = 0; j < n; j ++) M[i][j] = 0;
  }

  for (int i = 0; i < n; i ++) {
    cin >> u >> k;
    u --;
    for (int j = 0; j < k; j ++) {
      cin >> v;
      v --;
      M[u][v] = 1;
    }
  }

  for (int i = 0; i < n; i ++) {
    for (int j = 0; j < n; j ++) {
      if (j) cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3080
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int N[4], L[4], S[4], l, s, i, num;
	char input[5];
	
	while (1){
		scanf("%s", input);
		
		for (i = 0; i < 4; i++){
			N[i] = input[i] - '0';
		}
		
		if (input[0] == '0' && input[1] == '0' && input[2] == '0' && input[3] == '0'){
			break;
		}
		
		if (input[0] == input[1] && input[0] == input[2] && input[0] == input[3]){
			printf("NA\n");
			continue;
		}
		
		num = 0;
		while (1){
			if (N[0] == 6 && N[1] == 1 && N[2] == 7 && N[3] == 4){
				break;
			}
			
			for (i = 0; i < 4; i++){
				L[i] = N[i];
				S[i] = N[i];
			}
			
			sort(L, L + 4);
			reverse(L, L + 4);
			sort(S, S + 4);

			for (i = 3; i >= 0; i--){
				N[i] = L[i] - S[i];
				if (N[i] < 0){
					N[i] += 10;
					L[i - 1]--;
				}
			}
			
			num++;
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 996
N, K = map(int,input().split())

s = {}

for _ in range(N):
    a, b = map(int,input().split())
    if str(a) in s.keys():s[str(a)] +=b
    else:s[str(a)]=b

s_key = list(s.keys())
s_key_int = [int(i) for i in s_key]
s_key_int.sort()

cnt = 0
num = 0

for j in s_key_int:
    cnt += s[str(j)]
    if cnt >= K:
        num=j
        break
print(j)

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

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    vector<vector<Int> > G(100);
    for(Int i=0;i<n;i++){
      Int a,b;
      cin>>a>>b;
      a--;b--;
      G[a].emplace_back(b);
      G[b].emplace_back(a);
    }
    for(Int i=0;i<100;i++){
      sort(G[i].begin(),G[i].end());
      G[i].erase(unique(G[i].begin(),G[i].end()),G[i].end());
    }
    Int ans=1;
    auto calc=[&](Int s){
      vector<int> used(100,0);
      function<void(int,int)> dfs=[&](int v,int d){
	chmax(ans,d+1);
	for(int u:G[v]){
	  if(used[u]) continue;
	  used[u]=1;
	  dfs(u,d+1);
	  used[u]=0;
	}
      };
      used[s]=1;
      dfs(s,0);
    };
    
    for(Int i=0;i<100;i++) calc(i);
    cout<<ans<<endl;
  }
  
  return 0;
}



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

int main()
{
  int n, tmp;
  ll ans = 0;
  cin >> n;
  vector<int> l;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    l.push_back(tmp);
  }
  sort(l.begin(), l.end());
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      int border = distance(l.begin() + j + 1, lower_bound(l.begin(), l.end(), l[i] + l[j]));
      ans += border;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=20010;
const int M=40000010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
int n,cnt;
int x[N],y[N];
int bgn[N],nxt[M],to[M],E;
int dfn[N],low[N],dfs_time;
int bel[N],st[N],top,in[N];
int scc_cnt;
struct node
{
	int pos,id,type;
	node(){}
	node(int pos,int id,int type):pos(pos),id(id),type(type){}
}a[N];
inline bool operator<(node A,node B){return A.pos<B.pos;}
inline void add_edge(int u,int v)
{
	//printf("%d %d\n",u,v);
	nxt[++E]=bgn[u],bgn[u]=E,to[E]=v;
}
inline void dfs(int u)
{
	dfn[u]=low[u]=++dfs_time;
	in[st[++top]=u]=1;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if(!dfn[v=to[i]])
		{
			dfs(v);
			chkmin(dfn[u],low[v]);
		}
		else if(in[v])chkmin(dfn[u],dfn[v]);
	}
	if(low[u]==dfn[u])
	{
		++scc_cnt;
		int x;
		do
		{
			x=st[top--];
			in[x]=0;
			bel[x]=scc_cnt;
		}while(x!=u);
	}
}
inline bool check(int x)
{
	mem(dfn,0);
	mem(bgn,0);
	mem(bel,0);
	E=0;
	scc_cnt=0;
	dfs_time=0;
	int nowl=1,nowr=1;
	For(i,1,cnt)
	{
		while(nowl<cnt&&a[nowl].pos<=a[i].pos-x)nowl++;
		while(nowr<cnt&&a[nowr+1].pos<a[i].pos+x)nowr++;
		For(j,max(i-50,nowl),i)
		if(i!=j)
		{
			add_edge(a[i].id*2+a[i].type,a[j].id*2+(a[j].type^1));
			add_edge(a[j].id*2+a[j].type,a[i].id*2+(a[i].type^1));
		}
		For(j,i,min(i+50,nowr))
		if(i!=j)
		{
			add_edge(a[i].id*2+a[i].type,a[j].id*2+(a[j].type^1));
			add_edge(a[j].id*2+a[j].type,a[i].id*2+(a[i].type^1));
		}
	}
	For(i,1,n)
	{
		if(!dfn[i*2])dfs(i*2);
		if(!dfn[i*2+1])dfs(i*2+1);
	}
	For(i,1,n)if(bel[i*2]==bel[i*2+1])return 0;
	return 1;
}
int main()
{
	//file();
	read(n);
	int MAX=0;
	For(i,1,n)
	{
		read(x[i]),read(y[i]);
		a[++cnt]=node(x[i],i,0);
		a[++cnt]=node(y[i],i,1);
		chkmax(MAX,x[i]),chkmax(MAX,y[i]);
	}
	sort(a+1,a+cnt+1);
	int l=1,r=MAX/(n-1),ans=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 37504
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
char a,b; cin>>a>>b;
if(a>b) cout<<">";
else if (b>a) cout<<"<";
else cout<<"=";
return 0;
}

Measured memory_bytes: 256