akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {

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

		Map<String,String> Alpha = new HashMap<>();

		Alpha.put("a","b");
		Alpha.put("b","c");
		Alpha.put("c","d");
		Alpha.put("d","e");
		Alpha.put("e","f");
		Alpha.put("f","g");
		Alpha.put("g","h");
		Alpha.put("h","i");
		Alpha.put("i","j");
		Alpha.put("j","k");
		Alpha.put("k","l");
		Alpha.put("l","m");
		Alpha.put("m","n");
		Alpha.put("n","o");
		Alpha.put("o","p");
		Alpha.put("p","q");
		Alpha.put("q","r");
		Alpha.put("r","s");
		Alpha.put("s","t");
		Alpha.put("t","u");
		Alpha.put("u","v");
		Alpha.put("v","w");
		Alpha.put("w","x");
		Alpha.put("x","y");
		Alpha.put("y","z");

		System.out.print(Alpha.get(sc.next()));

		sc.close();
	}
}


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

namespace BAlgae
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var r = inputs[0];
            var d = inputs[1];
            var start = inputs[2];

            // 解答の計算・出力
            var weight = start;
            for (var i = 1; i <= 10; i++)
            {
                weight = r * weight - d;
                Console.WriteLine(weight);
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

vector<int> L[100100];
int N;
bool isvisit[100100];

//int dfs(int v, int t){
//    if(v == t){
//        return 0;
//    }
//    isvisit[v] = true;
//    int ret = 0;
//    for(int i = 0; i < L[v].size(); i++){
//        int next = L[v][i];
//        if(isvisit[next]) continue;
//        ret += dfs(next, t);
//    }
//    return ret+1;
//}

int main(){
    cin >> N;
    REP(i,N-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        L[a].push_back(b);
        L[b].push_back(a);
    }

    queue<pair<int, int> > fe;
    queue<pair<int, int> > su;
    fe.push(make_pair(0, 0));
    su.push(make_pair(N-1, 0));
    isvisit[0] = isvisit[N-1] = true;
    int sfe = 0;
    int ssu = 0;
    int lfe = 0;
    int lsu = 0;
    while(!(fe.empty() && su.empty())){
        while(!fe.empty()){
            pair<int, int> p = fe.front();
            int v = p.first;
            int level = p.second;
            if(lfe < level) break;
            fe.pop();
            sfe++;
            for(int i = 0; i < L[v].size(); i++){
                int next = L[v][i];
                if(isvisit[next]) continue;
                isvisit[next] = true;
                fe.push(make_pair(next, lfe+1));
            }
        }
        while(!su.empty()){
            pair<int, int> p = su.front();
            int v = p.first;
            int level = p.second;
            if(lsu < level) break;
            su.pop();
            ssu++;
            for(int i = 0; i < L[v].size(); i++){
                int next = L[v][i];
                if(isvisit[next]) continue;
                isvisit[next] = true;
                su.push(make_pair(next, lsu+1));
            }
        }
        lfe++;
        lsu++;
    }
    //printf("sfe:%d, ssu:%d\n", sfe, ssu);

    if(sfe <= ssu){
        cout << "Snuke" << endl;
    }
    else{
        cout << "Fennec" << endl;
    }
    return 0;

}


Measured memory_bytes: 6144
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size()){cout<<"GREATER";return 0;}
	if(b.size()>a.size()){cout<<"LESS";return 0;}
	for(int i=0;i<a.size();i++){
		if(a[i]>b[i]){cout<<"GREATER";return 0;}
		if(b[i]>a[i]){cout<<"LESS";return 0;}
	}
	cout<<"EQUAL";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S1 = input()
S2 = input()

M = 1000000007

c = 0
i = 0
result = 1

while i < N:
    if S1[i] == S2[i]:
        if c == 0:
            result = (result * 3) % M
        elif c == 1:
            result = (result * 2) % M
        elif c == 2:
            result = (result * 1) % M
        c = 1
        i += 1
    else:
        if c == 0:
            result = (result * 3 * 2) % M
        elif c == 1:
            result = (result * 2) % M
        elif c == 2:
            result = (result * 3) % M
        c = 2
        i += 2

print(result)


