akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define MAX(a,b) (((a)>(b))?a:b)

LL dp[100001][3];
//LL c=0;
LL val[100001][3];

LL cal(LL i,LL j)
{
    //cout<<"FUNCTION ENTERED \n";
    //c++;

    if(i==0)
    {
        return 0;
    }
    else
    {
        if(dp[i][j]=-1)
        {

                if(dp[i-1][(j+1)%3]==-1)
                {
                    dp[i-1][(j+1)%3]=cal(i-1,(j+1)%3);
                }
                if(dp[i-1][(j+2)%3]==-1)
                {
                    dp[i-1][(j+2)%3]=cal(i-1,(j+2)%3);
                }
                dp[i][j]=val[i][j]+MAX(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
            
        }
        return dp[i][j];
    }
    
    
}

int main()
{
    LL n,i,j,k;
    cin>>n;
    for(i=0;i<100001;i++)
    {
        for(j=0;j<3;j++)
        {
            dp[i][j]=-1;
            val[i][j]=-1;
        }
    }

    for(i=1;i<=n;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>val[i][j];
        }
    }
    
    //cout<<val[n][0]<<" "<<val[n][1]<<" "<<val[n][2]<<endl;

    dp[n][0]=val[n][0]+MAX(cal(n-1,2),cal(n-1,1));
    //cout<<(MAX(cal(n-1,2),cal(n-1,1)))<<endl;
    dp[n][1]=val[n][1]+MAX(cal(n-1,0),cal(n-1,2));
    dp[n][2]=val[n][2]+MAX(cal(n-1,0),cal(n-1,1));

    //cout<<val[n][0]<<" "<<val[n][1]<<" "<<val[n][2]<<endl;

    //cout<<dp[n][0]<<" "<<dp[n][1]<<" "<<dp[n][2]<<endl;
    LL ans=MAX(MAX(dp[n][0],dp[n][1]),dp[n][2]);
    //cout<<"VALUE OF c is "<<c<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9600
using System;
using System.Linq;

class Atcoder
{
    static void Main(string[] args)
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int b = a[0] + a[1] + a[2];
        if (b >= 22)
        {
            Console.WriteLine("bust");
        }
        else
        {
            Console.WriteLine("win");
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int n;
ll cnt[MAXN];
ll a[MAXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	mset(cnt,0);
	
	cin>>n;
	forn(i,0,n){
		int x; cin>>x;
		a[i]=x;
		cnt[x]++;
	}
	
	if(cnt[0]!=1 || a[0]!=0){
		cout<<0<<'\n';
		return 0;
	}
	
	ll ans=1;
	forn(i,1,n){
		ans*=cnt[a[i]-1];
		ans%=MOD;
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        ArrayList<Dish> dishes = new ArrayList<Dish>();
        for(int i = 0; i < 5; i++){
            dishes.add(new Dish(sc.nextInt()));
        }
        Collections.sort(dishes, (a,b) -> a.mod10 - b.mod10);
        int ans = 0;
        int i = 0;
        for(Dish d : dishes){
            ans += d.t;
            if(i != 4){
                ans += d.mod10;
            }
            i++;
        }
        System.out.println(ans);
    }
}

class Dish{
    int t, mod10;
    public Dish(int t){
        this.t = t;
        mod10 = (10 - (t%10)) % 10;
    }
}


Measured memory_bytes: 26708
n,m,l=[int(x) for x in input().split()]
A=[[0 for _ in range(m)] for _ in range(n)]
B=[[0 for _ in range(l)] for _ in range(m)]
C=[[0 for _ in range(l)] for _ in range(n)]
for i in range(n):
    A[i]=[int(x) for x in input().split()]
for i in range(m):
    B[i]=[int(x) for x in input().split()]
B_transpose=list(map(list,zip(*B)))
for i in range(n):
    for j in range(l):
        C[i][j]=sum([x*y for x,y in zip(A[i],B_transpose[j])])
    print(" ".join([str(x) for x in C[i]]))

Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    string s;
    cin >> s;
    if(a>b) {
        swap(a,b);
        swap(c,d);
    } //aは常にbより小さい
    if(c<a||d<b){
        cout << "No" << endl;
        return 0;
    }
    for(int i=a+1; i<c; i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=b+1; i<d; i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(c<d){
        cout << "Yes" << endl;
        return 0;
    }
    if(c>d){
        int fi = max(b-1,a);
        int la = min(d-1,c-2);
        for(int i=fi; i<=la; i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){

char moji[4];

scanf("%s", moji);
if(moji[0] != moji[1] && moji[1] != moji[2] && moji[0] != moji[2]){
 		printf("Yes\n");
}
else{
printf("No\n");
}
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////
int main(){
    int n,a,b;
    cin >> n >> a >> b;

    if((a+b)%2 == 0)P("Alice");
    else P("Borys");
	return  0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
bool used[30001];

int main() {
    scanf("%d", &n);
    if (n == 3) {
        cout << "2 5 63" << endl;
        return 0;
    }
    int sum2 = 0, sum3 = 0;
    for (int i = 1; i <= 30000; ++i) {
        if (i % 2 == 0 || i % 3 == 0) {
            if (n > 0) {
                --n;
                used[i] = true;
                sum2 = (sum2 + i) % 2;
                sum3 = (sum3 + i) % 3;
            }
        }
    }
//    cerr << sum2 << ' ' << sum3 << endl;
    while (sum2 > 0) {
        for (int i = 6; i < 30000; i += 3) {
            if (used[i] && !used[i + 3]) {
                sum2 = (sum2 + 3) % 2;
                used[i] = false;
                used[i + 3] = true;
                break;
            }
        }
    }
    while (sum3 > 0) {
        for (int i = 4; i < 30000; i += 2) {
            if (used[i] && !used[i + 2]) {
                sum3 = (sum3 + 2) % 3;
                used[i] = false;
                used[i + 2] = true;
                break;
            }
        }
    }
//    cerr << "OK" << endl;
    for (int i = 1; i <= 30000; ++i) {
        if (used[i]) {
            printf("%d ", i);
        }
    }
    puts("");
    return 0;
}


Measured memory_bytes: 384
#include <string>
#include <vector>
#include <iostream>
using namespace std;
const vector<vector<int> > r = {
	{5, 1, 3, 4, 6, 2},
	{4, 2, 1, 6, 5, 3},
	{2, 6, 3, 4, 1, 5},
	{3, 2, 6, 1, 5, 4}
};
int n; string s;
int main() {
	while (cin >> n, n) {
		vector<int> a = { 1, 2, 4, 3, 5, 6 };
		for (int i = 0; i < n; i++) {
			cin >> s;
			int d = 0;
			if (s[0] == 'e') d = 1;
			if (s[0] == 's') d = 2;
			if (s[0] == 'w') d = 3;
			vector<int> b = a;
			for (int j = 0; j < 6; j++) b[j] = a[r[d][j] - 1];
			a = b;
		}
		cout << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
// #[warn(dead_code)]
// const TOP: u64 = 1000000007;

pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace<'a>) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());

	let a: u64 = iter.read();
	let p: u64 = iter.read();

	let pi = (a * 3 + p) / 2;

	println!("{}", pi);
	// use std::collections::BTreeMap;
}


Measured memory_bytes: 4352
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int L, R, d;
    cin >> L >> R >> d;
    int x = R / d;
    int y = (L - 1) / d;
    cout << x - y << endl;

    return 0;
}


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

 
int main() {
   int n;
   cin>>n;
   int B[n-1];
   rep(i,n-1)cin>>B[i];

   int ans=0;
   //a1とanはb1とbn-1に等しいので
   ans=B[0]+B[n-2];
   rep(i,n-2){
       ans+=min(B[i],B[i+1]);
   }

   cout<<ans<<endl;


}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long MOD = (long)Math.pow(10, 9) + 7;
    long[][][][] dp = new long[n][4][4][4];
    long ans = 0;
    if(n == 1) {
      ans = 4;
    } else if(n == 2) {
      ans = 16;
    } else {
      for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
          for(int k = 0; k < 4; k++) {
            if(!(((i == 0) && (j == 2) && (k == 1)) || ((i == 2) && (j == 0) && (k == 1)) || ((i == 0) && (j == 1) && (k == 2)))) {
              dp[2][i][j][k] = 1;
            }
          }
        }
      }
      for(int m = 3; m < n; m++) {
        for(int i = 0; i < 4; i++) {
          for(int j = 0; j < 4; j++) {
            for(int k = 0; k < 4; k++) {
              if((k == 0) || (k == 3)) {
                for(int t = 0; t < 4; t++) {
                  dp[m][i][j][k] = (dp[m][i][j][k] + dp[m - 1][t][i][j]) % MOD;
                }
              }
              if(k == 1) {
                if(!(((i == 0) && (j == 2)) || ((i == 2) && (j == 0)))) {
                  for(int t = 0; t < 4; t++) {
                    if(!(((t == 0) && (j == 2)) || ((t == 0) && (i == 2)))) dp[m][i][j][k] = (dp[m][i][j][k] + dp[m - 1][t][i][j]) % MOD;
                  }
                }
              }
              if(k == 2) {
                if(!((i == 0) && (j == 1))) {
                  for(int t = 0; t < 4; t++) {
                    dp[m][i][j][k] = (dp[m][i][j][k] + dp[m - 1][t][i][j]) % MOD;
                  }
                } 
              }
            }
          }
        }
      }
      for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 4; j++) {
          for(int k = 0; k < 4; k++) {
            ans = (ans + dp[n - 1][i][j][k]) % MOD;
          }
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=4e3+7;

const ll mod=1e9+7;
ll power(ll a, ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}
int a[N];
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll n; cin>>n;
	ll k; cin>>k;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	int inter=0;
	for(int i=1; i<=n; i++) {
		for(int j=i+1; j<=n; j++) {
			if(a[j]<a[i]) {
				inter++;
			}
		}
	}
	if(k==1) {

		cout<<inter<<endl;
		return 0;
	}
	else{
		int ext=0;
		for(int i=1; i<=n; i++) {
			a[i+n]=a[i];
		}
		for(int i=1; i<=n; i++) {
			for(int j=n+1; j<=2*n; j++) {
				if(a[j]<a[i]) {
					ext++;
				}
			}
		}
		ll ans=inter*k;
		ans%=mod;
		ll d=k*(k-1)/2;
		d%=mod;

		ll m=ext*d;
		m%=mod;
		ans+=m;
		ans%=mod;
		cout<<ans<<endl;
		return 0;
	}


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector< vector<int> > next(N);
  for(int i=0; i<N-1; i++){
    int a, b;
    cin >> a >> b;
    next[a-1].push_back(b-1);
    next[b-1].push_back(a-1);
  }

  vector<bool> FS(N, false);
  vector<int> F, S;
  F.push_back(0);
  S.push_back(N-1);
  FS[0] = true;
  FS[N-1] = true;
  int f = 0;
  int s = 0;
  int n = 2;
  int nf = 1;
  int ns = 1;
  while(n < N){
    int fend = F.size();
    for(int i=f; i<fend; i++)
      for(int j=0; j<next[F[i]].size(); j++)
	if(!FS[next[F[i]][j]]){
	  F.push_back(next[F[i]][j]);
	  FS[next[F[i]][j]] = true;
	  nf++;
	  n++;
	}
    f = fend;
    int send = S.size();
    for(int i=s; i<send; i++)
      for(int j=0; j<next[S[i]].size(); j++)
	if(!FS[next[S[i]][j]]){
	  S.push_back(next[S[i]][j]);
	  FS[next[S[i]][j]] = true;
	  ns++;
	  n++;
	}
    s = send;
  }
  if(nf > ns)
    cout << "Fennec" << endl;
  else
    cout << "Snuke" << endl;

  return 0;
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  ll n,d;
  cin>>n>>d;
  int ans=0;
  rep(i,0,n){
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y<= d*d) ans++;
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x)
{
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=510;
int a[N][N],n;
int main() {
	rd(n);
	for(int i=0;i<n;++i,puts(""))
		for(int j=i+1;j<n;++j) {
			for(int k=0;;++k)
				if(((i>>k)&1)^((j>>k)&1)) { printf("%d ",k+1); break; }
		}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
	int n=0;
	
	string s;
	cin>>s;
	
	for(int i=0;i<=3;i++)
	{
		if(s[i]=='+')
		n++;
		else
		n--;
	}
	
	cout<<n;
	
	return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,3){
        cin >> A[i];
    }
    // sort(A,A+3);
    cout << (A[1]>=A[2] ? "delicious" : (A[0]>=A[2]-A[1] ? "safe" : "dangerous" ) ) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
 
int main(){
    int n; string s; cin >> n >> s;
    ll ans=0;
    int R,B,G; R=G=B=0;
    rep(i,n){
      if(s[i]=='R'){
        R++;
        ans+=G*B;
      }
      if(s[i]=='G'){
        G++;
        ans+=R*B;
      }
      if(s[i]=='B'){
        B++;
        ans+=G*R;
      }
    }
    rep(i,n-1){
      for(int j=i+1; j<n; j++){
        if(j+j-i>=n) continue;
        if(s[i]!=s[j] && s[i]!=s[j+j-i] && s[j]!=s[j+j-i]){
          ans--;
        }
      }
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;

int main(void){
    ll x,y;
    ll ans = 0;

    cin >> x >> y;
    
    ans += max(0ll, (4ll-x) * 100000ll);
    ans += max(0ll, (4ll-y) * 100000ll);

    if(x == 1 && y == 1)
        ans += 400000;
    
    cout << ans << endl;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		const int mod=1000000007;
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long[] h=new long[s[1]-1];
		long[,] ans=new long[s[0]+1,s[1]];
		long z=1;
		for(int i=1;i<(1<<(s[1]-1));i++){
			string st=new string('0',s[1]-1-Convert.ToString(i,2).Length)+Convert.ToString(i,2);
			bool b=true;
			for(int j=1;j<s[1]-1;j++){
				if(st[j-1]=='1'&&st[j]=='1'){
					b=false;
					break;
				}
			}
			if(b){
				z++;
				for(int j=0;j<s[1]-1;j++){
					if(st[j]=='1'){h[j]++;}
				}
			}
		}
		ans[0,0]++;
		if(s[1]>1){
		for(int i=1;i<=s[0];i++){
			for(int j=0;j<s[1];j++){
				if(j==0){
					ans[i,0]+=ans[i-1,0]*(z-h[0]);
					ans[i,0]%=mod;
					ans[i,1]+=ans[i-1,0]*(h[0]);
					ans[i,1]%=mod;
				}
				else if(j==s[1]-1){
					ans[i,j-1]+=ans[i-1,j]*(h[j-1]);
					ans[i,j-1]%=mod;
					ans[i,j]+=ans[i-1,j]*(z-h[j-1]);
					ans[i,j]%=mod;
				}
				else{
					ans[i,j-1]+=ans[i-1,j]*(h[j-1]);
					ans[i,j-1]%=mod;
					ans[i,j]+=ans[i-1,j]*(z-h[j-1]-h[j]);
					ans[i,j]%=mod;
					ans[i,j+1]+=ans[i-1,j]*(h[j]);
					ans[i,j+1]%=mod;
				}
			}

			
		}
		Console.WriteLine(ans[s[0],s[2]-1]);
		}
		else{Console.WriteLine(1);}
	}
}

Measured memory_bytes: 13268
#include<stdio.h>
//abc120-A
/*
int main(void)
{
	int a, b, c,d;
	scanf("%d %d %d", &a, &b, &c);

	if (b >= a * c)
	{
		printf("%d", c);
	}

	else
	{
		d = b / a;
		printf("%d", d);
	}
	return 0;
}*/
//abc120-B
int main(void)
{
	int a, b, k, tmp;
	int ans = 0, i, j;

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

	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}

	for (i = b; i > 0; i--)
	{
		if ((a % i + b % i) == 0)
		{
			ans += 1;
		}
		if (ans == k)
		{
			break;
		}

	}
	printf("%d", i);
	return 0;
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int N;
	cin >> N;
	priority_queue<string> que;
	for (int i = 0; i < N; i++) {
		string tmp;
		cin >> tmp;
		que.push(tmp);
	}
	int ans = 0;
	string str;
	for (int i = 0; i < N; i++) {
		if (que.top() != str) ans++;
		str = que.top();
		que.pop();
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11656
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  char cur = S[0];
  bool cont = false;
  for (int i = 1; i < S.length(); i++) {
    if (cur == S[i]) {
      cont = true;
      break;
    } else {
      cur = S[i];
    }
  }
  string ans = "Bad";
  if (!cont) ans = "Good";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define ll long long
using namespace std;
const int N=505;
int n,mo,l[N],r[N];
int S[N],f[N][N][N];
int main(){
	scanf("%d%d",&n,&mo);
	For(i,0,2*n-1){
		for (;i*i+l[i]*l[i]<n*n;l[i]++); l[i]++;
		for (;i*i+r[i]*r[i]<=4*n*n&&r[i]!=2*n;r[i]++);
	}
	For(i,0,n) For(j,n+1,2*n-1)
		S[i]+=((l[i]-1)>=r[j]);
	For(i,0,n+1) f[n+1][0][i]=1;
	Rep(i,n,0) For(j,0,n-i) For(k,0,i+1){
		int now=S[i+1]+j,val=1;
		Rep(p,2*n-1-S[i+1],2*n-S[i]) if (l[i+1]-1<r[p]&&r[p]<=l[i]-1) val=1ll*val*max(r[p]-now,0)%mo,++now;
		f[i][j+1][k]=(f[i][j+1][k]+mo-1ll*max(l[i]-now-1,0)*val%mo*f[i+1][j][k]%mo)%mo;
		if (k) f[i][j][k-1]=(f[i][j][k-1]+1ll*max(r[i]-(2*n-k),0)*val%mo*f[i+1][j][k])%mo;
	}
	int ans=0;
	For(i,0,n+1){
		int now=S[0]+i,val=f[0][i][0];
		Rep(p,2*n-1,n+1) if (l[0]-1<r[p]) val=1ll*val*max(r[p]-now,0)%mo,++now;
		ans=(ans+val)%mo;
	}
	printf("%d\n",ans);
}

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

using namespace std;

const int N = 3010;
typedef long long LL;

int n,m;
double dp[N][N];
double c[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    
    for(int i = 1; i<=n; i++) cin>>c[i];
    
    dp[0][0] = 1;
    for(int i = 1; i<=n; i++){
        dp[i][0] = dp[i-1][0] * (1-c[i]);
        for(int j = 1; j<=i; j++){
            dp[i][j] = dp[i-1][j-1] * c[i] + dp[i-1][j] * (1-c[i]);
        }
    }
    
    double ans = 0;
    int x = n>>1;
    for(int j = x+1; j<=n; j++){
        ans += dp[n][j];
    }
    
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

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

int main() {

long N;
cin>>N;
vector<long> a(N);
for(int i=0;i<N-1;i++) cin>>a[i];

vector<long> b(N);
for(int i=0;i<N-1;i++){
  b[a[i]-1]++;
}
for(int i=0;i<N;i++){
cout<<b[i]<<endl;
}
//cout<<ans<<endl;
}


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

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll res = 0;
    ll ma = min(k,a);
    res+=min(k,a);
    a-=ma;
    k-=ma;
    k = max(ll(0),k);
    ll mb = min(k,b);
    k-=mb;
    k = max(ll(0),k);
    ll mc = min(k,c);
    res-=mc;
    k-=mc;
    k = max(ll(0),k);
    cout << res;
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

/*--------------------------------------------*/
/* 0 : push                                   */
/* 1 : top                                    */
/* 2 : pop                                    */
/*--------------------------------------------*/

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

  std::vector< stack<int> > st(n);

  int order;
  int num;
  int t;

  for(int i=0; i<q; ++i){
    cin >> order >> t;

    if(order == 0){
      cin >> num;
      st[t].push(num);
    }
    else if(order == 1 && !st[t].empty()){
      cout << st[t].top() << endl;
    }
    else if(order == 2 && !st[t].empty()){
      st[t].pop();
    }
  }

  return 0;
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    int n, k; cin >> n >> k;
    vector<ll> h(n), dp(n, LINF);
    for (int i = 0; i < n; i++) cin >> h[i];

    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i+j < n) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VL vector<LL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e18;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    /*
    int t,n;
    cin>>t;
    loop(t1,1,t+1)
    {
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    LL n;
    cin>>n;
    LL ans = 0, n1 = n, c;
    for(LL i = 2; i*i <= n; ++i)
    {
        if(n1 % i == 0)
        {
            c = 0;
            while(n1 % i == 0) {++c; n1/=i;}
            int j = 1;
            while(c)
            {
                if(j > c) break;
                c -= j; ++j;
                ++ans;
            }
        }
    }

    if(n1 != 1) ++ans;
    cout<<ans<<'\n';

    /*
    if(f) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    */

    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main() {
    int n,t[1000],m,p[1000],x[1000],i,j,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
		scanf("%d",&t[i]);
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&p[i],&x[i]);
		sum = sum + x[i];
		for(j=0;j<n;j++){
			if(j==p[i]-1)
				continue;
			sum = sum + t[j];
		}
		printf("%d\n",sum);
		sum = 0;
	}
    return 0;
}


Measured memory_bytes: 1664
import copy
n, x = map(int, input().split())
A = list(map(int, input().split()))
B = copy.deepcopy(A)

if A[0] > x:
  A[0] = x
for i in range(1, len(A)):
  if A[i-1] + A[i] > x:
    A[i] = x - A[i-1]
ans = 0
for a, b in zip(A, B):
  ans += b - a
print(ans)


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

int main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }

  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      if (i == 0 || i == H + 1) {
        cout << '#';
      } else if (j == 0 || j == W + 1) {
        cout << '#';
      } else {
        cout << a.at(i - 1).at(j - 1);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
nhw = input().split()
n = int(nhw[0])
h = int(nhw[1])
w = int(nhw[2])

ablist = []
for i in range(n):
    ab = input().split()
    a = int(ab[0])
    b = int(ab[1])
    ablist.append((a, b))


count = 0
for a, b in ablist:
    if a >= h and b >= w:
        count += 1

print(count)


Measured memory_bytes: 3064
def aux(l)
  l.inject(1){|s,x| s.lcm(x)}
end

def main
  dat=[]
  fh=STDIN
  #fh=File.new("x.txt", "r")
  n = fh.gets.chomp.to_i
  l=fh.gets.chomp.split.map(&:to_i)
  puts aux(l)
end

if $0 == __FILE__ then
  main
end


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

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  for(ll i=0;i<N;++i){
    cin >> A[i];
  }
  ll tmp,cnt1=0,cnt2=0,tmp2=0;
  for(ll i=0;i<N;++i){
    if(A[i]==1){
      tmp=i;
      break;
    }
  }
  while(tmp+cnt1*(K-1)<N-1){
    cnt1++;
  }
  tmp2 = tmp+cnt1*(K-1)-N+1;
  while(tmp-tmp2-cnt2*(K-1)>0){
    cnt2++;
  }
  cout << cnt1+cnt2 << endl;
}

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


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        int n = Integer.parseInt(scanner.next());
      	int k = Integer.parseInt(scanner.next());
      	int[] array = new int[n];
      	int ans = 0;
      	
        for(int i = 0 ; i < n ; i++){
        	array[i] = Integer.parseInt(scanner.next());
        }
        
        Arrays.sort(array);
      	
        for(int i = 0; i < k; i++) {
        	ans += array[i];
        }
        
        System.out.println(ans);
        
        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

int main() {
  string s;
  cin >> s;
  int len = s.length();
  int ans = 0;
  int ans_tmp = 0;
  for (int i; i<len; i++){
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
      ans_tmp += 1;
    }
    else {
      if (ans_tmp >= ans) ans = ans_tmp;
      ans_tmp = 0;
    }
  }
  if (ans_tmp >= ans) ans = ans_tmp;
      
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner scan = new Scanner(System.in)) {
          int a = scan.nextInt();
          System.out.println(a*a*a);
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  int l[N], A_temp;
  map<int, int> r;
  for(int i = 0; i < N; i++){
    cin >> A_temp;
    l[i] = i + A_temp;
    r[i - A_temp] += 1;
  }
  long int ans = 0;
  for(int i = 0; i < N - 1; i++) ans += r[l[i]];
  cout << ans;
  return 0;
}

Measured memory_bytes: 21352
import itertools as it
import collections as col
import heapq
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N=input()

D=set()
for n in range(1,10):
    for d in it.product(['3','5','7'],repeat=n):
        x=0
        for i in range(n):
            x += (10**i)*int(d[n-i-1])
        if (x <= int(N) and '3' in d and '5' in d and '7' in d):
            D.add(x)
#print(N)
print(len(D))
#print(3*(1-3**9)//(1-3))


Measured memory_bytes: 44636
#include<stdio.h>
#define  _CRT_SECURE_NO_WARNINGS

main() {
	int x, y;

	while (1) {
             scanf("%d %d", &x,&y);
             if(x==0 && y==0)
               break;
             else{
		
		if(y>x)
	           printf("%d %d\n", x, y);
		else printf("%d %d\n", y, x);
             }
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include<string>
#include <algorithm>
#include <queue>
#define NIL -1
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MAX 10003
#define GREY 1
#define BLACK 0
#define WHITE 2
int main() {
	int a, b, c, n; cin >> a >> b;
	if (a + b >= 10) {
		cout << "error" << endl;
	}
	else {
		cout << a + b << endl;
	}
	return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <math.h>

#define N 10000
#define TRUE 1
#define FALSE 0

int isprime(int);

int main(){
  int i,j,num,A[N],count=0;

  while(1){
    scanf("%d",&num);
    if(1 <= num && num <= N) break;
  }
  for(i = 0;i < num;i++){
    scanf("%d",&A[i]);
    if(A[i] < 2 || N*N < A[i]) i = i - 1;;
  }
  for(i = 0;i < num;i++) if(isprime(A[i]) == TRUE) count++;
  printf("%d\n",count);

  return 0;
}

int isprime(int a){
  int i;
  if(a == 2) return TRUE;
  if(a < 2 || a%2 == 0) return FALSE;
  i = 3;
  while(i <= sqrt(a)){
    if(a%i == 0) return FALSE;
    i = i + 2;
  }
  return TRUE;
}

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

using namespace std;

int main(){
  int m,n1,n2,p,res;
  while(cin >> m >> n1 >> n2, m|n1|n2){
    vector<int> a;
    for(int i=0;i<m;i++){
      cin >> p;
      a.push_back(p);
    }
    res = n1;
    for(int i=n1,g=0;i<=(m==n2?n2-1:n2);i++){
      // cout << i << " " << a[i-1]-a[i] << endl;
      if(g<=a[i-1]-a[i]){
	res=i;
	g=a[i-1]-a[i];
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3064
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var A = Number(lines[0].split(" ")[0]);
    var B = Number(lines[0].split(" ")[1]);

    var S = lines[1];
    var i = 0;
    while (i < S.length) {
        if (i < A && S[i] === "-") { console.log("No"); return (0); }
        if (i === A && S[i] !== "-") { console.log("No"); return (0); }
        if (A < i && S[i] === "-") { console.log("No"); return (0); }
        i++
    }
console.log("Yes");
});

Measured memory_bytes: 21320
#include<iostream>
using namespace std;
const int maxv=100000;
int main()
{
	int root[101][101];
	for(int i=0;i<=100;i++){
		for(int i2=0;i2<=100;i2++){
			root[i][i2]=maxv;
		}
	}
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
	int r,k,ch;
	cin>>r>>k;
		for(int i2=0;i2<k;i2++){
			cin>>ch;
			root[r][ch]=1;
		}
	}

	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int i2=01;i2<=n;i2++){
				root[i][i2]=min(root[i][i2],root[i][k]+root[k][i2]);
			}
		}
	}

	int m;
	int s,d,v;
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>s>>d>>v;
		if(root[s][d]<v){
			cout<<root[s][d]+1<<endl;
		}
		else{
			cout<<"NA"<<endl;
		}
	}
}

Measured memory_bytes: 1204
r, c = gets.chomp.split.map(&:to_i)
data = Array.new(r + 1){Array.new(c + 1, 0)}
r.times{|x|
    data[x] = gets.chomp.split.map(&:to_i)
    sum = data[x].inject(:+)
    data[x] << sum
    data[x].each_with_index{|number, i| data[r][i] += number}
}
data.each{|row| puts row.join(" ")}


Measured memory_bytes: 7132
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define LEFT(x) (x<<1)
#define RIGHT(x) (x<<1|1)

#define INF 1e18
#define MOD 1000000007

using namespace std;

vi adj[200010];
ll a[200010];
int ans[200010];
int n;
ll lis[200010];

void dfs(int u, int p) {
    int ind = (int) (lower_bound(lis, lis + n, a[u]) - lis);
    ll va = lis[ind];
    lis[ind] = a[u];
    ans[u] = (int) (lower_bound(lis, lis + 200010, INF) - lis) - 1;
    for(int v : adj[u]) {
        if(v == p) continue;
        dfs(v, u);
    }
    if(ind < 200010)
        lis[ind] = va;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 0; i < 200010; i++) lis[i] = INF;
    lis[0] = -INF;
    for(int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].PB(b);
        adj[b].PB(a);
    }

    dfs(1, 1);
    for(int i = 1; i <= n; i++) cout << ans[i] << "\n";
}


Measured memory_bytes: 32856
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use num_integer::div_floor;

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

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr >() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn lower_bound<T: Copy, F>(v: &Vec<T>, f: F) -> Option<usize> where
F: Fn(T) -> bool
{
    let mut left = 0_usize;
    let mut right = (v.len() - 1_usize);
    if !f(v[left]) {
        return None;
    }
    loop  {
        if f(v[right]) {
            return Some(right);
        }
        if right - left == 1 {
            return Some(left);
        }
        let mid = (left + right) / 2;
        if f(v[mid]) {
            left = mid;
        } else {
            right = mid;
        }
    }
}

fn main() {
    let (n, m, k): (u64, u64, u64) = read_tuple3();
    let a_list:Vec<u64> = (0..n).map(|_|read()).collect();
    let b_list:Vec<u64> = (0..m).map(|_|read()).collect();
    let a_sum = {
        let mut sum = 0;
        let mut v = vec![0];
        for i in a_list {
            sum += i;
            v.push(sum);
        }
        v
    };
    let b_sum = {
        let mut sum = 0;
        let mut v = vec![0];
        for i in b_list {
            sum += i;
            v.push(sum);
        }
        v
    };
    let mut readable_books = vec![0];
    for (i, a) in a_sum.iter().enumerate() {
        let is_ok = |val|val + *a <= k;
        if let Some(b_books) = lower_bound(&b_sum, is_ok) {
            readable_books.push(i + b_books);
        }
    }
    let ans = *readable_books.iter().max().unwrap();
    print!("{}", ans);



}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	string s,t;
	cin>>s>>t;
	int ans = 0;
	REP(i,0,s.length()-t.length()) {
		int cur=0;
		REP(j,0,t.length()-1) {
			if(s[i+j]==t[j])cur++;
		}
		ans=max(ans,cur);
	}
	cout<<t.length()-ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	int x = 0;
	for (int i = 0; i < a.size(); i++) {
		int z = 0;
		for (int j = 0; j < a.size(); j++) {
			if (a[(j + i) % a.size()] == b[j]) z++;
		}
		if (z == a.size()) x = 1;
	}
	if (x == 1) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
//2019.7.22 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 1e18+1e9
#define eps 1e-10
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
#define Pi 2.0*acos(-1.0)
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int kcz=998244353;
const int N=5e5+10;
namespace MAIN{
    inline void add(res &x,const res &y){
        x+=y,x>=kcz?x-=kcz:1;
    }
    inline int Add(const res &x,const res &y){
        return x+y>=kcz?x+y-kcz:x+y;
    }
    inline int mul(const res &x,const res &y){
        return int(1LL*x*y%kcz);
    }
    int n,m;
    int fac[N],inv[N];
    inline int C(const res &x,const res &y){
        return mul(fac[x],mul(inv[y],inv[x-y]));
    }
    inline int A(const res &x,const res &y){
        return mul(fac[x],inv[x-y]);
    }
    int pwn[N],pwm[N];
    int ans;
    inline void MAIN(){
        n=read(),m=read(),fac[0]=fac[1]=inv[0]=inv[1]=pwn[0]=pwm[0]=1;
        if(n>m)swap(n,m);
        for(res i=1;i<=m;i++)pwn[i]=mul(pwn[i-1],n+1),pwm[i]=mul(pwm[i-1],m+1);
        for(res i=2;i<=m;i++)fac[i]=mul(fac[i-1],i),inv[i]=mul(inv[kcz%i],kcz-kcz/i);
        for(res i=2;i<=m;i++)inv[i]=mul(inv[i-1],inv[i]);
        for(res i=0;i<=n;i++)add(ans,i&1?kcz-mul(mul(C(n,i),A(m,i)),mul(pwn[m-i],pwm[n-i])):mul(mul(C(n,i),A(m,i)),mul(pwn[m-i],pwm[n-i])));
        printf("%d\n",ans);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}


Measured memory_bytes: 8064
#include<cstdio>
#include<algorithm>
using namespace std;
int n, a[100000+5];
int result=0,last=0;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i) 
	{
        scanf("%d",a+i);
        int b=0;
        while(a[i]>>b+1) ++b;
        int c=a[i]!=(1<<b);
        b+=c;
        if(last>=b) 
		{
            last=b-c;
        } 
		else 
		{
            result+=b-last;
            last=b;
        }
    }
    printf("%d\n",result);
    return 0; 
}

Measured memory_bytes: 512