akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int absolute(int a);
int main() {
  int N,i,ans=10010;
  cin >> N;
  vector<int> W(N),sum(N);
  for(i=0;i<N;i++)cin >> W[i];
  sum[0] = W[0];
  for(i=0;i<N-1;i++)sum[i+1] = sum[i] + W[i+1];
  for(i=0;i<N;i++) {
    if(ans > absolute(2*sum[i]-sum[N-1]))ans=absolute(2*sum[i]-sum[N-1]);
  }
  cout << ans << endl;
}
int absolute(int a) {
  if(a<0)return -a;
  else return a;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c = 0, d[100000], e[100000], f = 0, g = 0, h = 0,maxcount=0, mincount = 0, x = 0, y = 0, z = 0;
	char rikka, toka[100000];
	string saya, homu, kyok, mami, mado[50];
	bool gg = true;
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> d[i];
		e[i] = d[i];
	}
	if (a == 1) {
		cout << 0 << endl;
		return 0;
	}
	maxcount = max(d[0], d[ 1]);
	for (int j = 2; j < a; j++) {
		maxcount = max(maxcount, d[j]);

	}
	mincount = min(e[0], e[1]);
	for (int k = 2; k < a; k++) {
		mincount = min(mincount, e[k]);

	}
	cout << maxcount - mincount<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
    ans = 3
elif (S[0] == 'R' and S[1] == 'R' and S[2] == 'S') or (S[0] == 'S' and S[1] == 'R' and S[2] == 'R'):
    ans = 2
elif S[0] == 'S' and S[1] == 'S' and S[2] == 'S':
    ans = 0
else:
    ans = 1

print(ans)

Measured memory_bytes: 9028
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
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; }
const ll INF = 1LL << 60;
const ll mod = 1000000007;

string s,t;

ll H,W;
vstr a;
ll dp[1100][1100]={0};//dp[i+1][j+1]:=sのi文字目までとtのj文字目まででのLCSの長さ

void add(ll &a, ll b){
	a+=b;
	if(a>=mod) a-=mod;
}

int main(){
	//乱数srand((unsigned)time(NULL));
	//入力
	cin>>H>>W;
	a.resize(H);
	//dpテーブル埋め
	for(ll i=0; i<H; i++) cin>>a[i];
	
	dp[0][0]=1;
	
	for(ll i=0; i<H; i++){
		for(ll j=0; j<W; j++){
			if(i+1 < H && a[i+1][j] =='.')add(dp[i+1][j],dp[i][j]);
			if(j+1 < W && a[i][j+1] =='.')add(dp[i][j+1],dp[i][j]);			
		}
	}
	
	cout<<dp[H-1][W-1]<<endl;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define INF (1LL << 60)
#define int long long
#define mod 1000000007
using namespace std;

int A[400];

int dp[400][400];
int prec[401];
int32_t main(){
	for(int i = 0; i < 400; i++){
		for(int j = 0; j < 400; j++){
			dp[i][j] = INF;
		}
	} 
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	prec[0] = 0;
	for(int i = 0; i < n; i++){
		prec[i+1] = prec[i] + A[i];
	}
	for(int i = 0; i < n; i++){
		dp[i][i] = 0;
	} 
	for(int i = 0; i < n - 1; i++){
		dp[i][i+1] = A[i] + A[i+1];
	} 
	for(int diff = 2; diff < n; diff++){
		for(int i = 0; i < n - diff; i++){
			int j = i + diff;
			for(int k = i; k < j; k++){
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + prec[j+1] - prec[i]);
			}
		}
	}
	cout << dp[0][n - 1];
}

Measured memory_bytes: 1536
def inpl(): return [int(i) for i in input().split()]
import sys

N = int(input())
A = inpl()

