akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define sz(v) (int)(v).size()
using vi = vector < int >;
using vii = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';


int dp[101000];


void dfs(vi edg[], vi &vis, int u) {
	vis[u] = 1;
	for (auto e : edg[u]) {
		if (!vis[e]) {
			dfs(edg, vis, e);
		}
		if (dp[u] < 1 + dp[e]) {
			dp[u] = 1 + dp[e];
		}
	}
}




void calc(vi edg[], int n) {
	vi vis(n + 1, 0);
	for1(i, n) {
		if (!vis[i]) {
			dfs(edg, vis, i);
		}
	}

}




int main() {
// #ifndef ONLINE_JUDGE
// 	if (fopen("input.txt", "r")) {
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	}
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n, m;
	cin >> n >> m;
	vi edge[n + 1];
	for0(i, m) {
		int x, y;
		cin >> x >> y;
		edge[x].pb(y);
	}

	calc(edge, n);
	int a = 0;
	for1(i, n) {
		if (a < dp[i])
			a = dp[i];
	}
	cout << a;

	return 0;
}



Measured memory_bytes: 9216
#include <stdio.h>
#include <string.h>

char table[6][7] = {
	{ '0', '0', '0', '0', '0', '0', '0' },
	{ '0', 'a', 'f', 'k', 'p', 'u', 'z' },
	{ '0', 'b', 'g', 'l', 'q', 'v', '.' },
	{ '0', 'c', 'h', 'm', 'r', 'w', '?' },
	{ '0', 'd', 'i', 'n', 's', 'x', '!' },
	{ '0', 'e', 'j', 'o', 't', 'y', ' ' },
};

int main()
{
	char str[300] = {} ;
	int length = 0, i;
	char message[201];

	while ( fgets( str, sizeof( str ), stdin  ) ) {
		if ( ( length = strlen( str ) - 1 ) % 2 ) {
			printf( "NA\n" );
			continue;
		}

		i = 0;
		memset( ( void * ) message, 0, strlen(message) );

		while ( i < length ) {
			// printf( "%c %c %c\n", str[i], str[i+1], table[str[i+1]-'0'][str[i]-'0'] );
			if ( str[i]-'0' > 0 && str[i]-'0' < 7 && str[i+1]-'0' > 0 && str[i+1]-'0' < 6 ) {
				message[i/2] = table[str[i+1]-'0'][str[i]-'0'];
				i += 2;
			} else {
				printf( "NA\n" );
				i = -1;
				break;
			}
		}

		if ( i == -1 ) {
			continue;
		} else {
			i++;
			message[i/2] = 0;
			printf( "%s\n", message );
		}
	}
	return 0;
}



