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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = n-1; i > 0; i--){
        if(h[i] >= h[i-1])
            continue;
        else if(h[i-1] - h[i] <= 1){
            h[i-1]--;
        } else {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    string s;
    cin >> s;
    vector<int> ans(2019,0);
    ll tmp=0;
    ll kakeru=1;
    IREP(i,s.size()){
        tmp+=kakeru*(s[i]-'0');
        tmp%=2019;
        ans[tmp]++;
        kakeru*=10;
        kakeru%=2019;
    }
    ll kotae=0;
    REP(i,2019){
        if(i==0){
            kotae+=ans[i];
        }
        kotae += ans[i]*(ans[i]-1)/2;
    }
    cout << kotae << endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL<<31) - 1;
const ll mod = 1e9 + 7;




int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int N; cin >> N;
	cout <<  (1000-N%1000)%1000 << endl;




}


Measured memory_bytes: 3636
#include<cstdio>
int main(){
	char s[11];
	scanf("%s",s);
	if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f

//std::ios::sync_with_stdio(0); std::cin.tie(0);
int main() {
	int a[5];
	for (int i = 0; i < 5; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < 5; ++i) {
		if (a[i] == 0) {
			cout << i + 1 << endl;
			break;
		}
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 2000001000
#define MOD 1000000007
using Graph=vector<vector<int>>;

int nn=1;
vector<int> tree;

void solve(int a,int b,int i,int m,int left,int right){
  if(a<=left&&right<=b){
    tree.at(i)=min(tree.at(i),m);
    return;
  }
  if(right<=a||b<=left){
    return;
  }
  solve(a,b,2*i+1,m,left,(left+right)/2);
  solve(a,b,2*i+2,m,(left+right)/2,right);
}

void update(int a,int b,int m){
  solve(a,b,0,m,0,nn);
}

int main(){
  int N,Q;
  cin>>N>>Q;
  vector<int> S(N),T(N),X(N),D(Q);
  set<int> s;
  for(int i=0;i<N;i++){
    cin>>S.at(i)>>T.at(i)>>X.at(i);
    s.insert(S.at(i)-X.at(i));
    s.insert(T.at(i)-X.at(i));
  }
  for(int i=0;i<Q;i++){
    cin>>D.at(i);
    s.insert(D.at(i));
  }

  int n=0;
  map<int,int> m;
  for(auto x:s){
    m[x]=n;
    n++;
  }

  while(nn<n){
    nn*=2;
  }
  tree.resize(2*nn-1,INF);

  for(int i=0;i<N;i++){
    int s=m[S.at(i)-X.at(i)];
    int t=m[T.at(i)-X.at(i)];
    update(s,t,X.at(i));
  }

  for(int i=0;i<nn-1;i++){
    tree.at(2*i+1)=min(tree.at(i),tree.at(2*i+1));
    tree.at(2*i+2)=min(tree.at(i),tree.at(2*i+2));
  }
  for(int i=0;i<Q;i++){
    int x=tree.at(nn-1+m[D.at(i)]);
    if(x==INF){
      cout<<-1<<endl;
    }else{
      cout<<x<<endl;
    }
  }
}


Measured memory_bytes: 68864
#include <stdio.h>

char str[16][16];

/*
void erase(int x, int y)
{
	if (x < 0 || x > 11 || y < 0 || y > 11) return;
	if (str[y][x] == '0') return;
	
	str[y][x] = '0';
	
	erase(x + 1, y);
	erase(x, y + 1);
	erase(x - 1, y);
	erase(x, y - 1);
}
*/

void is(int i, int j)
{
	int n;
	int k;
	
	str[i][j] = '0';
	
	k = 1;
	for (n = 0; n < 2; n++){
		if (str[i + k][j] == '1' && i + k >= 0 && i + k < 12){
			is(i + k, j);
		}
		if (str[i][j + k] == '1' && j + k >= 0 && j + k < 12){
			is(i, j + k);
		}
		k = -1;
	}
}

int main(void)
{
	int i, j;
	int ans;
	int a;
//	int case_ = 0;
	 
	while (1){
//		if (case_) fgets(str[0], 16, stdin);
//		case_++;
		ans = 0;
		for (i = 0; i < 12; i++){
			if (fgets(str[i], 16, stdin) == NULL){
				return (0);
			}
		}
		for (i = 0; i < 12; i++){
			for (j = 0; j < 12; j++){
				if (str[i][j] == '1'){
					is(i, j);
					str[i][j] = '1';
					ans++;
				}
			}
		}
		printf("%d\n", ans);
		if (fgets(str[0], 16, stdin) == NULL) return(0);
	}
}

Measured memory_bytes: 948
n = int(input())

a = list(map(int,input().split()))

a.reverse()

flg = True

for i in range(n-1):
	if a[i] >= a[i+1]:
		continue
	else:
		if a[i+1] > a[i] +1 :
			flg = False
			break
		else:
			a[i+1] -= 1

if flg:
	print("Yes")
else:
	print("No")




Measured memory_bytes: 14396
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]

for x in range(1000):
    sx=str(x)
    if n!=len(sx):
        continue

    for s,c in sc:
        if sx[s-1]!=str(c):
            break
    else:
        print(x)
        exit(0)

print(-1)

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

int main() {
  double A, B;
  cin >> A >> B;

  if (A > B) {
    printf("GREATER");
  } else if (A == B) {
    printf("EQUAL");
  } else {
    printf("LESS");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+18
#define int long long
using namespace std;

int dp[1001][1001],w,h,s[1001][1001];

int calc(int x1,int x2,int y1,int y2){
	return s[x2 + 1][y2 + 1] - s[x2 + 1][y1] - s[x1][y2 + 1] + s[x1][y1];
}

int dfs(int x,int y){
	if(x == h || y == w) return 0;
	if(dp[x][y] != INF) return dp[x][y];
	if((x + y) % 2 == 0) return dp[x][y] = max(dfs(x + 1,y) + calc(x,x,y,w - 1),dfs(x,y + 1) - calc(x,h - 1,y,y));
	else return dp[x][y] = min(dfs(x + 1,y) + calc(x,x,y,w - 1),dfs(x,y + 1) - calc(x,h - 1,y,y));
}

signed main(){
	cin >> w >> h;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			cin >> s[i + 1][j + 1];
		}
	}
	for(int i = 0;i <= h;i++){
		for(int j = 0;j <= w;j++) dp[i][j] = INF;
	}
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
		}
	}
	cout << abs(dfs(0,0)) << endl;
	return 0;
}