Measured memory_bytes: 3064
def e():
    import numpy as np

    N, W = map(int, input().split())

    dp = np.zeros(W+1, dtype=np.int64)

    for _ in range(N):
        w, v = map(int, input().split())
        np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

    print(dp[-1])


##########
if __name__ == "__main__":
    e()


Measured memory_bytes: 14684
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(200+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

vector<int> adj[N];
int col[N];
vector<pair<int,int>> ed;
int dis[N][N];
void dfs(int u,int c){
	col[u] = c;
	for(auto v:adj[u]){
		if(col[v] == 0){
			if(c == 1) dfs(v,2);
			else dfs(v,1);
		}
	}
}
void solve(){
	int n;
	cin >> n;
	for(int i =1;i<=n;i++)
		for(int j = 1;j<=n;j++)
			dis[i][j] = INF;
	for(int i =1;i<=n;i++) dis[i][i] =0;
	for(int i =1;i<=n;i++){
		string s;
		cin >> s;
		for(int j = 0;j < n;j++){
			if(s[j] == '1') {
				ed.pb({i,j+1});
				dis[i][j+1] = 1;
				adj[i].pb(j+1);
			}
		}
	}

	dfs(1,1);
	bool bip = true;
	for(auto p:ed){
		bip &= (col[p.f] != col[p.s]);
	}
	if(!bip){
		cout << -1 << endl;
		return;
	}
	for(int k = 1;k<=n;k++){
		for(int i =1;i<=n;i++){
			for(int j =1;j<=n;j++){
				dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
			}
		}
	}
	int ans = 0;
	for(int i =1;i<=n;i++){
		for(int j =1;j<=n;j++)
			ans = max(ans,dis[i][j]);
	}
	cout << ans+1 << endl;

	





}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 4900
#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 repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

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

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(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> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; 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, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int n;
  cin >> n;
  vi32 a(n + 2);
  a[0] = 0;
  a[n + 1] = 0;
  reps(i, n) cin >> a[i];
  int sum = 0;
  rep(i, n + 1) sum += abs(a[i + 1] - a[i]);
  reps(i, n) {
    int temp = sum;
    if (a[i] > a[i - 1] && a[i] > a[i + 1]) {
      temp -= (a[i] - max(a[i - 1], a[i + 1])) * 2;
    }
    if (a[i] < a[i - 1] && a[i] < a[i + 1]) {
      temp -= (min(a[i - 1], a[i + 1]) - a[i]) * 2;
    }
    cout << temp << endl;
  }
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8


int main(){
    char  S[107];cin >> S;
    cout << S[0] << strlen(S)-2 << S[strlen(S)-1] << endl;
}

Measured memory_bytes: 888
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define amen ;
#define vec vector
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef double d;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;
typedef unsigned int ui;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, d;
    cin >> n >> d;
    vector <int> v[n];
    for (int i= 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            int x;
            cin >> x;
            v[i].pb(x);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int kek = 0;
            for (int g = 0; g < d; g++)
            {
                kek += (v[i][g] - v[j][g]) * (v[i][g] - v[j][g]);
            }
            int t = sqrt(kek);
            if (t * t == kek)
            {
                ans++;
            }
        }
    }
    cout << ans;

    return 0;
}

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

int c[3][3];
int a[3], b[3];

bool check() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (a[i] + b[j] != c[i][j]) {
                return false;
            }
        }
    }
    return true;
}

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 <= 100; i++) {
        a[0] = i;
        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];
        if (check()) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)

ll prime[1000005];
bool is_prime[1000005];
ll sieve(ll n){
	ll p=0;
	for(ll i=0; i<=n; i++) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(ll i=2; i<=n; i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(ll j=2*i; j<=n; j+=i) is_prime[j]=false;
		}
	}
	return p;
}
ll N;
ll a[60];

int main(){

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

cin>>N;

ll n=sieve(55555);
ll index=0;
rep(i,n){
	if(prime[i]%5==1){
		a[index]=prime[i];
		index++;
		if(index==N) break;
	}
}

rep(i,N){
	if(i==N-1){
		cout<<a[i]<<endl;
	}else{
		cout<<a[i]<<" ";
	}
}

}
	


Measured memory_bytes: 384
N = int(input())
a = [int(i) for i in input().split()]
A = 1
if 0 in a:
  print(0)
  exit()