Measured memory_bytes: 1972
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int a, b;
	string s, t, u;
	cin >> s >> t >> a >> b >> u;
	if (u == s) {
		a--;
	}
	if (t == u) {
		b--;
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

A, B, X = map(int, input().split())
if A**2*B/2 > X:
    d = X*2/B/A
    ans = np.arctan(B/d)/np.pi*180
else:
    d = X*2/A/A - B
    ans = np.arctan((B-d)/A)/np.pi*180
print(ans)

Measured memory_bytes: 21388
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator

from fractions import gcd


inf = float('inf')


# globals
N, X = 0, 0
C = []


def set_inputs():
    global N, X, C
    N, X = get_li()
    C = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    ans = reduce(gcd, filter(lambda x: x != 0, map(lambda x: abs(x-X), C)))
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16320
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
		int n,p[15];
		int max_val = 0, num;
		cin >> n;
		REP(i, n) {
			cin >> p[i];
			if (max_val < p[i]) {
				max_val = p[i];
				num = i;
			}
		}
		int sum = 0;
		REP(i, n) {
			if (i == num) {
				sum += p[i] / 2;
			}
			else
				sum += p[i];
		}
		cout << sum << endl;
		return 0;

}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

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

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

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

    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
        // cout << S[i] << endl;
    }

    map<string, ll> counter;
    for (int i = 0; i < (int) S.size(); i++) {
        counter[S[i]]++;
    }

    ll answer = 0;
    for (auto &p : counter) {
        ll x = p.second;
        answer += (x * (x - 1)) / 2;
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
	ll n,k,q;
	cin >> n >> k >> q;
	ll a[100010];
	ll v[100010];
	FOR(i,100010)v[i]=k-q;
	FOR(i,q){
		cin >> a[i];
		v[a[i]]+=1;
	}
	for(int i=1;i<=n;i++){
		if(v[i]>0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 2176
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 7)


def LI(): return list(map(int, stdin.readline().split()))


inf = 1000000007


def main():
    N, K = LI()
    graph = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = LI()
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)

    stack = [0]
    ans = 1
    done = [False] * N
    while len(stack) > 0:
        now = stack.pop()
        done[now] = True
        cnt = 0
        for x in graph[now]:
            if not done[x]:
                cnt += 1
                stack.append(x)
        if now == 0:
            for i in range(cnt):
                ans = (K - 1 - i) * ans % inf
        else:
            for i in range(cnt):
                ans = (K - 2 - i) * ans % inf
    print(ans * K % inf)


if __name__ == "__main__":
    main()

Measured memory_bytes: 65072
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N, W;
	cin >> N >> W;

	ll VMAX = 100 * 1000;
	ll WMAX = 100100100100;

	vector<vector<ll>> weight(N+1, vector <ll> (VMAX+1, WMAX));
	for (int ii = 0; ii <= N; ++ii){
		weight[ii][0] = 0;
	}

	for (int idx = 1; idx <= N; ++idx){
		ll w, v;
		cin >> w >> v;

		for (int value = 0; value <= VMAX; ++value){
			if (value < v){
				weight[idx][value] = weight[idx-1][value];
			} else {
				weight[idx][value] = min(weight[idx-1][value], weight[idx-1][value-v] + w);
			}
		}
	}

	for (ll value = VMAX; value >= 0; --value){
		if (weight[N][value] <= W){
			cout << value << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int a, b, c, x, y;
int ans;

int main() {
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &x);
  scanf("%d", &y);
  if(c * 2 >= a + b) {
    ans += a * x;
    ans += b * y;
    printf("%d\n", ans);
    return 0;
  } else {
    if(x < y) {
      ans += c  * 2 * x;
      if(c * 2 >= b) {
        ans += b * (y - x);
      } else {
        ans += c * 2 * (y - x);
      }
    } else {
      ans += c * 2 * y;
      if(c * 2 >= a) {
        ans += a * (x - y);
      } else {
        ans += c * 2 * (y - x);
      }
    }
    printf("%d\n", ans);
    return 0;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	int i, u, v;
	for ( i = 0; i < n; i++ ) d[i] = INFTY;
	d[s] = 0;

	while ( !q.empty() ) {
		u = q.front();
		q.pop();
		for ( v = 0; v < n; v++ ) {
			if ( M[u][v] == 0 ) continue;
			if ( d[v] != INFTY ) continue;
			d[v] = d[u] + 1;
			q.push(v);
			}
		}

		for ( i = 0; i < n; i++ ) {
			cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
	}
}

int main() {
	int u, k, v, i, j;

	cin >> n;

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

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

	bfs(0);

	return 0;
}

Measured memory_bytes: 3156
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n = readln.chomp.to!int;
	int[] as = readln.chomp.split.map!(to!int).array;
	
	int minsum = int.max;
	for(int i = -100; i <= 100; i ++){
		int sum = 0;
		foreach(a; as) sum += (a - i) * (a - i);
		if(sum < minsum) minsum = sum;
		}
	
	minsum.writeln;
	
	}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

int N, M;
vector<double> L, A, B;
void input() {
    cin >> N >> M;
    L.resize(N);
    A.resize(N);
    B.resize(N);
    for (int i = 0; i < N; i++) 
        cin >> L[i] >> A[i] >> B[i];
}

double Calc(int bit) {
    vector<int> X;
    for (int i = 0; i < N; i++) {
        if (bit & (1 << i)) {
            X.push_back(i);
        }
    }
    double Ret = 0;
    for (int i = 0; i < M; i++) {
        for (int j = i + 1; j < M; j++) {
            int a = X[i],
                b = X[j];
            Ret += (L[a] - L[b]) * (L[a] - L[b]) + (A[a] - A[b]) * (A[a] - A[b]) + (B[a] - B[b]) * (B[a] - B[b]);
        }
    }
    return Ret;
}

void solve() {
    double Ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        if (__builtin_popcount(i) != M) continue;
        Ans = max(Ans, Calc(i));
    }
    printf("%.8f\n", Ans);
}

int main() {
    input(); solve();
    return 0;
}

Measured memory_bytes: 1272
class BiCoeff(object):
    def __init__(self, MAX, m):
        super(BiCoeff, self).__init__()
        fac = [0]*MAX
        finv = [0]*MAX
        inv = [0]*MAX

        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2,MAX):
            fac[i] = (fac[i-1]*i)%m
            inv[i] = m - (inv[m%i] * (m//i))%m
            finv[i] = (finv[i-1] * inv[i])%m

        self.MAX = MAX
        self.m = m
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def calc(self,n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return (self.fac[n] * (self.finv[k]*self.finv[n-k])%self.m)%self.m

mod = 10**9 + 7
k = int(input())
s = input()
n = len(s)

b = BiCoeff(n+k+10, mod)
res = 0
for t in range(k+1):
    res += b.calc(n+k - (t+1), k-t)*pow(25,k-t,mod)*pow(26,t,mod)
    res %= mod
print(res)

Measured memory_bytes: 117756
import math
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N, M = read_ints()
    A = read_ints()
    BC: List[List[int]] = []
    for _ in range(M):
        BC.append(read_ints())
    A.sort()
    BC.sort(key=lambda pair: pair[1])
    chosen = 0
    answer = 0

    def pop_bc():
        nonlocal answer
        bc = BC.pop()
        bc[0] -= 1
        if bc[0] > 0:
            BC.append(bc)
        return bc[1]

    while chosen < N:
        if A and BC:
            if A[-1] > BC[-1][1]:
                answer += A.pop()
            else:
                answer += pop_bc()
        elif A:
            answer += A.pop()
        else:
            answer += pop_bc()
        chosen += 1
    return answer


if __name__ == '__main__':
    print(solve())


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




void solve()
{
       int n,k;
       cin >> n >> k ;
       int w[n],v[n];

       for(int i = 0 ; i < n ; i ++) cin >> w[i] >> v[i];
       
       vector< vector<long int> > memo(n+1, vector< long int> (k+1,0));
      
      
      auto print = [&]()
      {
          for(int i = 0 ; i <= n ; i ++)
          {
              for(int j = 0 ; j <= k; j ++)
              {
                  cout << memo[i][j] << "   ";
              }
              
              cout << endl; 
          }
      };
      
      for(int i = 1; i <= n ; i ++)
           for(int j = 1 ; j <= k ; j ++)
              if( j-w[i-1] < 0 ) 
                 memo[i][j] = memo[i-1][j]; 
           	  else 
           	    memo[i][j] = max({memo[i-1][j], v[i-1] + memo[i-1][j-w[i-1]]}); 
      
      
      //print(); 

      cout << memo[n][k] ;



}

int main()
{

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

	 int test = 0, t = 1;
	 if(test) cin >> t;
	 for(int i = 0 ; i < t ; i ++)
	 {
         solve(); 
	 }

	return 0;
}


Measured memory_bytes: 82980
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    def dfs(start):
        stack=[start]
        used=[False]*N
        d=[-1]*N
        d[start]=0
        while stack:
            node=stack.pop()
            used[node]=True
            for x in cns[node]:
                if not used[x]:
                    d[x]=d[node]+1
                    stack.append(x)
        return d
    
    N,u,v=map(int,input().split())
    u-=1
    v-=1
    A,B=[0]*(N-1),[0]*(N-1)
    cns=[[] for _ in range(N)]
    for i in range(N-1):
        A[i],B[i]=map(lambda x: int(x)-1,input().split())
        cns[A[i]].append(B[i])
        cns[B[i]].append(A[i])

    u_l = dfs(u)
    v_l = dfs(v)
    ans=0
    for U,V in zip(u_l,v_l):
        if V > U:
            ans=max(ans,V-1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64056
#include<bits/stdc++.h>
using namespace std ;
int n,t,a[100001],ans=0,maxx=0,anss=0;
int main()
{
    scanf("%d%d",&n,&t);
    for(register int i=1;i<=n;++i)
	{
		scanf("%d",a+i) ;
	}
    for(register int i=n;i;--i)
	{
        maxx=max(a[i],maxx);
        ans=max(maxx-a[i],ans);
    }
    maxx=0;
    for(register int i=n;i;--i)
	{
        maxx=max(a[i],maxx);
        if(maxx-a[i]==ans)anss++;
    }
    printf("%d\n",anss);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
#define END "\n"
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<ii> vii;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////



int main()
{
    fast
    #ifdef ANUBHAB
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    string s;
    int flag1 = 0, flag2 = 0;
    cin >> s;
    for (int i = 0; i < s.size(); ++i)
    {
      if (s[i] == 'A')
        flag1 = 1;
      if (s[i] == 'B')
        flag2 = 1;
    }
    if (flag1 && flag2)
      cout << "Yes";
    else cout << "No";
    return 0;
}

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

void merge(vector<int> &n, int left, int mid, int right)
{
	int num = right - left;
	int *tmp = new int[num];

	int iw = 0;
	int il = left;
	int ir = mid;

	while (il < mid && ir < right)
	{
		if (n[il] <= n[ir])
		{
			tmp[iw++] = n[il++];
		}
		else {
			tmp[iw++] = n[ir++];
		}
	}

	while (il < mid) tmp[iw++] = n[il++];
	while (ir < right) tmp[iw++] = n[ir++];

	for (int i = 0; i<num; i++) n[left + i] = tmp[i];

	delete[] tmp;
}


void merge_sort_sub(vector<int> &n, int left, int right)
{
	if (right - left <= 1) return;

	int mid = left + (right - left) / 2;
	merge_sort_sub(n, left, mid);
	merge_sort_sub(n, mid, right);

	merge(n, left, mid, right);
}


void merge_sort(vector<int> &n, int len)
{
	merge_sort_sub(n, 0, len);
}


int main()
{
	int N; 
	cin >> N;
	vector<int> a(N);

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

	merge_sort(a, N);

	double A[2] = { 0.0,0.0 };
	double B[2] = { 0.0,0.0 };
	double C[2] = { 0.0,0.0 };
	double D[2] = { 0.0,0.0 };
	int min = 1000000;
	int used[2] = { 0,0 };
	
	A[0] = a[N - 1];
	B[0] = a[N - 2];

	for (int i = 0; i < N - 3; i++) {
		if ((a[i+1] - a[i]) < min) {
			C[0] = (double)a[i+1];
			D[0] = (double)a[i];
			min = a[i+1] - a[i];
		}
	}
	
	min = 1000000;
	for (int i = 0; i < N - 1; i++) {
		if ((a[i+1] - a[i]) < min) {
			C[1] = (double)a[i+1];
			D[1] = (double)a[i];
			min = a[i+1] - a[i];
			used[0] = i+1;
			used[1] = i;
		}
	}
	a.erase(a.begin() + used[0]);
	a.erase(a.begin() + used[1]);

	A[1] = (double)a[N - 4];
	B[1] = (double)a[N - 3];

	double data1 = (double)((A[0] + B[0]) / (C[0] - D[0]));
	double data2 = (double)((A[1] + B[1]) / (C[1] - D[1]));

	std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
	if (data1 < data2)
		cout << data2 << endl;
	else
		cout << data1 << endl;
	return 0;
}

Measured memory_bytes: 3300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * A Fat Wallet - Accepted
 * PCK2014 ??????2
 */
public class Main {

	static final int[] coins = new int[]{1, 5, 10, 50, 100, 500};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		words = br.readLine().split(" ");

		int sum = 0;
		for (int i = coins.length - 1; i >= 0; i--) {
			sum += parseInt(words[i]) * coins[i];
			if (sum >= 1000) break;
		}
		System.out.println(sum < 1000 ? 0 : 1);
	}
}

Measured memory_bytes: 24288
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,count=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='R')count++;
    }
    if(count>n-count){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

int main() {
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0); // cin??¨cout?????£????????????
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;
	vector<char> c(n); REP(i, n) cin >> c[i];

	// dp[0~i???][??°????????????????????????????£???°][??°????????????????????????????£???°]
	vector<vvl> dp(n+1, vvl(n+1, vl(n+1, 0))); dp[0][0][0] = 1;
	ll mod = TEN(9) + 7;
	REP(i, n) REP(j, n) REP(k, n) {
		if (c[i] == '-') {
			(dp[i+1][j][k] += dp[i][j][k]) %= mod;
		}  else if (c[i] == 'U') {
			(dp[i+1][j+1][k+1] += dp[i][j][k]) %= mod;          // ????????§?????????????????£?????????????????°??????????????´???
			if(j!=0) (dp[i+1][j][k] += dp[i][j][k] * j) %= mod; // ????????§?????????????????£?????????????????°??????????????´???
		} else if (c[i] == 'D' && k > 0){
			(dp[i+1][j][k] += dp[i][j][k] * k) %= mod;                  // ????????§?????????????????£?????????????????°??????????????´???
			if(j!=0) (dp[i+1][j-1][k-1] += dp[i][j][k] * k * j) %= mod; // ????????§?????????????????£?????????????????°??????????????´???
		}
	}

	cout << dp[n][0][0] << endl;

	return 0;
}

Measured memory_bytes: 67812
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	string s;
	cin >> s;
	int n = s.size();
	cout << s[0] << n - 2 << s[n - 1];
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	string s;
	cin >> s;
	int lo = 0, hi = s.size() - 1;
	int ans = 0;
	while(lo <= hi){
		if(s[lo] != s[hi])
			ans++;
		lo++;
		hi--;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a*b,a-b))<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    cin.tie(NULL);
    ios::sync_with_stdio(false);
	#if LOCAL
	freopen("d.in", "r", stdin);
	#endif
	ll A,B,res=0;
	cin>>A>>B;

    function<ll(ll)> f1 = [&](ll a) {
        ll r[] = {a,1,a+1,0};
        return r[a%4];
    };

    if(A<1)A=1;
    if(B<A)res=0;
    else res=(f1(B)^f1(A-1));

    cout<<res<<endl;

	return 0;
}



Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(N: Int, A: Array<IntArray>){
    var ans = 0
    for (i in 0 until N){
        val sum1 = A[0].filterIndexed{ index, value -> index <= i }.sum()
        val sum2 = A[1].filterIndexed{ index, value -> index >= i }.sum()
        ans = Math.max(ans, sum1 + sum2)
    }
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val A = Array<IntArray>(2.toInt()){ IntArray(N) }
    for (i in 0 until 2.toInt()) {
        for (j in 0 until N) {
            A[i][j] = sc.next().toInt()
        }
    }
    solve(N, A)
}