Measured memory_bytes: 18884
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;



int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]) cout<<"YES\n";
    else cout<<"NO\n";

    return 0;
}

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

int H;
int W;
char M[ 60 ][ 60 ];

int Chk( const int i, const int j )
{
	if( M[ i ][ j ] != '#' ) return 0;

	if( i > 0		&& M[ i - 1 ][ j ] == '#' ) return 1;
	if( i + 1 < W	&& M[ i + 1 ][ j ] == '#' ) return 1;
	if( j > 0		&& M[ i ][ j - 1 ] == '#' ) return 1;
	if( j + 1 < H	&& M[ i ][ j + 1 ] == '#' ) return 1;

	return 2;
}

int main()
{
int i;
int j;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> H;
	cin >> W;
	for( i = 0; i < H; i++ )
	{
		cin >> M[ i ];
	}

	for( i = 0; i < W; i++ )
	{
		for( j = 0; j < H; j++ )
		{
			if( Chk( i, j ) == 2 )
			{
				cout << "No" << endl;

				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}




Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;

bool ok(vi a) {
	FOR(i, 1, a.size()-1) {
		if(a[i-1] > a[i]) {
			return false;
		}
	}
	return true;
}

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

	REP(sgz, N) {
		vi a, b;

		int x;
		cin >> x;
		a.push_back(x);
		REP(i, 9) {
			cin >> x;
			if(x > a[a.size()-1]) {
				a.push_back(x);
			} else {
				b.push_back(x);
			}
		}

		if(ok(a) && ok(b)) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

int prime[300005];
bool is_prime[300015];

int sieve(int n)
{
    int p = 0;
    REP(i, n) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; ++i)
    {
        if (is_prime[i])
        {
            prime[p++] = i;
            for (int j = 2*i; j <= n; j+=i) is_prime[j] = false;
        }
    }
    return p;
}

class CNextPrime {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int x;
        cin >> x;
        sieve(300000);

        while (true) {
            if (is_prime[x]) {
                break;
            }
            x++;
        }
        cout << x << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CNextPrime solver;
    solver.solve(in, out);
    return 0;
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

const int N = 5e5 + 1;
int ans[N];
struct BIT
{
    int N;
    vector<int> bit;

    void init(int n)
    {
        N = n;
        bit.assign(n + 1, 0);
    }

    void update(int idx, int val)
    {
        while(idx <= N)
        {
            bit[idx] += val;
            idx += idx & -idx;
        }
    }

    void updateMax(int idx, int val)
    {
        while(idx <= N)
        {
            bit[idx] = max(bit[idx], val);
            idx += idx & -idx;
        }
    }

    int pref(int idx)
    {
        int ans = 0;
        while(idx > 0)
        {
            ans += bit[idx];
            idx -= idx & -idx;
        }
        return ans;
    }

    int rsum(int l, int r)
    {
        return pref(r) - pref(l - 1);
    }

    int prefMax(int idx)
    {
        int ans = -2e9;
        while(idx > 0)
        {
            ans = max(ans, bit[idx]);
            idx -= idx & -idx;
        }
        return ans;
    }
};
/*
BIT b;
b.init(10);
*/


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, q;
    cin >> n >> q;
    int c[n+1];
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    int a[n + 1] = {};
    memset(a, -1, sizeof a);
    vector<pair<pii,int>> queries;
    int idx = 0;
    while(q--) {
        int l, r;
        cin >> l >> r;
        queries.pb({{r, l}, idx++});
    }

    sort(queries.begin(), queries.end());
    BIT b;
    b.init(n + 1);
    for(int i = 1; i <= queries.front().first.first; i++) {
        if(a[c[i]] == -1) {
            b.update(i, 1);
        }
        else {
            b.update(a[c[i]], -1);
            b.update(i, 1);
        }
        a[c[i]] = i;
    }
    int last_r = -1;
    for(auto x: queries) {

        int l = x.first.second, r = x.first.first;
        if(last_r != -1) {
            for(int j = last_r; j <= r; j++) {
                if(a[c[j]] == -1) {
                    b.update(j, 1);
                }
                else {
                    b.update(a[c[j]], -1);
                    b.update(j, 1);
                }
                a[c[j]] = j;
            }    
        }
        int res = b.rsum(l, r);
        ans[x.second] = res;
        last_r = r;
    }
    for(int i = 0; i < idx; i++) {
        cout << ans[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 31184
#include<stdio.h>

int main(void){
    int N,T;
    int min = 1001;
    int maxnum = 0;
    scanf("%d %d",&N,&T);
    int c[N],t[N];
    for(int i=0;i<N;i++){
        scanf("%d %d",&c[i],&t[i]);
        if(t[i]<=T && c[i]<min){
            min = c[i];
            maxnum = i;
        }
    }
    if(min==1001){
        printf("TLE");
    }else{
        printf("%d",min);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
char s[120];
int n,ans;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='R')ans++;
		else ans--;
	}
	if(ans>0)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
 int a,b,c,temp;
 scanf("%d%d%d",&a,&b,&c);
 if(b>c){
 temp=b;
 b=c;
 c=temp;
 }
 if(a>b){
 temp=a;
 a=b;
 b=temp;
 }
 if(b>c){
 temp=b;
 b=c;
 c=temp;
 }
 printf("%d %d %d\n",a,b,c);
 return 0;
 }


Measured memory_bytes: 1948
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<29;

int dp[(1<<12)+1];

int main(){
  int n,m; cin >> n >> m;
  rep(i,1<<n) dp[i]=inf;
  dp[0]=0;
  rep(i,m){
    int a,b; cin >> a >> b;
    int s=0;
    rep(j,b){
      int c; cin >> c; c--;
      s+=(1<<c);
    }
    rep(j,1<<n){
      chmin(dp[j|s],dp[j]+a);
    }
  }
  if(dp[(1<<n)-1]==inf) cout << -1 << endl;
  else cout << dp[(1<<n)-1] << endl;
}

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

int main(){
    int N,M;
    int buf1,buf2;
    int count = 0;
    cin >> N >> M;
    vector<int> height(N);
    vector<vector<int>> connected(N,vector<int>(0));
    for(auto &i : height) cin >> i;
    for(int i = 0;i < M;i++){
        cin >> buf1 >> buf2;
        connected[buf1 - 1].push_back(height[buf2-1]);
        connected[buf2 - 1].push_back(height[buf1-1]);
    }
    for(int i = 0;i < N;i++){
        if(connected[i].empty()){count++;continue;}
        if(height[i] > *max_element(connected[i].begin(),connected[i].end())){
            count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 8800
'use strict'

function main(input) {

    input = input.split('\n')
    let n = ~~input[0]
    let x = input[1].split(' ').map(v => ~~v) 
    let x2 = x.slice(0).sort((a, b) => a - b)
    let med = x2[n / 2]
    let index = 0
    for (let i = 0; i < n; i++) {
        if (x[i] < med) index = (n) / 2
        else index = (n) / 2 - 1
        console.log(x2[index])
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
	int n; cin >> n; 
	vector<int>h(n);
	for(int i=0; i<n; i++){
		cin >> h[i];
	}
	vector<int>dp(n,INT_MAX);
	dp[0] = 0; 
	dp[1] = abs(h[1] - h[0]);
	for(int i=0; i<n; i++){
		for(auto j : { i+1, i+2}){
			if(j < n){
				dp[j] = min(dp[j] , dp[i]+abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 3960
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	double n;
	cin >> n;
	cout << round(n / 2);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    double r;
    cin >> r;
    cout << fixed << setprecision(10) << r * 2 * 3.14159 << endl;
}

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

long long cal;
long long mn[30],all;

main()
{
    long long d;
    scanf("%lld",&d);
    for(int i=0;i<26;i++)
    {
        scanf("%lld",&mn[i]);
        all+=mn[i];
    }
    for(int i=0;i<d;i++)
    {
        int idx;
        long long mx=-1e18;
        for(int j=0;j<26;j++)
        {
            long long a;
            scanf("%lld",&a);
            // printf("%lld\n",a+mn[i]-all);
            if(mx<a+mn[i]-all)
            {
                mx=a+mn[i]-all;
                idx=j+1;
            }
        }
        printf("%d\n",idx);
    }
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 4479545
using namespace std;
int main()
{
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3560
while true
  n, arr = gets.to_i, []
  
  break if n == 0
  
  n.times do |i|
    arr[i] = gets.split.map(&:to_i)
    arr[i][n] = 0
    
    n.times do |j|
      arr[i][n] += arr[i][j]
    end
  end
  
  arr[n] = Array.new(n + 1, 0)
  
  (n + 1).times do |i|
    str = ""
    
    (n + 1).times do |j|
      arr[n][i] += arr[j][i] unless j == n
      str += sprintf("%5d", arr[i][j])
    end
    
    puts str
  end
end

Measured memory_bytes: 6120
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  set<ll> ans;
  for (int i = A; i < A + K && i <= B; i++) {
    ans.insert(i);
  }
  for (int i = B; i > B - K && i >= A; i--) {
    ans.insert(i);
  }
  for (auto x : ans) {
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"

#define REP(i, a) for (ll i = 0; i < (a); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

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

int ccc(ll x) {
  ll a = 2;
  int pos=1, flag;
  ll size=(ll)sqrt(x)+2;
  while(size>=a) {
    flag = 0;
    while(x%a==0) {
      x /= a;
      flag = 1;
    }
    pos += flag;
    a++;
  }
  if (x>1) pos++;
  return pos;
}

void Main() {
  ll A, B;
  cin >> A >> B;
  cout << ccc(gcd(A,B)) << endl;
}

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


Measured memory_bytes: 256
S = input()
T = input()


dict_S = {}
dict_T = {}

for i in range(len(S)):
  if S[i] in dict_S:
    if dict_S[S[i]] != T[i]:
      print("No")
      exit()
  else:
    dict_S[S[i]] = T[i]
  
  if T[i] in dict_T:
    if dict_T[T[i]] != S[i]:
      print("No")
      exit()
  else:
    dict_T[T[i]] = S[i]
    
print("Yes")

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

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    int ans[N] = {0};
    int tmp;
    for(int i = 0; i < Q; ++i) { cin >> tmp; --tmp; ++ans[tmp]; }
    for(int i = 0; i < N; ++i) {
        if(K - (Q - ans[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    //write code  here

    ll A,B,C,K;
    cin >> A >> B >> C >> K;

    ll sum=0;
    if (K<=A){
        sum = K;
//        cout << "A\n";
    }else if (K<=A+B) {
        sum = A;
//        cout << "B\n";
    }else if (K<=A+B+C){
        sum = A-(K-(A+B));
//        cout << "C\n";
    }

    cout << sum <<endl;

    return 0;
}

Measured memory_bytes: 3636
//Template Jollybee 2017-0720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;

const int INF=(int)2e9;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
const ll MOD=(ll)1e9+7;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front

int main(){
	int n;
	int arr[100010];
	scanf("%d",&n);
	long long count[100010];
	memset(count,0,sizeof(count));
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
		count[arr[i]]++;
		if(arr[i]>0){
			count[arr[i]-1]++;
		}
		count[arr[i]+1]++;
	}
	long long mx = 0;
	long long mxidx =0;
	for(int i=0;i<100010;i++){
		if(mx<count[i]){
			mx=count[i];
			mxidx = i;
		}
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		if(arr[i]+1==mxidx||arr[i]-1==mxidx||arr[i]==mxidx){
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll N;
	vector<ll>V;
	string s,t;
	cin>>N>>s>>t;
	rep(i,N){
		ll F=0;
		rep(j,s.size()){
			if(s[j]==t[j]){
				F++;
			}
			else F=0;
		}
		V.push_back(F);
		s.erase(s.begin());
	}
	sort(V.begin(),V.end());
	cout<<2*N-V.back()<<endl;
}

Measured memory_bytes: 256
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
        
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x==y: return
    if rank[x]<rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x]+=1
            
def same(x,y):
    return find(x)==find(y)
    
n,m = readLine_int_list()
v = n + m
par = [i for i in range(0, v)]
rank = [1] * v
def main():
    for i in range(n):
        for ii in readLine_int_list()[1:]:
           unite(i, ii-1+n)
           
    r = "YES"
    for i in range(0, n):
        if find(i) != find(0):
            r = "NO"
    print(r)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 12592
n,x=map(int, input().split())
m=[int(input()) for _ in range(n)]

count=0

for i in range(len(m)):
    if x>=m[i]:
        x-=m[i]
        count+=1
        
min_donut=min(m)
while(x>=min_donut):
    x-=min_donut
    count+=1
    
print(count)

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

int main(void)
{
    int n;
    cin >> n;
    int max_n = INT_MIN;
    int min_n = INT_MAX;
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (min_n > x)
            min_n = x;
        if (max_n < x)
            max_n = x;
        sum += x;
    }
    cout << min_n << ' ' << max_n << ' ' << sum << endl;
    return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,ce=0,cw=0,an=1e9,a[300003];
	char c[300003];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c[i];
		a[i]=cw;
		if(c[i]=='W')cw++;
	}
	for(int i=n-1;i>=0;i--)
	{
		an=min(an,a[i]+ce);
		if(c[i]=='E')ce++;
	}
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<limits.h>
#include<string.h>
using namespace std;
int main(){
    char s[1000];
    cin>>s;
    for(int i=0;i<strlen(s);i++)cout<<"x";
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
a,b,k = map(int,input().split())
lst = []
for i in range(a,a+k):
    if a<=i<=b:
        lst.append(i)
for i in range(b-k+1,b+1):
    if a<=i<=b:
        lst.append(i)    
ans = list(set(lst))
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

//誤差を考慮して足し算
double add(double a, double b) {
	if (abs(a + b) < eps*(abs(a) + abs(b))) {
		return 0;
	}
	return a + b;
}

//二次元ベクトル構造体
struct pp {
	double x, y;
	pp() {}
	pp(double x, double y) :x(x), y(y) {}
	pp operator+(pp p) {
		return pp(add(x, p.x), add(y, p.y));
	}
	pp operator-(pp p) {
		return pp(add(x, -p.x), add(y, -p.y));
	}
	pp operator*(double d) {
		return pp(add(x, d), add(y, d));
	}
	double dot(pp p) {//内積
		return add(x*p.x, y*p.y);
	}
	double det(pp p) {//外積
		return add(x*p.y, -y * p.x);
	}
};

double dist(pp p, pp q) {//距離の二乗
	return (p - q).dot(p - q);
}

bool cmp_x(const pp& p, const pp& q) {
	if (p.x != q.x)return p.x < q.x;
	return p.y < q.y;
}

//凸包
vector<pp>convex_full(pp* ps, int N) {
	sort(ps, ps + N, cmp_x);
	int k = 0;
	vector<pp>qs(N * 2);
	//下側凸包
	for (int i = 0;i < N;i++) {
		while (k > 1 && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0)k--;
		qs[k++] = ps[i];
	}
	//上側凸包
	for (int i = N - 2, t = k;i >= 0;i--) {
		while (k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0)k--;
		qs[k++] = ps[i];
	}
	qs.resize(k - 1);
	return qs;
}

struct Union_Find_Tree {
private:
	vector<ll>par;
	vector<ll>Rank;
	int N;
public:
	void init(int n) {
		N = n;
		par.resize(N + 1);
		Rank.resize(N + 1);
		for (int i = 0;i <= N;i++)par[i] = i, Rank[i] = 0;
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (Rank[x] < Rank[y])par[x] = y;
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int V, r, a, b;
double ans;
pp po[110];
vector<int>v[110];
map<P, int>mp;
vector<pair<double,P>>edge;

int main() {
	cin >> V >> r;
	for (int i = 0;i < V;i++) {
		cin >> po[i].x >> po[i].y;
		mp[P((int)po[i].x, (int)po[i].y)] = i;
	}
	for (int i = 0;i < r;i++) {
		cin >> a >> b;
		a--, b--;
		edge.eb(make_pair(dist(po[a], po[b]), P(a, b)));
	}
	vector<pp>qs = convex_full(po, V);
	Union_Find_Tree uf;
	uf.init(V);
	for (int i = 0;i < qs.size();i++) {
		ans += sqrt(dist(qs[i], qs[(i + 1) % qs.size()]));
		uf.unite(mp[P((int)qs[i].x,(int)qs[i].y)], mp[P((int)qs[(i + 1) % qs.size()].x,(int)qs[(i+1)%qs.size()].y)]);
	}
	sort(ALL(edge));
	for (auto u : edge) {
		if (uf.same(u.sc.fr, u.sc.sc))continue;
		uf.unite(u.sc.fr, u.sc.sc);
		ans += sqrt(u.fr);
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 3312
#include "bits/stdc++.h"
using namespace std;
#define r(i,a,n) for(int i=a;i<(int)(n);i++)
typedef long long ll;
int main(){
    int N;
    cin>>N;
    string ans="";
    if(N==0){
        cout<<0<<endl;
        return 0;
    }
    while(N!=0){
        if(N%(-2)!=0){
            N--;
            ans='1'+ans;
        }else{
            ans='0'+ans;
        }
        N=N/(-2);
    }
    cout<<ans<<endl;
    return 0;
}

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

vector<string>a;
int n,cnt=1;
string x;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	while(n--)cin>>x,a.push_back(x);
	sort(a.begin(),a.end());
	cout<<unique(a.begin(),a.end())-a.begin();
	return 0;
}

Measured memory_bytes: 11592
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    a, b = LI()

    a1 = a + b
    a2 = a - b
    a3 = a * b
    print(max(a3, max(a1, a2)))

solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    for(int i=0; i<=x; i++){
        for(int j=i; j<=x; j++){
            if((j*4+(x-j)*2)==y){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;

int n;

int main() {
  cin >> n;
  vector<double> v(n);
  rep(i, n) {
    cin >> v[i];
  }

  sort(v.begin(), v.end());
  double x = v[0];
  for (int i = 1; i < n; i++) {
    x = (x + v[i]) / 2.0;
  }

  cout << fixed;
  cout << setprecision(20) << x << endl;
}

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

bool search(int S[], int n, int key) {
	int i=0;
	S[n] = key;
	while (S[i] != key) i++;
	return i != n;	
}

int main(){
	int n, S[10001],q;
	int cnt = 0;
	int key;

	scanf("%d",&n);
	for (int i=0;i<n;i++)
	scanf("%d",&S[i]);
	
	scanf("%d",&q);
	for (int i=0;i<q;i++) {
	scanf("%d",&key);
	if (search(S,n,key)) cnt++;
	}

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

Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int ans = 0, res = 0;
  rep(i, n) {
    if (s[i] == 'I') res++;
    else res--;
    ans = max(ans, res);
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
import heapq
N,M = [ int(x) for x in input().split()]

AB = [ list(map(int, input().split())) for _ in range(N)]
AB.sort()
result = 0
# sort したABを押し上げるindex
i = 0
memo = []
# 制約のきついM-1日後(余裕日数1日)から数える
for x in range(M-1, -1, -1):
    allaw = M - x
    while i < N:
        ab = AB[i]
        limit, reward = ab
        if limit > allaw:
            # AB は sort してあるので、制約を超えたらそれ以上は見ない
            break
        else:
            # 日数制約を満たした仕事は全て heapq に入れられる
            heapq.heappush(memo, -reward)
            i += 1
    if memo:
        # heapq の特性により自動的に最小のもの（-を掛けているので最大のもの）から取り出される
        result += -heapq.heappop(memo)
print(result)


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = min(b, d) - max(a, c);

  cout << (ans > 0 ? ans : 0) << endl;
}


Measured memory_bytes: 256
(function(input) {
    var p = input.split('\n').map(Number);
    var n = p.shift();
    var a = p.slice(0, n);
    var pns = primeNumbers(a);
    console.log(pns.length);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function greatestCommonDevisor(x, y) {
    return Math.max.apply(null, commonDevisors(x, y));
}

function commonDevisors(x, y) {
    if (x > y) {
        x = x % y;
    } else if (x < y) {
        var tmp = y;
        y = x;
        x = tmp % x;
    }
    var a = [];
    var ds = divisors(x);
    for (var i = 0; i < ds.length ; i++) {
        var d = ds[i];
        if (y % d === 0) {
            a.push(i);
        }
    }
    return a;
}

function divisors(x) {
    var a = [];
    for (var i = 1; i <= x; i++) {
        if (x % i === 0) {
            a.push(i);
        }
    }
    return a;
}

function isPrimeNumber(x) {
    if (x < 2) {
        return false;
    }
    for (var i = 2; i < x; i++) {
        if (x % i === 0) {
            return false;
        }
    }
    return true;
}

function inArray(needle, heystack) {
    return heystack.indexOf(needle) !== -1;
}

function primeNumbers(x) {
    var a = {};
    for (var i = 2; i <= Math.sqrt(Math.max.apply(null, x)); i++) {
        a[i] = 1;
    }
    var d = {};
    for (var i = 0; i < x.length; i++) {
        var y = x[i];
        d[y] = 1;
    }

    var n = 2;
    do {
        for (var i = n * 2; i <= Math.sqrt(Math.max.apply(null, x)); i += n) {
            if (a[i] === 1) {
                delete a[i];
            }
        }
        for (var i in d) {
            if (Number(i) % n === 0 && Number(i) !== n) {
                delete d[i];
            }
        }
        var m = Math.max.apply(null, x);
        for (var i in a) {
            if (i > n && i < m) {
                m = Number(i);
            }
        }
        n = m;
    } while (n <= Math.sqrt(Math.max.apply(null, x)))
    return Object.keys(d).map(Number);
}

Measured memory_bytes: 18296
while True:
    a,op,b = input().split()
    if op == '?':
        break
    elif op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    else:
        print(int(int(a) / int(b)))


Measured memory_bytes: 5600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

var ans int

func main() {
	sc.Split(bufio.ScanWords)
	s := stringLineScan()
	init := make([]string, 0)
	stringSplitter(s, init)
	fmt.Println(ans)
}
func stringSplitter(str string, seed []string) {
	if str == "" {
		for _, i := range seed {
			n, _ := strconv.Atoi(i)
			ans += n
		}
	} else {
		if len(seed) == 0 {
			stringSplitter(str[1:], append(seed, string(str[0])))
		} else {
			stringSplitter(str[1:], append(seed, string(str[0])))
			seed[len(seed)-1] = seed[len(seed)-1] + string(str[0])
			stringSplitter(str[1:], seed)
		}
	}
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (sc.hasNext()) {
            sb.append(sc.nextLine().toLowerCase());
        }
        String s = sb.toString();
        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            int point = s.codePointAt(i);
            if (97 <= point && point <= 122) {
                count[point - 97]++;
            }
        }
        for (int i = 0; i < count.length; i++) {
            System.out.println(Character.toChars(i + 97)[0] + " : " + count[i]);
        }
    }
}

Measured memory_bytes: 26180
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, m;
	cin >> n >> m;
	char d[4] = {};
	rep(i, 4)d[i] = '\0';
	rep(i, m) {
		int s;
		char c;
		cin >> s;
		cin.ignore();
		cin >> c;
		s--;
		if (d[s] != '\0' && d[s] != c) {
			cout << -1 << endl;
			return 0;
		}
		if (n!=1 && s == 0 && c == '0') {
			cout << -1 << endl;
			return 0;
		}
		d[s] = c;
	}
	
	if (n !=1 && d[0] == '\0') d[0] = '1';
	rep(i, n)if (d[i] == '\0')d[i] = '0';

	cout << d << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Vector.Unboxed.Mutable (STVector)
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = solve <$> readLn >>= print

solve :: Int -> Int
solve n = runST $ do
  sv <- sieve 100003
  loop sv n
  where
    loop sv i = do
      b <- VM.read sv i
      if b then return i
        else loop sv (i + 1)

sieve :: Int -> ST s (STVector s Bool)
sieve n = do
  sv <- VM.replicate (n + 1) True
  VM.write sv 0 False
  VM.write sv 1 False
  forM_ ixs $ \i -> do
    b <- VM.read sv i
    when b $ forM_ [i * i, i * i + i .. n] $ \j -> VM.write sv j False
  return sv
  where
    ixs = takeWhile ((<= n) . (^2)) [2..]


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

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

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

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

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

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

vector<ll>relation[20], money(20, 1);

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll r = 0, g = 0, b = 0;
	rep(i, n) {
		if (s[i] == 'R')r++;
		else if (s[i] == 'G')g++;
		else b++;
	}
	ll ans = r * b * g;
	for (int i = 0;i < n - 2;++i) {
		for (int j = i + 1;j < n - 1;++j) {
			if (s[i] != s[j]) {
				if (2 * j - i < n) {
					if (s[2 * j - i] != s[i] && s[2 * j - i] != s[j])ans--;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stack>
using namespace std;
stack <int>reversh_polish;//不返回值
int main(void)
{
	int a, b;
	char s[100];

	while (scanf("%s", s) != EOF)
	{
		if (s[0] == '+')
		{
			a = reversh_polish.top();
			reversh_polish.pop();
			b = reversh_polish.top();
			reversh_polish.pop();
			reversh_polish.push(a + b);
		}
		else if (s[0] == '-')
		{
			a = reversh_polish.top();
			reversh_polish.pop();
			b = reversh_polish.top();
			reversh_polish.pop();
			reversh_polish.push(b - a);
		}
		else if (s[0] == '*')
		{
			a = reversh_polish.top();
			reversh_polish.pop();
			b = reversh_polish.top();
			reversh_polish.pop();
			reversh_polish.push(b * a);
		}
		else if (s[0] == '/')
		{
			a = reversh_polish.top();
			reversh_polish.pop();
			b = reversh_polish.top();
			reversh_polish.pop();
			reversh_polish.push(a / b);
		}
		else
		{
			reversh_polish.push(atoi(s));
		}
	}
	printf("%d\n", reversh_polish.top());
	//system("pause");
	                                                                           
	return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

#define MAX 200000
#define SENTINEL 2000000000
typedef long long ll;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

ll merge(int A[], int n, int left, int mid, int right) {

    int i, j, k;
    ll cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;

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

    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    i = 0;
    j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

ll mergeSort(int A[], int n, int left, int right) {

    int mid;
    ll v1, v2, v3;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    } else {
        return 0;
    }
}

int main() {

    int n;
    cin >> n;

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

    ll ans = mergeSort(A, n, 0, n);
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 4660
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli n;
lli a[4][N];
lli cache[4][N];

lli dp(lli idx, lli prev) {

    if(idx > n + 1) {
        return 0;
    }

    lli &ans = cache[prev][idx];

    if(ans != -1) {
        return ans ;
    }

    ans = 0;

    for(int i = 1; i <= 3; i ++) {

        if(prev == i)
            continue ;
        ans = max(ans, a[i][idx] + dp(idx + 1, i));
    }

    return ans ;

}

void solve()
{

    cin>>n;

    memset(cache, -1, sizeof cache);

    for(int j = 1; j <= n; j ++) {
        for(int i = 1; i <= 3; i ++) {
            cin>>a[i][j];
        }
    }

    lli ans = dp(1, 0);

    cout<<ans;

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=307;
int a[4],n;
double dp[N][N][N];

double dfs(int a,int b,int c){
	if(dp[a][b][c]) return dp[a][b][c];
	if(a==0&&b==0&&c==0) return 0.0;
	double res=0;
	if(a) res+=dfs(a-1,b,c)*a;
	if(b) res+=dfs(a+1,b-1,c)*b;
	if(c) res+=dfs(a,b+1,c-1)*c;
	res+=1.0*n,res/=(a+b+c);
	return dp[a][b][c]=res;
}

int main(){
	n=input();
	for(int i=1;i<=n;i++)a[input()]++;
	printf("%.10lf\n",dfs(a[1],a[2],a[3]));
}

Measured memory_bytes: 221440
#include <iostream>
#include <string>

int main() {
	std::string s[3];

	for (auto&& v : s)
		std::cin >> v;

	int now = 0;
	int prog[3] = {};
	while (prog[now] != s[now].size()) {
		++prog[now];
		now = (
			s[now][prog[now] - 1] == 'a' ? 0
			: s[now][prog[now] - 1] == 'b' ? 1
			: 2
			);
	}

	std::cout << (
		now == 0 ? 'A'
		: now == 1 ? 'B'
		: 'C'
		)
		<< std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();

        for(;;){
            c = c - b;
            if(c <= 0){
                System.out.println("Yes");
                break;
            }
            a = a - d;
            if(a <= 0){
                System.out.println("No");
                break;
            }
        }
    }
}

Measured memory_bytes: 35748
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p,ll mod)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,mod);
	z=(z*z)%mod;
	if(p%2) z=(z*a)%mod;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	int x,n;
	cin>>x>>n;
	set<int> S;

	for(int i=0;i<105;i++) S.insert(i);

	for(int i=0;i<n;i++)
	{
		int p;
		cin>>p;
		if(S.count(p)) S.erase(p);
	}
	int ans=-1;
	int diff=MOD;
	for(auto num:S)
	{
		if(abs(num-x)<diff)
		{
			ans=num;
			diff=abs(num-x);
		}
	}
	cout<<ans<<endl;
}		

Measured memory_bytes: 7024