for i in range(N):
  A = A * a[i]
  if A > 1000000000000000000:
    print(-1)
    exit()
print(A)

Measured memory_bytes: 21648
#include<iostream>
#include<iomanip>
#include<vector>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<unordered_set>
using namespace std;
const int MAX = 100002;
const int INF = 1000000000;

int main() {
	int X, K, Q;
	int m[MAX], ub[MAX], lb[MAX], up[MAX], lo[MAX];
	vector<int> r;
	
	cin >> X >> K;
	r.push_back(0);
	for (int i = 1; i <= K; i++) {
		int temp;
		cin >> temp;
		r.push_back(temp);
	}
	r.push_back(INF);

	m[0] = 0;
	ub[0] = X;
	lb[0] = 0;
	up[0] = 0;
	lo[0] = 0;

	bool b = true;
	for (int i = 1; i < r.size(); i++) {
		int td = r[i] - r[i - 1];

		if (b) {
			ub[i] = max(0, ub[i - 1] - td);
			lb[i] = max(0, lb[i - 1] - td);
			m[i] = m[i - 1] - td;
		}
		else {
			ub[i] = min(X, ub[i - 1] + td);
			lb[i] = min(X, lb[i - 1] + td);
			m[i] = m[i - 1] + td;
		}

		up[i] = max(m[i], up[i - 1]);
		lo[i] = min(m[i], lo[i - 1]);

		b = !b;
	}

	cin >> Q;

	for (int i = 0; i < Q; i++) {
		int t, a;
		cin >> t >> a;

		vector<int>::iterator it = upper_bound(r.begin(), r.end(), t);

		int index = distance(r.begin(), it) - 1;

		int ans = 0;

		if (a + up[index] > X) {
			ans = ub[index];
		}
		else if (a + lo[index] < 0) {
			ans = lb[index];
		}
		else {
			ans = m[index] + a;
		}

		t -= r[index];
		if (index & 1) {
			ans = min(X, ans + t);
		}
		else {
			ans = max(0, ans - t);
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

map<ll,ll> m;

int main(){
  ll N,M,A[100007],sum=0,ans=0;
  cin >> N >> M;
  rep(i,N){
    cin >> A[i];
    sum+=A[i];
    sum%=M;
    m[sum]++;
  }
  for(auto P : m){
    if(P.fr==0){
      ans+=P.sc*(P.sc+1)/2;
    }
    else{
      ans+=P.sc*(P.sc-1)/2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
// https://atcoder.jp/contests/dp/tasks/dp_l

#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n;
  cin >> n;
  vector<int> points(n);
  for (int &i : points)
    cin >> i;
  vector<vector<int>> dp(n, vector<int>(n));
  // dp[l][r] --> X-Y considering game played only between l and r
  // dp[l][r] = max(points[l]-dp[l+1][r],points[r]-dp[l][r-1])
  for (int l = n-1; l >= 0; l--) {
    for (int r = l; r < n; r++) {
      if (l == r)
        dp[l][r] = points[l];
      else
        dp[l][r] = max(points[l] - dp[l + 1][r], points[r] - dp[l][r - 1]);
    }
  }
  cout<<dp[0][n-1]<<endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 70784
require 'pp'

n, y = ARGF.gets.split(" ").map(&:to_i)
y /= 1000

if (y-n) < 0
  puts "-1 -1 -1"
  exit
end

a = -1
loop do
  a += 1

  b = (y-n-9*a)
  if b % 4 != 0 
    next
  end

  if b < 0
    puts "-1 -1 -1"
    exit
  end

  b/=4

  c = n - (a+b)
  if c >= 0
    puts "#{a} #{b} #{c}"
    exit
  end
end


Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<set>

using namespace std;

int main(){
  string s;
  int q;
  cin >> s >> q;
  int t, f;
  char c;
  vector<char> cfor, cback;
  bool rev = false;
  for(int i=0; i<q; i++){
    cin >> t;
    if(t==1){ // 反転フラグ
      rev = !rev;
    } else {
      cin >> f >> c;
      if( (rev && f==1)||(!rev && f==2)){ // 末尾
        cback.push_back(c);
      }else{ //先頭
        cfor.push_back(c);
      }
    }
  }
  if(rev){ //反転
    for(auto i=cback.rbegin(); i!=cback.rend(); i++){
      cout << *i;
    }
    for(auto i=s.rbegin(); i!=s.rend(); i++){
      cout << *i;
    }
    for(auto i=cfor.begin(); i!=cfor.end(); i++){
      cout << *i;
    }
  }else{
    for(auto i=cfor.rbegin(); i!=cfor.rend(); i++){
      cout << *i;
    }
    cout << s;
    for(auto i=cback.begin(); i!=cback.end(); i++){
      cout << *i;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1148
/*   三玖天下第一！！！  */
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5,maxd=10;
int n,m,Q,_39[maxn+5]={},lin[maxn+5]={},len=0;
bool vis[maxn+5][maxd+5]={};
struct edge{int y,next;}e[(maxn<<1)+5];
inline void insert(int xx,int yy){e[++len]={yy,lin[xx]};lin[xx]=len;}
inline int dread()
{
	int x=0;bool f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())f^=(ch=='-');
	for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
	return f?x:-x;
}
struct operation
{
	int v,d,c;
	inline void read(){v=dread();d=dread();c=dread();}
}opt[maxn+5];
void color(int point,int dis,int c)
{
	if(vis[point][dis]) return;else for(int i=0;i<=dis;i++)vis[point][i]=1;
	if(!_39[point]) _39[point]=c;
	if(!dis) return;
	for(int i=lin[point];i;i=e[i].next) color(e[i].y,dis-1,c);
}
inline void Kaslana()
{
	n=dread();m=dread();
	for(int i=1,u,v;i<=m;i++) insert(u=dread(),v=dread()),insert(v,u);
	Q=dread();
	for(int i=1;i<=Q;i++) opt[i].read();
}
inline void Raiden()
{
	for(int i=Q;i>=1;i--) color(opt[i].v,opt[i].d,opt[i].c);
}
inline void Zaychik()
{
	for(int i=1;i<=n;i++) printf("%d\n",_39[i]);
}
int main()
{
    Kaslana(),Raiden(),Zaychik();return 0;
}

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

#define INF 10000000
using namespace std;

int main(void){

    int a, b;
    cin >> a >> b;
    int ans = INF;

    for(int i = 0;i < 1010;i++){
        if(int(i * 0.08) == a && int(i * 0.1) == b) ans = min(ans, i);
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int X;
    cin >> X;
    
    if(X<100){
        cout << 0 << endl;
        return 0;
    }
    
    int A = X/100;
    int B = X%100;
    
    int waru = B/5;
    if(B%5==0 && waru<=A){
        cout << 1 << endl;
        return 0;
    }else if(B%5!=0 && waru+1<=A){
        cout << 1 << endl;
        return 0;
    }
    
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdint>
#include<cstdlib>

int main() {
  std::cout << std::setprecision(10) << std::fixed;
  double W, H, x, y; std::cin >> W >> H >> x >> y;
  std::cout << (W*H*0.5) << std::endl;
  if(x*2 == W && y*2 == H) std::cout << " 1" << std::endl;
  else                     std::cout << " 0" << std::endl;
  return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int h=0;
    int a,b;
    int i,j;
    for(i=0;i<s.size();i++){
        if(s.at(i)=='A'){
            a=i;
        for(j=s.size()-1;j>=i;j--){
            if(s.at(j)=='Z'){
                b=j;
                break;
            }
        }
            break;
        }
    }
    cout << b-a+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
main(){
	string s;cin>>s;
	vector<char> c;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='B')
		{
			if(c.size())c.pop_back();
		}
		else c.push_back(s[i]);
	}
	for(int i=0;i<c.size();i++)cout<<c[i];
}

Measured memory_bytes: 256
(n, m, x, y) = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

xs.append(x)
ys.append(y)

xs.sort()
xs.reverse()
ys.sort()

if(xs[0] >= ys[0]):
    print('War')
else:
    print('No War')

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

int n;

class LCA
{
    int n, log_n;
    vector<vector<int>> parent;
    vector<int> depth;
    void dfs(const vector<vector<int>> &g, int v, int p, int d)
    {
        parent[0][v] = p;
        depth[v] = d;
        for (int i = 0; i < (int)g[v].size(); i++)
        {
            if (g[v][i] != p)
                dfs(g, g[v][i], v, d + 1);
        }
    }

  public:
    LCA(const vector<vector<int>> &g, int root) : n(g.size()), log_n(0), depth(n, 0)
    {
        for (int v = n; v > 0; v /= 2)
            log_n++;
        parent.assign(log_n, vector<int>(n, 0));
        dfs(g, root, -1, 0);
        for (int k = 0; k < log_n - 1; k++)
        {
            for (int v = 0; v < n; v++)
            {
                if (parent[k][v] < 0)
                    parent[k + 1][v] = -1;
                else
                    parent[k + 1][v] = parent[k][parent[k][v]];
            }
        }
    }
    int query(int u, int v)
    {
        if (depth[u] > depth[v])
            swap(u, v);
        for (int k = 0; k < log_n; k++)
        {
            if (((depth[v] - depth[u]) >> k) & 1)
            {
                v = parent[k][v];
            }
        }
        if (u == v)
            return u;
        for (int k = log_n - 1; k >= 0; k--)
        {
            if (parent[k][u] != parent[k][v])
            {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }
};

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

    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++)
    {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    vector<int> visit;
    vector<int> dist(n, INF);
    queue<int> q;
    q.push(0);
    dist[0] = 0;
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        visit.push_back(v);
        for (auto next : g[v])
        {
            dist[next] = dist[v] + 1;
            q.push(next);
        }
    }
    LCA lca(g, 0);
    ll res = 0;
    for(int i=1;i<n;i++){
        int cur=visit[i],pre=visit[i-1];
        int p=lca.query(cur,pre);
        res += (dist[cur]-dist[p]) + (dist[pre]-dist[p]);
    }
    cout<<res<<endl;
}



Measured memory_bytes: 19172
#include <iostream>
using namespace std;
 
int gcd(int a, int b)
{
    if (a%b == 0) {
        return(b);
    }
    else {
        return gcd(b, a%b);
    }
}
 
int main() 
{
  int k,ans = 0;
  cin >> k;
  
  for (int a = 1; a <= k; a++) {
      for (int b = 1; b <= k; b++) {
          for (int c = 1; c <= k; c++) {
              
              ans += gcd(gcd(a,b),c);
          
          }   
      }   
  }
  
  cout << ans << "\n";
  
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d) - max(a, c);
    cout << max(ans, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>

char jukuClass(int, int, int);
int main()
{
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; ++i) {
            int pm, pe, pj;
            std::cin >> pm >> pe >> pj;
            std::cout << jukuClass(pm, pe, pj) << std::endl;
        }
    }
    return 0;
}
char jukuClass(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
        return 'A';
    } else if ((pm + pe) / 2.0 >= 90) {
        return 'A';
    } else if ((pm + pe + pj) / 3.0 >= 80) {
        return 'A';
    } else if ((pm + pe + pj) / 3.0 >= 70) {
        return 'B';
    } else if (((pm + pe + pj) / 3.0 >= 50) && (pm >= 80 || pe >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

Measured memory_bytes: 1152
from itertools import combinations

INF = float("inf")
data = {d: [-INF, INF, -INF, INF] for d in 'RLUD'}

_, *XYD = open(0).read().split()
X = map(int, XYD[::3])
Y = map(int, XYD[1::3])
D = map(data.get, XYD[2::3])

for x, y, d in zip(X, Y, D):
    d[0] = max(d[0], x)
    d[1] = min(d[1], x)
    d[2] = max(d[2], y)
    d[3] = min(d[3], y)


X = [
    (data["L"][0], -1), (data["L"][1], -1),
    (data["R"][0], 1), (data["R"][1], 1),
    (data["U"][0], 0), (data["U"][1], 0),
    (data["D"][0], 0), (data["D"][1], 0),
]
Y = [
    (data["L"][2], 0), (data["L"][3], 0),
    (data["R"][2], 0), (data["R"][3], 0),
    (data["U"][2], 1), (data["U"][3], 1),
    (data["D"][2], -1), (data["D"][3], -1),
]

X = [(x, dx) for x, dx in X if abs(x) < INF]
Y = [(y, dy) for y, dy in Y if abs(y) < INF]

T = set(
    [0] +
    [max(0, (x - y) / (dy - dx)) for (x, dx), (y, dy) in combinations(X, 2) if dx != dy] +
    [max(0, (x - y) / (dy - dx)) for (x, dx), (y, dy) in combinations(Y, 2) if dx != dy]
)


def area(t):
    XX = [t * dx + x for x, dx in X]
    YY = [t * dy + y for y, dy in Y]

    dx = max(XX) - min(XX)
    dy = max(YY) - min(YY)

    return dx * dy


print(min(map(area, T)))

Measured memory_bytes: 20452
#include<bits/stdc++.h>
using namespace std; 
int main() 
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
  long long n,sum=0,ans=INT_MAX;cin>>n;
  vector<long long>v(n);
  for(long long i=0;i<n;i++){cin>>v[i];}
  sort(v.begin(),v.end());
  for(long long i=v[0];i<=v[n-1];i++)
  {
  for(long long j=0;j<n;j++)
  {
  sum+=(v[j]-i)*(v[j]-i);
  }
  ans=min(ans,sum);sum=0;
  }
  cout<<ans;
 return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N + 1);
    rep(i, N + 1) cin >> A[i];
    ll num = 1;
    vector<ll> lim(N + 1);
    rep(i, N + 1) {
        lim[i] = num;
        num -= A[i];
        if(i != N && num <= 0) {
            cout << -1 << endl;
            return 0;
        }
        num = min(num * 2, LINF);
    }

    ll cnt = 0;
    ll ans = 0;
    for(int i = N; i >= 0; i--) {
        if(cnt > (lim[i] - A[i]) * 2) {
            cout << -1 << endl;
            return 0;
        }
        if(cnt > lim[i] - A[i]) {
            cnt = lim[i] - A[i];
        }
        cnt += A[i];
        ans += cnt;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4808
import java.util.Scanner;

//Fermat's Last Theorem
public class Main{

	void run(){
		long[] p = new long[1111];
		for(int i=0;i<1111;i++)p[i]=(long) Math.pow(i, 3);
		Scanner sc = new Scanner(System.in);
		while(true){
			int z = sc.nextInt();
			if(z==0)break;
			int i=1, j=z;
			long max = 0;
			while(i<=j){
				long val = p[i]+p[j];
				if(val<=p[z]){
					i++;
					max = Math.max(max, val);
				}
				else j--;
			}
			System.out.println(p[z]-max);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"strconv"
)

func solve(c []int, n int) string {
	if c[0] == 0 && n == 1 {
		return "0"
	} else if c[0] == 0 {
		return "-1"
	}

	if c[0] == -1 && n == 1 {
		return "0"
	}

	answer := ""
	if c[0] == -1 {
		answer = "1"
	} else {
		answer = strconv.Itoa(c[0])
	}
	for i := 1; i < n; i++ {
		if c[i] > 0 {
			answer += strconv.Itoa(c[i])
		} else {
			answer += "0"
		}
	}
	return answer
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		c[i] = -1
	}

	result := true
	for i := 0; i < m; i++ {
		var p, q int
		fmt.Scan(&p, &q)
		if c[p-1] == -1 {
			c[p-1] = q
		} else if c[p-1] != q {
			result = false
			break
		}
	}

	if result == false {
		fmt.Println("-1")
	} else {
		fmt.Println(solve(c, n))
	}

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

const int MAX=500000;

int fac[MAX],finv[MAX],inv[MAX];
 
void t(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  repi(i,2,MAX){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        int t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
 
int calc(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
 


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,a,b;
  cin>>n>>a>>b;
  t();
  int num=n;
  int ans=1;
  int now=2;
  while(num){
    if(num%2==1) ans=now*ans%MOD;
    now=now*now%MOD;
    num/=2;
  }
  //cout<<ans<<endl;
  int bad=1;
  int bad2=1;
  repi(i,1,a+1){
    bad=bad*(n-i+1)%MOD;
    bad2=i*bad2%MOD;
  }
  ans-=(bad*modinv(bad2,MOD))%MOD;
  bad=bad2=1;
  repi(i,1,b+1){
    bad=bad*(n-i+1)%MOD;
    bad2=i*bad2%MOD;
  }
  ans-=(bad*modinv(bad2,MOD))%MOD;
  while(ans<0)ans+=MOD;
  cout<<ans-1<<endl;
  return 0;
}

Measured memory_bytes: 12032
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();

		int sum = 0;
		int curentInt = sc.nextInt();
		sum += curentInt;
		int beforeCur = curentInt;
		for (int i = 1; i < (n - 1); i++) {
			curentInt = sc.nextInt();
			sum += (beforeCur > curentInt) ? curentInt : beforeCur;
			beforeCur = curentInt;
		}

		sum += curentInt;

		System.out.println(sum);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
            return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
            }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
            }
        }

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
        }

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 int N,M;
 cin >> N ;
 vector <string> s(N);
 for (int i = 0; i < N; i++){
 	 cin >> s.at(i);
 }
 cin >> M;
 vector<string> t(M);
  for (int i = 0; i < M; i++){
 	 cin >> t.at(i);
 }

int ans,tmp;
ans = 0;
for (int i = 0; i < N; i++){
	tmp = 0;
	for ( int j = 0; j < N; j++){
		if (s.at(j) == s.at(i)){
			tmp++;
		}
	}
	//cout << "dbgtmp1 " << tmp << endl;
	for ( int j = 0; j < M; j++){
		if (s.at(i) == t.at(j)){
			tmp--;
		}
	}
	//cout << "dbgtmp2 " << tmp << ", " << ans << endl;
	if (tmp > ans){
		ans = tmp;
	//cout << "dbgans " << ans << endl;
	}
}
cout << ans << endl;



 return 0;
}

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

int main()
{
  char s[500001];
  scanf("%s", s);

  long ans = 0;
  char *p = s;
  if (*p == '>')
  {
    char *q = p;
    while (*p && *p == '>') ++p;
    long long len = p - q;
    ans += len * (len + 1) / 2;
  }
  
  while (*p)
  {
    char *q = p;
    while (*p && *p == '<') ++p;
    long long l = p - q;
    if (!*p)
    {
      ans += l * (l + 1) / 2;
      break;
    }
    q = p;
    while (*p && *p == '>') ++p;
    long long r = p - q;
    long long max = std::max(l, r);
    long long min = std::min(l, r);
    ans += max * (max + 1) / 2;
    ans += (min - 1) * min / 2;
  }
  printf("%lld\n", ans);
  return 0;
}

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

digit1=N % 10

if digit1 == 2 or digit1 == 4 or digit1 == 5 or digit1 == 7 or digit1 == 9:
    print('hon')
elif digit1 == 0 or digit1 == 1 or digit1 == 6 or digit1 == 8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9108
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}

bool prime[10000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n,k;
    cin >> n >>k;
    cout <<n-k+1;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=55;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

ll n, req, arr[N], dp[N][N][N*N];

ll solve(ll i, ll num_taken, ll sum_taken)
{
    if(i==n+1)
    {
        if(num_taken==0)
            return 0;
        if(sum_taken%num_taken)
            return 0;
        if(sum_taken/num_taken==req)
            return 1;
        return 0;
    }
    if(dp[i][num_taken][sum_taken]!=-1)
        return dp[i][num_taken][sum_taken];
    ll ret=0;
    // if(num_taken!=0 && sum_taken%num_taken==0 && sum_taken/num_taken==req)
    //     ret=1;
    ret+=solve(i+1, num_taken+1, sum_taken+arr[i]);
    ret+=solve(i+1, num_taken, sum_taken);
    return dp[i][num_taken][sum_taken]=ret;
}

int main() 
{
    inlld2(n, req);
    for(ll a=1; a<=n; a++)
        inlld(arr[a]);
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", solve(1, 0, 0));
    return 0;
}



Measured memory_bytes: 71808
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	int n,ma,sum=0;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		int p;
		cin >> p;
		ma = max(ma, p / 2);
		sum+= p;
	}
	cout << sum - ma << endl;
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int vec12x = x2 - x1;
  int vec12y = y2 - y1;
  
  int vec14x = -vec12y;
  int vec14y = vec12x;
  
  int x4 = x1 + vec14x;
  int y4 = y1 + vec14y;
  int x3 = x4 + vec12x;
  int y3 = y4 + vec12y;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
n=int(input())
ordenado=[]
a =list(map(int,input().split()))
ordenado = sorted(a)
maiden=0
for i in range(n):
    if(a[i]==ordenado[i]):
        continue
    else:
        maiden=maiden+1
if(maiden==2 or maiden==0):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
from collections import defaultdict
S = input()
d = defaultdict(int)

for s in S:
    d[s] += 1


ans = "Yes"
if d["N"] > 0 and d["S"] == 0:
    ans = "No"
if d["S"] > 0 and d["N"] == 0:
    ans = "No"
if d["W"] > 0 and d["E"] == 0:
    ans = "No"
if d["E"] > 0 and d["W"] == 0:
    ans = "No"

print(ans)


Measured memory_bytes: 3316
using System;

public class Hello{
    public static void Main(){
        string[] str = {Console.ReadLine(),Console.ReadLine(),Console.ReadLine()};
        
        int i = 0;
        int count = 0;
        while(str[i].Length != 0){
            string ch = str[i];
            int turn = ch[0] - 'a';
            str[i] = str[i].Substring(1);
            i = turn;
        }
        System.Console.WriteLine((char)('A'+i));
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    int a, b, c, x, count = 0;
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= a; i++) {//500
        for(int j=0;j<=b;j++){//100
            if (x - 500 * i - 100 * j >= 0 && (x - 500 * i - 100 * j) % 50 == 0 && (x - 500 * i - 100 * j) / 50 <= c) count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOD(i,b,a) for(i=a;i>=b;i--)
#define pa pair<long long , long long >
#define pb push_back
#define fi first
#define se second
#define task "x"

typedef long long ll;
const ll M=1e6 + 1;
const ll N=1e4 + 1;
const ll MOD = 1e9 + 1;
using namespace std;

ll a[6],i;

void input()
{
 cin >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
}

void solve()
{
FOR(i,1,5) if(a[i] == 0) {cout<< i;break;}
}

int main()
{
  	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	if(fopen(task".inp","r"))
        {
 	  freopen(task".inp","r",stdin);
 	  freopen(task".out","w",stdout);
	}
 	input();
	solve();

   return 0;
}


Measured memory_bytes: 3608
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define per(how) cout << fixed << setprecision(how)
#define bit(a , b) (a >> b) & 1
#define all(v) v.begin() , v.end()
#define LB(x) (x & -x)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 , MOD = 1e9 + 7 , SQRT = 350 ;
inline void smin(ll &x , ll y) { x = min(x , y) ; }
inline void smax(ll &x , ll y) { x = max(x , y) ; }

const ll MAXN = 3e5 + 100;
ll n , m;
vector < ll > adj[MAXN];
bool mark[MAXN];


int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(ll i = 0 ; i < m ; i++)
	{
		ll u , v;
		cin >> u >> v;
		adj[u].pb(v) , adj[v].pb(u);
	}
	for(auto u : adj[1])
	{
		mark[u] = 1;
		for(auto x : adj[u])
		{
			mark[x] = 1;
		}
	}
	if(mark[n])		cout << "POSSIBLE";
	else	cout << "IMPOSSIBLE";
	cout << endl ; 
	return 0;
}



Measured memory_bytes: 15336
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N, K;
  cin >> N >> K;

  vector<int> v(N);
  for (int &a: v) {
    cin >> a;
  }

  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += v[i];
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve(ll N, string S);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    solve(N, S);
}

void solve(ll N, string S){
    vl cnt(3);
    rep(i,N){
        if(S[i]=='R')cnt[0]++;
        else if(S[i]=='G')cnt[1]++;
        else cnt[2]++;
    }

    ll ans=cnt[0]*cnt[1]*cnt[2];
    rep(i,1,2000){
        rep(j,N){
            if(j+i*2>=N)break;
            ll bit=0;
            rep(k,3){
                char c=S[j+i*k];
                if(c=='R')bit|=1;
                else if(c=='G')bit|=2;
                else bit|=4;
            }
            if(bit==7)ans--;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3656
A = []

for i in range(3):
    A.extend(input().split())

n = int(input())

for i in range(n):
    com = input()
    if com in A:
        A[A.index(com)] = '0'

if (A[0] == A[1] == A[2] or A[3] == A[4] == A[5] or A[6] == A[7] == A[8] or
    A[0] == A[3] == A[6] or A[1] == A[4] == A[7] or A[2] == A[5] == A[8] or
        A[0] == A[4] == A[8] or A[2] == A[4] == A[6]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064