sumA = sum(A)
k = (N*(N+1)//2)
if sumA % k != 0:
    print('NO')
    sys.exit()
k = sumA // k
B = []
for i in range(N-1):
    B.append(A[i+1]-A[i]-k)
B.append(A[0]-A[N-1]-k)
flag = 0
ans = 'NO'
for i in B:
    if i%N != 0:
        break
    if i//N > 0:
        break
    flag -= i//N
else:
    if flag == k:
        ans = 'YES'
print(ans)

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



void solve(){
    double t,x;
    cin >> t >> x;
    cout << setprecision(10) << t/x << endl;
}

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

Measured memory_bytes: 256
for _ in range(int(input())):
    d, r = map(int, input().split())
    a = d // 100 + r // 30 * 5
    if d % 100:
        if r % 30:print("{} {} {} {}".format(a, a + 1, a + 5, a + 6))
        else:print("{} {}".format(a, a + 1))
    else:
        if r % 30:print("{} {}".format(a, a + 5))
        else:print(a)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
const int inv2 = (mod+1)>>1;
/* math */
const int N = 1e5+5;
int a[1<<19],b[1<<19],c[1<<19],d[1<<19];
inline void fwt(int *f,int n,int type){
	for(int step=1;step<n;step<<=1){
		for(int i=0;i<n;i+=step<<1){
			for(int j=0;j<step;j++){
				int x=f[i+j], y=f[i+j+step];
				f[i+j] = add(x,y);
				f[i+j+step] = sub(x,y);
				if(type==0){
					f[i+j] = mul(f[i+j], inv2);
					f[i+j+step] = mul(f[i+j+step], inv2);
				}
			}
		}
	}
}
int n,buc[N],sg[N];
vector<int> s[N];
inline void calc(int n,int *q){
	int m;cin >> m;for(int i=1;i<=n;i++)s[i].clear();
	for(int i=1;i<=m;i++){
		int u,v;scanf("%d%d",&u,&v);
		s[min(u,v)].push_back(max(u,v));
	}
	for(int i=n;i;i--){
		sg[i]=0;
		for(size_t j=0;j<s[i].size();j++){
			int v=s[i][j];
			// cout << i << " -> " << v << endl;
			buc[sg[v]]++;
		}
		while(buc[sg[i]])sg[i]++;
		for(size_t j=0;j<s[i].size();j++){
			int v=s[i][j];
			buc[sg[v]]--;
		}
		// cout << i << " " << sg[i] << endl;
		q[sg[i]]=add(q[sg[i]], qpow(10,18*i));
	}
}

int main()
{
	cin >> n;
	calc(n,a),calc(n,b),calc(n,c);
	fwt(a,1<<19,1);
	fwt(b,1<<19,1);
	fwt(c,1<<19,1);
	for(int i=0;i<1<<19;i++){
		d[i]=mul(a[i],mul(b[i],c[i]));
	}
	fwt(d,1<<19,0);
	cout << d[0] << endl;
}

Measured memory_bytes: 14208
end = 0
ans = [0]
def pushBack(x):
    global end, ans
    ans[end] = x
    end += 1
    if end >= len(ans):
        ans.append(0)

def randomAccess(p):
    global ans
    print(ans[int(p)])

def popBack():
    global end
    end -= 1

q = int(input())
for i in range(q):
    query = list(input().split())
    if query[0] == "0":
        pushBack(query[1])
    elif query[0] == "1":
        randomAccess(query[1])
    else:
        popBack()


Measured memory_bytes: 19804
#include <iostream>

using namespace std;

int Count(int n)
{
	int count = 0;

	while (n)
	{
		count++;
		n /= 10;
	}

	return count;
}

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

	int count = 0;

	for (int i = 1; i <= N; i++)
	{
		if (Count(i) % 2 == 1)
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

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


#define L_B lower_bound
#define U_B upper_bound

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf (1000*1000*1000+5)
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	VL arr(n);
	fr(i,0,n)
		rl(arr[i]);
	ll flag=1;
	fr(i,0,n)
	{
		if(arr[i]%2==0)
		{
			if(arr[i]%3==0||arr[i]%5==0)
			{

			}
			else
				flag=0;
		}
	}
	if(flag==1)
		cout<<"APPROVED\n";
	else
		cout<<"DENIED\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
  int i,j,N,x,a[100],m,s=0;
  scanf("%d%d",&N,&x);
  for(i=0;i<N;i++)
    scanf("%d",&a[i]);
  while(i--){
    for(m=0;m<N&&!a[m];m++)
    if(m==N)break;
    for(j=m+1;j<N;j++)
      if(a[j]<a[m]&&a[j]>0)m=j;
    if(x<a[m])break;
    x-=a[m];
    if(i>0)s++;
    else if(x==0)s++;
    a[m]=0;
  }
  printf("%d\n",s);
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string str = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			Console.WriteLine(n / 2 + n % 2);


			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	int rec(int S, int v, vector<vector<int>>& dp, vector<vector<int>>& path) {
		if (dp[S][v] >= 0) {
			return dp[S][v];
		}
		if (S == (1 << v) && path[v][0] >= 0) {
			return dp[S][v] = path[v][0];
		}
		
		int n = path.size();
		int res = INT_MAX;
		int nS = S & ~(1 << v);
		for (int i = 0; i < n; ++i) {
			if (S >> i & 1) {
				if (path[v][i] >= 0) {
					int d = rec(nS, i, dp, path);
					if (d != INT_MAX) {
						chmin(res, d + path[v][i]);
					}
				}
			}
		}
		return dp[S][v] = res;
	}

	void solve() {
		IOS;
		int n, m;
		cin >> n >> m;
		vector<int> s(m), t(m), d(m);
		//using e=edge<int>;
		vector<vector<int>> path(n, vector<int>(n, -1));
		REP(i, m) {
			cin >> s[i] >> t[i] >> d[i];
			path[s[i]][t[i]] = d[i];
		}
		int b = 1 << n;
		vector<vector<int>> dp(b, vector<int>(n, -1));
		int res = rec(b-1, 0, dp, path);
		if (res == INT_MAX) {
			put(-1);
		} else {
			put(res);
		}
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}



Measured memory_bytes: 6272
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(a==b) cout << c<<endl;
  else if(b==c) cout <<a << endl;
  else cout << b << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int s, h, m;
    cin >> s;
    h = s / 3600;
    s %= 3600;
    m = s / 60;
    s %= 60;
    cout << h << ":" << m << ":" << s << "\n";
    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int i, n, k;
    cin>>n>>k;
    vector<int> ws(n);
    rep(i, n) cin>>ws[i];

    int l, r, p;
    l = 0; r = 1001001001;
    while (l + 1 < r) {
        p = (l + r) / 2;
        int cnt = 0;
        int w = 0;
        rep(i, n) {
            if (ws[i] > p) {
                cnt = k + 1;
                break;
            }

            w += ws[i];
            if (w > p) {
                cnt++;
                w = ws[i];
            }
        }
        if (w > 0) cnt++;

        if (cnt <= k) {
            r = p;
        }
        else {
            l = p;
        }
    }
    cout<<r<<endl;
}


Measured memory_bytes: 3364
s = str(input())
t = str(input())

S = [0]*26
T = [0]*26
for i in range(len(s)):
    c = ord(s[i])-ord('a')
    S[c] += 1

for i in range(len(t)):
    c = ord(t[i])-ord('a')
    T[c] += 1

s_ = ''
for i in range(26):
    s_ += chr(i+ord('a'))*S[i]

t_ = ''
for i in reversed(range(26)):
    t_ += chr(i+ord('a'))*T[i]

X = [s_, t_]
#print(X)
if s_ == t_:
    print('No')
    exit()
Y = sorted(X)
if X[0] == Y[0]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);