Measured memory_bytes: 31496
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    int h=0,s,m;
    scanf("%d %d",&a,&b);
    h=a+b;
    s=a-b;
    m=a*b;
    if(h>=s&&h>=m)
        printf("%d",h);
    if(s>h&&s>m)
        printf("%d",s);
    if(m>s&&m>h)
        printf("%d",m);
    return 0;
}

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

typedef long long ll;

int main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    
    bool center = false;
    if (x + x == W && y + y == H) center = true;
    
    if (center) {
        printf("%lf %d\n", double(W)*double(H)/2, 1);
    } else {
        printf("%lf %d\n", double(W)*double(H)/2, 0);
    }
    
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26;

int d;
int c[A],s[D][A],last[A];

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

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j],
        last[j]=-1;
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]+c[j]*(i-last[j])>
               s[i][best]+c[best]*(i-last[best]))
                best=j;
        last[best]=i;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
int main(){
  int m,i,j;
  string str,t1,t2,t3,t4;
  cin>>m;
  while(m--){
    set<string> v;
    cin>>str;
    for(i=0;i<str.size()-1;i++){
      t1=str.substr(0,i+1);
      t2=str.substr(i+1);
      t3=t1;
      t4=t2;
      reverse(t3.begin(),t3.end());
      reverse(t4.begin(),t4.end());
      v.insert(t1+t2);
      v.insert(t2+t1);
      v.insert(t3+t2);
      v.insert(t2+t3);
      v.insert(t1+t4);
      v.insert(t4+t1);
      v.insert(t3+t4);
      v.insert(t4+t3);
    }
    cout<<v.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>
int max(int a, int b){
    return a>b ? a: b;
}

int main()
{
    int last=0, atu=0;
    int moves = 0, maxi = 0;
    int qmt;
    scanf("%d",&qmt);
    for(int i = 0; i < qmt; ++i){
        last = atu;
        scanf("%d", &atu);
        if(last>=atu){
            moves++;
            maxi= max(maxi, moves);
        }else moves = 0;
    }
    printf("%d", maxi);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int p[100005];
bool judge(int n)
{
    int b;
    int flag=1;
    while(n)
    {
        b=n%10;
        if(p[b])
        {
             return false;
        }
          n/=10;
    }
    return true;
}
int main()
{
    int N,K;
    int m;
    while(scanf("%d%d",&N,&K)!=EOF)
    {
        memset(p,0,sizeof(p));
        for(int i=0;i<K;i++)
        {
              scanf("%d",&m);
              p[m]=1;
        }
         for(int i=N;;i++)
         {
             if(judge(i))
             {
                 printf("%d\n",i);
                 break;
             }
         }
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
using namespace std;
 
int main(void) {
  int N;
  int A[100001];
  
  cin >> N;
  for(int i = 1; i <= N; i++) {
    int a;
    cin >> a; 
    A[a] = i;
  }
  for(int i = 1; i <= N; i++) {
    cout << A[i] << " ";
  }
  
 
  return 0; 
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll mod = 998244353;
vector<int> a(4000);
int n,s;
ll dp[4000][4000][3];
int ways(int l,int r,int S){
    if(S == 0){
        return 1;
    }
    if(r == l){
        return 0;
    }
    return ways(l,r-1,S) + (S>=a[r-1]?ways(l,r-1,S-a[r-1]):0);
}



int main(){
    cin >> n >> s;
    for(int i = 0;i<n;++i){
        cin >> a[i];
    }
   
    /*
     int ans  = 0;
    for(int i = 0;i<n;++i){
        for(int j = i;j < n;++j){
            ans += ways(i,j+1,s);
            if(ans >= mod){
                ans-=mod;
            }
        }
    }
    
    cout << ans <<"\n";
    */
   auto add =[&](ll &x,vector<ll> to){
       for(ll y : to){
            x += y;
            if(x >= mod){
                x-=mod;
            }
       }
   };
   
   memset(dp,0LL,sizeof dp);
   dp[0][0][0] = 1;
   for(int i = 0;i<n;++i){
       for(int j = 0;j<=s;++j){
            add(dp[i+1][j][0],{dp[i][j][0]});
            add(dp[i+1][j][1],{dp[i][j][0],dp[i][j][1]});
            add(dp[i+1][j][2],{dp[i][j][0],dp[i][j][1],dp[i][j][2]});
            if(j + a[i] <= s){
                add(dp[i+1][j+a[i]][1],{dp[i][j][0] , dp[i][j][1]});
                add(dp[i+1][j+a[i]][2],{dp[i][j][0] , dp[i][j][1]});
            }  
       }
   }
   cout << dp[n][s][2] <<"\n";
    return 0;    
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

int bo[2][310][310];
bool f[310][310];

void solve() {
  int N; cin >> N;
  vector<vector<int>> bo[2];
  bo[0] = vector<vector<int>>(N, vector<int>(N));
  rep(i, N) rep(j, N) {
    int a; cin >> a; bo[0][i][j] = a;
  }
  bo[1] = bo[0];
  rep(k, N) rep(i, N) rep(j, N) amin(bo[1][i][j], bo[1][i][k] + bo[1][k][j]);
  rep(i, N) rep(j, N) {
    if (bo[0][i][j] != bo[1][i][j]) {
      cout << -1 << '\n';
      return;
    }
  }
  i64 sum = 0;
  rep(i, N) rep(j, N) sum += bo[0][i][j];
  cerr << sum << '\n';
  rep(k, N) rep(i, N) rep(j, N) {
    if (k == i || i == j || j == k) continue;
    if (f[i][j]) continue;
    if (bo[0][i][j] == bo[0][i][k] + bo[0][k][j]) {
      sum -= bo[0][i][j];
      f[i][j] = true;
    }
  }
  cout << sum / 2 << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    uf.unite(a, b);
  }
  int ans = 0;
  rep(i,n) ans = max(ans, uf.size(i));
  cout << ans << endl;
}

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

bool is_harshad(int n){
    int s=0,t=n;
  for(int i=0;i<=8;i++){
    s+=t%10;t/=10;
  }
  if(n%s==0)return true;
  else return false;
}
int main(){
  int n;cin>>n;
  cout<<(is_harshad(n)?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll x;
    cin >> x;
    rep1(a, 1000) {
        ll a5 = 1;
        rep(i, 5) a5 *= a;
        for (int b=-1000; b<=1000; ++b) {
            ll b5 = 1;
            rep(i, 5) b5 *= b;
            if (a5 - b5 == x) {
                printf("%d %d\n", a, b);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3740
#include <cstdio>
#include <cctype>
#include <array>
#include <set>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int n = 0, c = gcu();
	// bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
//template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

struct board {
	enum {size = 3};
	struct pos {int r, c;};
	typedef array<array<int, size>, size> arr;
	arr b;
	pos p;
	int max;
	int cnt = 0;

	int f(arr &a) {
		int l = 0;
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				int c = a[i][j];
				if (c == 0)
					c = size * size - 1;
				else
					c--;
				l += abs(i - c / 3) + abs(j - c % 3);
			}
		return l;
	}

	void read() {
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				b[i][j] = in();
				if (!b[i][j])
					p.r = i, p.c = j;
			}
		max = f(b);
	}
	void print() {
		for (auto &r: b) {
			for (int &c: r)
				out(&c == &r[0]?"":" ", c);
			out('\n');
		}
		out('\n');
	}


	int solver() {
		set<arr> m;
		queue<board> q;
		q.push(*this);
		while (!q.empty()) {
			board a = q.front();
			q.pop();
//			a.print();
			int dis = f(a.b);
			if (dis > max + 10 - a.cnt / 1.5)
				continue;
//			out(dis, "\n");
			auto it = m.find(a.b);
			if (it != m.end())
				continue;
			m.insert(a.b);
			if (!dis)
				return a.cnt;
			pos to[] = {
				a.p.r + 1, a.p.c,
				a.p.r, a.p.c + 1,
				a.p.r - 1, a.p.c,
				a.p.r, a.p.c - 1
			};
			for (pos o: to) {
				if (0 <= o.r && o.r < size && 0 <= o.c && o.c < size) {
					board c = a;
					swap(c.b[a.p.r][a.p.c], c.b[o.r][o.c]);
					c.p = o;
					c.cnt = a.cnt + 1;
					q.push(c);
				}
			}
		}
		return -1;
	}
};

int main() {
	board b;
	b.read();
	out(b.solver(), '\n');
}


Measured memory_bytes: 16076
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

char c[3][3];

int main()
{
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 0; i < 3; i++) {
        cout << c[i][i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int r = sc.nextInt();

        if (r%2 == 0)
            System.out.println(r/2);
        else
            System.out.println((r/2)+1);
    }
}


Measured memory_bytes: 35600
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

char s[500111];
int n,dp[500111];
vector<int> seg[500111];
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='0'&&s[i-1]=='1'&&s[i+1]=='1')
		{
			for(int j=i-1;j>=1&&s[j]=='1';j--)seg[i+1].pb(j);
			for(int j=i+1;j<=n&&s[j]=='1';j++)seg[j].pb(i-1);
		}
	}
	for(int i=1;i<=n;i++)
	{
		dp[i]=dp[i-1];
		for(auto x:seg[i])
			dp[i]=max(dp[i],dp[x-1]+i-x-1);
	}
	printendl(dp[n]);
	return 0;
}

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

int main()
{
	int n = 0, x = 0, a[1000] = { 0 }, count = 0, count2;

	while (1){
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		a[count] = n, a[++count] = x;
		count++;
	}

	int i = 0;
	while (i < count){
		count2 = 0;
		for (int j = 1; j < a[i] - 1; j++){
			for (int k = j + 1; k < a[i]; k++){
				for (int l = k + 1; l <= a[i]; l++){
					if (j + k + l == a[i + 1]) count2++;
				}
			}
		}
		cout << count2 << endl;
		i += 2;
	}

	return 0;
}

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

unsigned long long GCD(unsigned long long a, unsigned long long b) {
	if (a < b) return GCD(b, a);
	if (b == 0) return a;
	return GCD(b, a % b);
}

int main() {
	unsigned long long a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	unsigned long long g = c * d / GCD(c, d);

	unsigned long long
		ad = a - (a / c + a / d - a / g);
	unsigned long long
		bd = b - (b / c + b / d - b / g);


	cout << bd - ad << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, a;
  scanf("%d" , &n);
  scanf("%d" , &a);
  while(n >= 0) n -= 500;
  n += 500;
  if(n <= a) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
N,M,K=map(int,input().split())
par=[0]*(N+1)
num=[0]*(N+1)
group = [1]*(N+1)

for i in range(1,N+1): par[i]=i

def root(x):
  if par[x]==x: return x
  return root(par[x])

def union(x,y):
  rx = root(x)
  ry = root(y)
  if rx==ry: return
  par[max(rx,ry)] = min(rx,ry)
  group[min(rx,ry)] += group[max(rx,ry)]

def same(x,y):
  return root(x)==root(y)     

for _ in range(M):
  a,b=map(int,input().split())
  union(a,b)
  num[a]+=1
  num[b]+=1
for _ in range(K):
  c,d=map(int,input().split())
  if same(c,d):
    num[c]+=1
    num[d]+=1

for i in range(1,N+1):
  print(group[root(i)]-num[i]-1,end=" ")

Measured memory_bytes: 14540
N = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]
B = []
for i in range(1,len(A)):
    B.append(abs(A[i]-A[i-1]))
S = sum(B)
for i in range(N):
    print(S-abs(A[i]-A[i+1])-abs(A[i+1]-A[i+2])+abs(A[i]-A[i+2]))


Measured memory_bytes: 92872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {int A,B,C,D,E,max;
        var word = Console.ReadLine().Split(' ');
        A = int.Parse(word[0]);
        B = int.Parse(word[1]);
        C = A + B; 
        D = A - B;
        E = A * B;
        max = C;
        if (max < D) max = D;
        if (max < E) max = E;
        Console.WriteLine(max);
        Console.ReadKey();
        }
    }
}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)



signed main(){

	int N;
	int l[11];
	cin >> N;
	for (int i = 0; i < N; i++)cin >> l[i];
	sort(l, l + N, greater<int>());
	int sum = 0;
	for (int i = 1; i < N; i++)
		sum += l[i];

	cout << (sum<=l[0]? "No" : "Yes") << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
wa=[0]*(N-1)
wa[0]=A[-1]
for i in range(1,N-1):
    wa[i]=wa[i-1]+A[N-i-1]
ans=0
wa.reverse()

for i in range(0,N-1):

    ans=(ans+wa[i]*A[i])%(10**9+7)
print(ans)


Measured memory_bytes: 94136
let h = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let swap i j t = let tmp = t.(i) in t.(i) <- t.(j); t.(j) <- tmp

let extract (t : int array) =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !h && t.(l) > t.(i) then l else i in
    let m = if r <= !h && t.(r) > t.(m) then r else m in
    if i <> m then begin
      swap i m t;
      max_heapify m
    end in
  let ret = t.(1) in
  t.(1) <- t.(!h);
  decr h;
  max_heapify 1;
  ret

let insert x (t : int array) =
  let rec doit i =
    if i > 1 && t.(parent i) < t.(i) then begin
      swap i (parent i) t;
      doit (parent i)
    end in
  incr h;
  t.(!h) <- x;
  doit !h

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let t = Array.make 2000001 0 in
  let rec doit () =
    match split_on_char ' ' (read_line ()) with
    | ["extract"] -> Printf.printf "%d\n" (extract t); doit ()
    | ["insert"; n] -> insert (int_of_string n) t; doit ()
    | _ -> () in
  doit ()

Measured memory_bytes: 20432
#include <bits/stdc++.h>
using namespace std;
#define ELEM(array)  (sizeof (array) / sizeof *(array))
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int,int> Pii;
typedef long long ll;

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    cin>>h[0];
    int a=0,mx=0;
    for(int i=1;i<n;i++){
        cin>>h[i];
        if(h[i-1]>=h[i]) a++;
        else {
            mx=max(mx,a);
            a=0;
        }
    }
    cout<<max(mx,a);

    return 0;
}

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

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

Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);

#ifdef BUGGY
	bool DEBUG = 1;
#endif
#ifndef BUGGY
	bool DEBUG = 0;
#endif

const int MAX_LIMIT = 200005;

string S;
int A[MAX_LIMIT];
map<int, int> ans;

int main()
{
	cin >> S;
	int limit = S.size();

	A[0] = (1<<(S[0] - 'a'));
	for(int i = 1; i < limit; i++) {
		A[i] = A[i - 1] ^ (1<<(S[i] - 'a'));
	}

	ans[A[0]] = 1;
	for(int i = 1; i < limit; i++) {
		int thisMin = MOD;
		for(int j = 0; j < 26; j++) {
			int mask = (1<<j)^A[i];
			if(ans.find(mask) != ans.end()) {
				thisMin = min(thisMin, ans[mask] + 1);
			}
		}
		if(A[i] == 0 || (A[i] && (!(A[i]&(A[i]-1))))) {
			thisMin = 1;
		}
		if(ans.find(A[i]) != ans.end()) {
			thisMin = min(thisMin, ans[A[i]]);
		}
		ans[A[i]] = thisMin;
	}

	cout << ans[A[limit - 1]];

	return 0;
}
/*
	Powered by Buggy Plugin
*/

Measured memory_bytes: 10628