int main(){
  sync;
  int n,sum=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  cout << sum-n << endl;
}


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

using namespace std;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    cout << string(dx, 'R') << string(dy, 'U');
    cout << string(dx, 'L') << string(dy, 'D');
    cout << "D" << string(dx+1, 'R') << string(dy+1, 'U') << "L";
    cout << "U" << string(dx+1, 'L') << string(dy+1, 'D') << "R" << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    INF = 10 ** 12
    N, W = map(int, input().split())
    ws, vs = [], []
    for _ in range(N):
        w, v = map(int, input().split())
        ws.append(w)
        vs.append(v)
    sum_v = sum(vs)
    dp = [[INF] * (sum_v + 1) for _ in range(2)]
    dp[0][0] = 0
    for i in range(N):
        now_i, next_i = i & 1, (i+1) & 1
        for j in range(sum_v + 1):
            if j - vs[i] >= 0:
                dp[next_i][j] = min(dp[now_i][j], dp[now_i][j - vs[i]] + ws[i])
            else:
                dp[next_i][j] = dp[now_i][j]
    ans = 0
    for i in range(sum_v + 1):
        if dp[N&1][i] <= W:
            ans = i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43092
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)

int main()
{
    int A, B, C;
    int i, ans = 0;
    int sum = 0;

    scanf("%d %d %d", &A, &B, &C);

    for (i = 1; i <= B; i++) {
        sum = A * i;

        if (C == sum % B) {
            ans = 1;
            break;
        }
    }

    if (ans)
        printf("YES");
    else
        printf("NO");

    return 0;

}

Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

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

ll a[120000];
ll x[120000];
vector<ll> x_lower;
vector<ll> x_upper;
ll s1[120000];
ll s2[120000];


ll abs(ll x){
    if(x > 0)
        return x;
    else
        return -x;
}

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

    for(int k2 = 0; k2 < N; k2++){
        int k;
        if((N-k2) % 2 == 0){
            k = (N-k2)/2+k2;
            x_lower.push_back(a[k] + a[k2+1]);
        }
        else{
            k = (N-k2-1)/2+k2;
            x_lower.push_back(a[k]+a[k2]);
        }
    }

    s1[0] = a[0];
    s1[1] = a[1];
    for(int i = 2; i < N; i+=2){
        s1[i] = s1[i-2] + a[i];
    }
    for(int i = 3; i < N; i+=2){
        s1[i] = s1[i-2] + a[i];
    }
    s2[N-1] = a[N-1];
    for(int i = N-2; i >= 0; i--){
        s2[i] = s2[i+1] + a[i];
    }

    for(int i = 0; i < Q; i++) {
        auto it1 = lower_bound(x_lower.begin(), x_lower.end(), 2 * x[i]);
        // auto it2 = lower_bound(x_upper.begin(), x_upper.end(), 2 * x[i]);
        int k2 = it1 - x_lower.begin();
        int k, kt;
        if(k2 <= -1) {
            k = N / 2;
            kt = -1;
        }
        else if((N-k2) % 2 == 0){
            k = (N-k2)/2+k2;
            kt = k2-1;
        }
        else{
            k = (N-k2-1)/2+k2;
            kt = k2-2;
        }
        // cout << k << " " << kt << " " << k2 << endl;
        ll res = 0;
        if(kt >= 0){
            res += s1[kt];
        }
        res += s2[k];
        cout << res << endl;
        // cout << endl;
    }


    return 0;

}



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

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

int n,k;
int r;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(2500);

int main(){
  cin >> n >> k;
  r = n - k + 1;
  for(int i = 1; i <= k; i++){
    // if(k-i+1>=i-1){
    //   cout << comb(r,i)*comb(k-1,i-1) << endl;
    // }else{
    //   cout << comb(r,i) << endl;
    // }
    cout << comb(r,i)*comb(k-1,i-1) << endl;
  }


  return 0;
}

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

#define pii pair <int, int>

#define mp make_pair

#define f first
#define s second

#define pb push_back

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int N = 1e5 + 10;
const int NN = 20;
const int INF = 1e9 + 7;

int n, k;
ll a[N], dp[N], pref[N], pos[N];

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
        pos[i] = pos[i - 1] + (a[i] > 0) * a[i];
    }
    ll ans = 0;
    for (int i = 1; i + k - 1 <= n; i++) {
        ans = max(ans, pos[i - 1] + pos[n] - pos[i + k - 1] + max(0ll, pref[i + k - 1] - pref[i - 1]));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from collections import defaultdict

n = int(input())
v = list(map(int, input().split()))

d0 = defaultdict(int)
d1 = defaultdict(int)
for i in range(len(v)):
    if i % 2 == 1:
        d1[v[i]] += 1
    else:
        d0[v[i]] += 1

max1 = 0
max12 = 0
for i in d1.keys():
    if max1 < d1[i]:
        max12 = max1
        max1 = d1[i]
        max1n = i
    elif max12 < d1[i]:
        max12 = d1[i]
max0 = 0
max02 = 0
for i in d0.keys():
    if max0 < d0[i]:
        max02 = max0
        max0 = d0[i]
        max0n = i
    elif max02 < d0[i]:
        max02 = d0[i]
if max1n == max0n:
    if max0 < max1:
        print(int(n / 2 - max02 + n / 2 - max1))
    elif max1 < max0:
        print(int(n / 2 - max0 + n / 2 - max12))
    else:
        if max12 < max02:
            print(int(n / 2 - max02 + n / 2 - max1))
        else:
            print(int(n / 2 - max0 + n / 2 - max12))
else:
    print(int(n / 2 - max0 + n / 2 - max1))


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

signed main(void)
{
	int r, g, b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

vector<vector<int>> nbr;
vector<int> added;
vector<int> val;

void dfs(int n, int parent, int acc) {
  acc += added.at(n);
  val.at(n) = acc;
  for (int c : nbr.at(n)) {
    if (c == parent) continue;
    dfs(c, n, acc);
  }
}


int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, Q; cin >> N >> Q;
  nbr.resize(N+1);
  added.resize(N+1);
  val.resize(N+1);
  for (int i = 0; i < N-1; i++) {
    int a, b; cin >> a >> b;
    nbr.at(a).push_back(b);
    nbr.at(b).push_back(a);
  }
  for (int i = 0; i < Q; i++) {
    int p, x; cin >> p >> x;
    added.at(p) += x;
  }
  dfs(1, -1, 0);
  for (int i = 1; i <= N; i++) {
    if (i > 1) cout << " ";
    cout << val.at(i);
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 24320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
int main() {
    int n, m; cin >> n >> m;
    if(n > m) swap(n, m);
    if(m - n >= 2) cout << 0;
    else {
        mint x=1, y=1;
        for(int i=1;i<=n;i++) x*=i;
        for(int i=1;i<=m;i++) y*=i;
        mint ans = x * y;
        if(n==m) ans *= 2;
        cout << ans.x;
    }
}


Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()
if '##' in S[A:C-1:] or '##' in S[B:D-1:]:
    print("No")
    exit()
swap = True if '...' in S[B-2:D+1:] else False
if C > D and not swap:
    print("No")
    exit()
print("Yes")

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    if( K%N == 0 && K%M == 0 )
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        rep(i,N+1)
        {
            rep(j,M+1)
            {
                if( (N-i)*j + (M-j)* i == K )
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

long long int d[100000+1];
int N;

int main() {
    int i;

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

    sort(d, d+N);

    cout << d[N/2] - d[N/2-1] << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long 
#define  ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define vii vector<pair<int,int> >
#define pb push_back
#define inf 1000000007
#define f(i,a,b) for(i=a;i<b;i++)

using namespace std;
bool cmp(string &a,string &b)
{
	if(a.size()==b.size())return a<b;
	return a.size()<b.size();
}

int main()
{ 
 ll t,n,k;
 cin>>n>>k>>t;
 
 cout<<((n-1)/k+1)*t;
}

Measured memory_bytes: 3620
x,y = map(int,input().split())
dum1 = [1,3,5,7,8,10,12]
dum2 = [4,6,9,11]
if x == 2:
    print("No")
else:
    if dum1.count(x) == 1 and dum1.count(y) == 1:
        print("Yes")
    elif dum2.count(x) == 1 and dum2.count(y) == 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n;
int a[N];
multiset<int> s;
int main() {
	while(~scanf("%d",&n)) {
		s.clear();
		rep(i, 1, n + 1) scanf("%d", a + i);
		rep(i, 1, n + 1) {
			auto it = s.upper_bound(-a[i]);
			// dd(a[i]);
			if(it == s.end()) {}
			else {
				// de(*it);
				s.erase(it);
			}
			s.insert(-a[i]);
		}
		printf("%d\n", sz(s));
	}
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(tuple<string, int, int> c, tuple<string, int, int> d){
	
	if(get<0>(c) != get<0>(d)) return get<0>(c) < get<0>(d);
	else return get<1>(c) > get<1>(d);
}

int main() {
	int N, p;
	string s;
	cin >> N;
	vector<tuple<string, int, int>> v;
	REP(i, 0, N){
		cin >> s >> p;
		v.PB(make_tuple(s, p, i));
	}
	
	sort(v.begin(), v.end(), sort_by);
	for(auto a:v){
		int i;
		tie(s, p, i) =a;
		cout << i+1 << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    if (n == 1) {
        std::cout << "Hello World" << std::endl;
        return 0;
    }

    int a, b;
    std::cin >> a >> b;
    std::cout << a + b << std::endl;
    return 0;
}


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>



#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 2000000000000000000ll
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31


using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;


const int N = 100002;

int n,a[N], diff[N];


int main() {
   
    scanf("%d",&n);
    lp(i, 1, n) scanf("%d",&a[i]);
    
    ll sum = 0;
    
    lp(i, 1, n) {
        sum += abs(a[i]-a[i-1]);
        diff[i] = abs(a[i-1] - a[i+1]) - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]);
    }
    sum += abs(a[n]);
    
    
    lp(i, 1, n) printf("%lld\n", sum+diff[i]);
    
    return 0;
}






/*
 2 3 2
 0 0
 100 0
 0 100
 50 -1 48 3
 49 49 51 52
 4 4 4
 -100 0
 0 100
 0 -100
 100 0
 3 3 -2 -2
 -101 50 101 50
 -101 -101 101 -101
 -49 -50 49 -50
 5 6 4
 40 40
 60 10
 70 30
 60 80
 30 81
 20 40
 0 10 40 50
 10 61 30 61
 -100 90 200 90
 50 20 50 50

 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);

Measured memory_bytes: 2048
#include <cstdio>
#include <cstring>

using namespace std;

  char s[10003];

int main(){

  while(scanf("%s",s) != EOF){


    //  char s[10003];

    //  scanf("%s",s);

  int joi = 0,ioi = 0;

  int len = strlen(s);

  for(int i = 0;i < len-2;i++){
    if(s[i] == 'J' && s[i+1] == 'O' && s[i+2] == 'I'){
      joi++;
    }else if(s[i] == 'I' && s[i+1] == 'O' && s[i+2] == 'I'){
      ioi++;
    }
  }

  printf("%d\n%d\n",joi,ioi);

  }

  return 0;

}


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

using namespace std;

int a[150], b[150], c[150], d[150];

int n, m, q, ans = 0;

vector <int> go;

void mk(int x) {
	if (x == n) {
		reverse(go.begin(), go.end());
		int sum = 0;
		for (int i = 0; i < q; ++i) {
			if (go[b[i] - 1] - go[a[i] - 1] == c[i])
				sum += d[i];
		}
		ans = max(ans, sum);
		reverse(go.begin(), go.end());
		return;
	}
	int tmp;
	if (x == 0)
		tmp = m;
	else
		tmp = go[go.size() - 1];
	for (int i = 1; i <= tmp; ++i) {
		go.push_back(i);
		mk(x + 1);
		go.pop_back();
	}
}

int main() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; ++i)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	mk(0);
	cout << ans << '\n';
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

string solve(){
  int MAMORU=0,TAMERU=1,KOUGEKIDA=2;
  string ISONO="Isono-kun",NAKAJIMA="Nakajima-kun",HIKIWAKE="Hikiwake-kun";
  int K;
  cin >> K;
  int player[2][K];
  int ap[2] = {0,0};
  int AP_MAX = 5;

  REP(i,2)REP(j,K){
    string s;
    cin >> s;
    if(s=="mamoru")player[i][j]=MAMORU;
    if(s=="tameru")player[i][j]=TAMERU;
    if(s=="kougekida")player[i][j]=KOUGEKIDA;
  }

  REP(i,K){
    int hand_i = player[0][i];
    int hand_n = player[1][i];

    if(hand_i==TAMERU)ap[0]=min(ap[0]+1,5);
    if(hand_n==TAMERU)ap[1]=min(ap[1]+1,5);
    if(hand_i==KOUGEKIDA){
      if(ap[0]==ap[1] && hand_n==KOUGEKIDA){
        ap[0]=ap[1]=0;
        continue;
      }
      if(ap[0]==0)return NAKAJIMA;
      if(ap[0]<5 && hand_n==MAMORU){
        ap[0]=0;continue;
      }
      if(hand_n==KOUGEKIDA) return (ap[0]>ap[1]?ISONO:NAKAJIMA);
      return ISONO;
    }
    if(hand_n==KOUGEKIDA){
      if(ap[1]==0)return ISONO;
      if(ap[1]<5 && hand_i==MAMORU){
        ap[1]=0;continue;
      }
      return NAKAJIMA;
    }
    // if(hand_i==MAMORU){
    //   if(hand_n==MAMORU){
    //     continue;
    //   }
    //   if(hand_n==TAMERU){
    //     ap[1] = min(ap[1]+1,AP_MAX);
    //   }
    //   if(hand_n==KOUGEKIDA){
    //     if(ap[1]==0){
    //       cout<<ISONO<<endl;
    //     }else if(ap[1]==5){
    //       return NAKAJIMA;
    //     }else{
    //       ap[1]=0;
    //       continue;
    //     }
    //   }
    // }
    // if(hand_i==TAMERU){
    //   if(hand_n==MAMORU){
    //     ap[0] = min(ap[0]+1,AP_MAX);
    //     continue;
    //   }
    //   if(hand_n==TAMERU){
    //     ap[0] = min(ap[0]+1,AP_MAX);
    //     ap[1] = min(ap[1]+1,AP_MAX);
    //     continue;
    //   }
    //   if(hand_n==KOUGEKIDA){
    //     if(ap[1]==0){
    //       cout<<ISONO<<endl;
    //       return 0;
    //     }else{
    //       cout<<NAKAJIMA<<endl;
    //       return 0;
    //     }
    //   }
    // }
    // if(hand_i==KOUGEKIDA){
    //   if(hand_n==MAMORU){
    //     if(ap[0]==0){
    //       cout<<NAKAJIMA<<endl;
    //       return 0;
    //     }else if(ap[0]==5){
    //       cout<<ISONO<<endl;
    //       return 0;
    //     }else{
    //       ap[0]=0;
    //       continue;
    //     }
    //   }
    //   if(hand_n==TAMERU){
    //     if(ap[0]==0){
    //       cout<<NAKAJIMA<<endl;
    //       return 0;
    //     }else{
    //       cout<<ISONO<<endl;
    //       return 0;
    //     }
    //   }
    //   if(hand_n==KOUGEKIDA){
    //     if(ap[0]==ap[1]){
    //       ap[0]=0;
    //       ap[1]=0;
    //       continue;
    //     }else{
    //       cout << (ap[0]<ap[1]?NAKAJIMA:ISONO) << endl;
    //       return 0;
    //     }
    //   }
    // }
  }
  return HIKIWAKE;
}

int main(){
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>

int main(void){
    
    int a,b,c,i=1;
    long long int max=10000000;
    
    scanf( "%d %d %d",&a,&b,&c );
    
    for( i = 1; i <= max; i++){
        if( i * a % b == c){
            printf("YES");
            return 0;
        }
    }
    printf("NO");

       return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

string reverse(string str){
  string res = "";
  pel(i,str.sz-1,0)res += str[i];
  return res;
}

int main(){
  int p;
  cin >> p;
  while(p--){
    vector<char> vec;
    map<string,int> ans;
    cin >> s;
    rep(i,0,s.sz)vec.pb(s[i]);
    rep(i,0,vec.sz-1){
      // create train
      s = "",t = "";
      lep(j,0,i)s += vec[j];
      rep(j,i+1,vec.sz)t += vec[j];
      // link and reverse
      string train = s + t;
      if(ans[train] == 0 && ans[reverse(train)] == 0)ans[train]++;
      train = s + reverse(t);
      if(ans[train] == 0 && ans[reverse(train)] == 0)ans[train]++;
      train = reverse(s) + t;
      if(ans[train] == 0 && ans[reverse(train)] == 0)ans[train]++;
      train = reverse(s) + reverse(t);
      if(ans[train] == 0 && ans[reverse(train)] == 0)ans[train]++;
      // puts("");
    }
    print(ans.sz);
  }
  return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch)
{
	if(ch == 'A')return 1;
	else if(ch == 'C') return 2;
	else if(ch == 'G') return 3;
	else if(ch == 't') return 4;
	else return 0;
}

long long getKey(char str[])
{
	long long sum = 0 , p = 1, i;
	for( i = 0;i < strlen(str); i++)
	{
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1+(key % (M-1));}

int find(char str[])
{
	long long key,i,h;
	key=getKey(str);
	for(i = 0;;i++)
	{
		h = (h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0)return 0;
	}
	return 0;
}

int insert(char str[])
{
	long long key,i,h;
	key=getKey(str);
	for(i = 0; ;i++)
	{
		h = (h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
	}
	}
	return 0;
}

int main(void)
{
	int i , n , h;
	char str[L],com[9];
	for( i = 0; i < M; i++)
	{
		H[i][0] = '\0';
	}
	scanf("%d",&n);
	for( i = 0; i < n; i++)
	{
		scanf("%s %s",com,str);
		if(com[0] == 'i'){
			insert(str);
		}
		else{
			if(find(str)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 16084
package main

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

const BIG_COST = 200000

const (
	ST_NOT_YET = iota
	ST_JOINED
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nNodes := scanInt(sc)

	costs := make([][]int, nNodes)
	graph := make([][]int, nNodes)

	states := make([]int, nNodes)
	costSums := make([]int, nNodes)

	for i := 0; i < nNodes; i++ {
		costs[i] = make([]int, nNodes)
		costSums[i] = BIG_COST
	}

	for i := 0; i < nNodes; i++ {
		u := scanInt(sc)
		k := scanInt(sc)
		graph[u] = make([]int, k)
		for d := 0; d < k; d++ {
			v := scanInt(sc)
			graph[u][d] = v
			costs[u][v] = scanInt(sc)
		}
	}

	costSums[0] = 0
	for {
		minCost := BIG_COST
		var u int

		for i, cost := range costSums {
			if states[i] != ST_JOINED && cost < minCost {
				minCost = cost
				u = i
			}
		}

		if minCost == BIG_COST {
			break
		}

		states[u] = ST_JOINED

		for _, v := range graph[u] {
			cost := minCost + costs[u][v]
			if cost < costSums[v] {
				costSums[v] = cost
			}
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for i, cost := range costSums {
		fmt.Fprintf(w, "%d %d\n", i, cost)
	}
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}



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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x, a;
    cin >> x >> a;
    if(x < a)
        cout << 0;
    else
        cout << 10;

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll ans = 0;
    vector<vector<vector<vector<ll>>>> dp;
    cin >> N;
    dp = vector<vector<vector<vector<ll>>>>(N + 1, vector<vector<vector<ll>>>(5, vector<vector<ll>>(5, vector<ll>(5))));
    dp[0][0][0][0] = 1;
    rep(i, N) {
        rep(j, 5) {
            rep(k, 5) {
                rep2(l, 1, 5) {
                    rep(m, 5) {
                        if(j == 1 && k == 2 && l == 3) continue;
                        if(j == 2 && k == 1 && l == 3) continue;
                        if(j == 1 && k == 3 && l == 2) continue;
                        if(m == 1 && j == 2 && l == 3) continue;
                        if(m == 1 && k == 2 && l == 3) continue;
                        dp[i + 1][j][k][l] += dp[i][m][j][k];
                        dp[i + 1][j][k][l] %= MOD;
                    }
                }
            }
        }
    }
    rep2(j, 1, 5) rep2(k, 1, 5) rep2(l, 1, 5) {
        ans += dp[N][j][k][l];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	int po[][] = new int[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			po[i][j]=sc.nextInt();
		}
	}
	for(int i=0;i<n;i++){
		int p=0;
		for(int j=0;j<3;j++){
			int c=0;
			for(int k=0;k<n;k++){
				if(po[i][j]==po[k][j]){
					c++;
				}
			}
			if(c==1){
				p+=po[i][j];
			}
		}
		System.out.println(p);
	}
	}
}

Measured memory_bytes: 20800
#include<stdio.h>

int main(void)
{
	int seisu = 0;
	int a, b, c, d;

	scanf("%d", &seisu);

	a = seisu / 1000;
	b = (seisu / 100) - (10 * a);
	c = (seisu / 10) - (100 * a) - (10 * b);
	d = seisu - (1000 * a) - (100 * b) - (10 * c);

	
	if (((a == b)&& (b== c)) ||( (b == c)&&(c == d)))
	{
		printf("\nYes");
	}
	else
	{
		printf("\nNo");
	}
	
	return 0;
}

Measured memory_bytes: 128
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    H,W = LMIIS()
    Ch,Cw = LMIIS()
    Ch -= 1
    Cw -= 1
    Dh,Dw = LMIIS()
    Dh -= 1
    Dw -= 1
    S = []
    for i in range(H):
        S.append(input())
    
    num_warp = []
    for i in range(H):
        num_warp.append([-1]*W)
    
    


    def check_and_move(y,x,d):
        if 0 <= y < H and 0 <= x < W and num_warp[y][x] == -1 and S[y][x] == '.':
            num_warp[y][x] = d
            return True
        return False


    # 歩行はDFS, ワープはBFS
    targets = deque([(Ch,Cw,0)])
    while targets:
        y,x,d = targets.pop()
        if not check_and_move(y,x,d):
            continue

        if y == Dh and x == Dw:
            break

        for y2,x2 in [(y-1,x),(y,x+1),(y+1,x),(y,x-1)]:
            targets.append((y2,x2,d))

        for y2,x2 in[
                (y-2,x-2),(y-2,x-1),(y-2,x),(y-2,x+1),(y-2,x+2),
                (y-1,x-2),(y-1,x-1),(y-1,x+1),(y-2,x+2),
                (y,x-2),(y,x+2),
                (y+1,x-2),(y+1,x-1),(y+1,x+1),(y+1,x+2),
                (y+2,x-2),(y+2,x-1),(y+2,x),(y+2,x+1),(y+2,x+2)
            ]:
            targets.appendleft((y2,x2,d+1))

    print(num_warp[Dh][Dw])



    
main()

Measured memory_bytes: 266408