akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/
// ll power(ll x, ll y) {
//     ll res = 1;x %= mod;
//     while (y > 0) {
//         if (y & 1)res = (res*x) % mod;
//         y = y>>1;
//         x = (x*x) % mod;
//     }
//     return res%mod;
// }
// bool cmp(pair<int, int> a, pair<int, int> b){
//     return (a.fi+a.si) > (b.fi+b.si);
// }
// void solve(){
//     int n, s = 0;
//     cin >> n;
//     vector<pair<int, int> > v(n) ;
//     rep(i, 0, n)cin >> v[i].fi >> v[i].si, s += v[i].fi;
//     sort(all(v), cmp);
//     rep(i, 0, n){
//         if(v[i].fi+v[i].si <= s){
//             cout << "INDEFINITELY\n";
//             return;
//         }
//         else s -= v[i].fi;
//     }
//     int mi, ans = s;
//     rep(i,0,n){
//         if()
//     }
// }

void solve() {
    int n;
    cin >> n;
    int sum = 0, ans = 0;
    rep(i, 0, n){
        int a;
        cin >> a;
        ans = (ans + (a*sum))%mod;
        sum = (sum+a)%mod;
    }
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    // fact((2e6+10));
    // //declare  and  global
    int t = 1;
    // cin >> t;
    rep(i, 0, t){
        solve();
    }
}


Measured memory_bytes: 3644
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int t = sc.nextInt();
		
		if (X-t > 0) System.out.println(X-t);
		else if (X-t <= 0) System.out.println("0");
	}
}


Measured memory_bytes: 21844
from collections import Counter

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

l = [ai - a for ai in l]

cnt = Counter([0, l[0]])

for li in l[1:]:
    tmp = Counter([])
    for k,v in cnt.items():
        tmp[k+li] += v
        
    cnt += tmp
    
print(cnt[0]-1)

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int n,q;
string s;
vector<int>x;
int main()
{
	cin>>n>>s>>q;
	for(int i=0;i<q;i++)
	{
		int a;
		cin>>a;
		x.push_back(a-1);
	}
	for(int i=0;i<x.size();i++)
	{
		int l=x[i];
		long long ans=0,now=0,add=0;
		queue<long long>q;
		for(int i=0;i<n;i++)
		{
			if(s[i]=='D')
			{
				q.push(add);
			}
			if(s[i]=='M')
			{
				now+=q.size();
				add++;
			}
			if(s[i]=='C')
			{
				ans+=now;
			}
			if(i>=l)
			{
				long long k=i-l;
				if(s[k]=='D')
				{
					now-=(add-q.front());
					q.pop();
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 9432
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<pair<int, int>, int>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> SUM(n + 10, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        SUM[max(0ll, i - a[i])]++;
        SUM[min(n, i + a[i] + 1)]--;
    }
    for (int i = 0; i < n; i++)
    {
        SUM[i + 1] += SUM[i];
    }
    int rest = 0;
    for (ll i = 0; i < k - 1; i++)
    {
        ll MIN = 1001001001;
        vector<ll> SUM1(n + 10, 0);
        for (ll j = 0; j < n; j++)
        {
            SUM1[max(0ll, j - SUM[j])]++;
            SUM1[min(n, j + SUM[j] + 1)]--;
        }
        for (int j = 0; j < n; j++)
        {
            SUM1[j + 1] += SUM1[j];
            MIN = min(MIN, SUM1[j]);
        }
        if (MIN >= n)
        {
            rest = k - 1 - i;
            break;
        }
        swap(SUM, SUM1);
    }
    if (rest > 0)
    {
        for (int i = 0; i < n; i++)
        {
            cout << n << " ";
        }
        cout << endl;
    }
    else
    {
        for (int i = 0; i < n; i++)
        {
            cout << SUM[i] << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 7960
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int n = in.nextInt();
            int[] a = new int[n];
            long[] acc = new long[n];

            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                acc[i] = (i == 0 ? a[i] : acc[i - 1] + a[i]);
            }

            long bst = (long) 1e18;

            for (int i = 0; i < n - 1; ++i) {
                bst = Math.min(bst, Math.abs(acc[i] - (acc[n - 1] - acc[i])));
            }

            out.println(bst);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 49824
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 200010
ll n, m;
P v[N];
int main(){
	cin>>n>>m;
	rep(i, n){
		int a, b;
		cin>>a>>b;
		v[i] = P(a, b);
	}
	sort(v, v+n);
	vector<ll> y;
	priority_queue<ll, vector<ll>, greater<ll> > x;
	rep(i, n){
		x.push(v[i].snd);
		if(x.size()>v[i].fst){
			y.push_back(m+1-x.top()); x.pop();
		}
	}
	ll res = 0, cnt = 0;
	sort(all(y));
	rep(i, y.size()){
		if(cnt+1<= y[i]) cnt++;
		else res++;
	}
	res = max(res, n-m);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 6260
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

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

	int n;
	cin >> n;
	vector<int> s(n);
	for (auto &t : s) {
		cin >> t;
	}
	auto rs = s;
	reverse(rs.begin(), rs.end());
	for (int i = 0; i < n; i++) {
		s[i] += rs[i]; 
	}
	vector<vector<int>> ps(n, vector<int> (1, 0));
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < n; j += i) {
			ps[i].push_back(ps[i].back() + s[j]);
		}
	}
	int ans = 0;
	auto rlx = [&](int a, int b, int k) {
		int c = a - b;
		if (a % c == 0 && a / c <= k) return;
		k++;
		int cr = ps[c][k];
		ans = max(ans, cr);
	};
	n--;
	for (int k = 1; k <= n; k++) {
		for (int c = 0; c <= n / k; c++) {
			int a = n - k * c;
			int b = a - c;
			if (a > 0 && b >= 0 && a > b && a < n) {
				rlx(a, b, k); 
			}
		}
	}
	cout << ans << endl;
}


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


class Solution {
  string s;
public:
  void run() {
    cin >> s;
    cin >> s;
    cout << (count(s.begin(), s.end(), 'R') > count(s.begin(), s.end(), 'B') ? "Yes" : "No") << '\n';
  }     
};
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  Solution().run();
}


Measured memory_bytes: 256
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = list(map(int,input().split()))

Ans = 10**8
for x in range(-100,100+1):
    ans = 0
    for i in range(N):
        ans += (A[i] - x)**2
    Ans = min(Ans,ans)

print(Ans)

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

int	main() {
	string S;
	string Su="Sunny";
	string Cl="Cloudy";
	string Ra="Rainy";
	cin >>S;
	if (S==Su)
		cout <<Cl <<endl;
	else if (S==Cl)
		cout <<Ra <<endl;
	else 
		cout<<Su <<endl;
	return 0;
};


Measured memory_bytes: 256
N, M = map(int, input().split())

def comb(n, r):
    bunshi = 1
    for i in range(n-r+1,n+1):
        bunshi = bunshi*i
    bunbo = 1
    for i in range(1,r+1):
        bunbo = bunbo * i 
    return bunshi//bunbo

print(comb(N,2)+comb(M,2))


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

int main() {
	long N,A,B;
	string S;
	cin >> N >> A >> B >> S;
	
	long all=A+B;
	long fore=B;
	
	for(long i=0; i<N; i++){
		if(S[i]=='c'){cout<<"No"<<endl;}
		else if(S[i]=='a'){
			if(all>0){cout<<"Yes"<<endl; all--;}
			else{cout<<"No"<<endl;}
		}
		else if(S[i]=='b'){
			if(all>0 && fore>0){
				cout<<"Yes"<<endl;
				all--;
			}
			else{cout<<"No"<<endl;}
			
			fore--;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

int main() {

	string s;
	cin >> s;
	
	if (s[0] == s[1]) {
		cout << 1 << ' ' << 2 << endl;
		return 0;
	}

	int letter0 = 0;
	int letter1 = 1;
	for (int i = 2; i < s.size();++i) {
		if (s[i] == s[letter0]) {
			cout << letter0 + 1 << ' ' << i + 1 << endl;
			return 0;
		}
		else {
			letter0++;
			letter1++;
			if (s[letter0] == s[letter1]) {
				cout << letter0 + 1 << ' ' << letter1 + 1 << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
// SeeAlso: https://atcoder.jp/contests/abc143/tasks/abc143_d

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

const long double PI = acos(-1);

int main() {

    ll N;
    cin >> N;
    vector<int> L;
    rep(i, N) {
        int l;
        cin >> l;
        L.push_back(l);
    }
    sort(L.begin(), L.end());

    ll counter = 0;
    FORR(a, 0, N) {
        FORR(b, 0, a) {
            auto it = lower_bound(L.begin(), L.end(), L[a]+L[b]);
            ll ng = distance(it, L.end());
            counter += (N-1-a)-ng;
        }
    }
    print(counter);
    return 0;
}


Measured memory_bytes: 256
# abc167 D
n, k = gets.split.map(&:to_i)
a = gets.split.map{|x|x.to_i - 1}

s = [1]

visited = Array.new(n, 0)
visited[0] = 1


# pos = 0
# n.times do
#   s << a[pos]
#   pos = a[pos] - 1
# end
# p s

pos = 0
loop_cnt = 1
b = [0]
loop do
  b << a[pos]
  pos = a[pos]
  if visited[pos] == 2
    break
  end
  visited[pos] += 1

  loop_cnt += 1
end
b.pop
bs = b.map(&:succ)
bs2 = bs.map{|bss|[bss,visited[bss-1]]}
one = bs2.select{|x| x[1] == 1}
two = bs2.select{|x| x[1] == 2}
if k < one.size
  p one[k][0]
else
  p two[(k - one.size) % two.size][0]
end





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

VV g;
V memo;

ll dfs(ll now){
    if(memo[now]!=-1)return memo[now];
    ll tmp=-1;
    for(ll to:g[now]){
        tmp=max(tmp,dfs(to));
    }
    memo[now]=tmp+1;
    return tmp+1;
}

int main(){
    ll n,m;
    cin>>n>>m;
    g.assign(n, V());
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        g[x].push_back(y);
    }
    memo.assign(n, -1);
    ll ans=0;
    rep(i,n)ans=max(ans,dfs(i));
    cout<<ans<<endl;
}


Measured memory_bytes: 8576
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int N;
	cin >> N;
	if (N / 10 == 9 || N % 10 == 9)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;

	return 0;
}

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

string a, b;
int num;

int main() {
  cin >> a >> b;
  num = stoi(a + b);
  string ans = "No";
  rep (i, 1000) {
    if (i * i == num) {
      ans = "Yes";
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, h;
  scanf("%d\n %d\n %d\n", &a, &b, &h);
  if (1<=a<=100 && 1<=b<=100 && 1<=h<=100){
    printf("%d\n", (a+b)*h/2);
  }else {
    printf("%s\n", "Invalid!");
  }
}
  


Measured memory_bytes: 1700
import math

N = int(input())

#Nが偶数
def prob_even(N):
    return 1/2
  
#Nが奇数
def prob_odd(N):
    return math.ceil(N/2)/N
  
if N%2 == 0:
    ans = prob_even(N)
else:
    ans = prob_odd(N)
    
print(ans)

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

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

	int N;
	cin >> N;

	vector<int> color;
	map<int, int> cnt;
	for(int i = 0; i < N; i++) {
		int c;
		cin >> c;
		color.push_back(c);
		cnt[c]++;
	}

	sort(color.begin(), color.end());
	color.erase(unique(color.begin(), color.end()), color.end());

	if(color.size() >= 3) {
		cout << "No" << endl;
	}
	else if(color.size() == 1) {
		if(color[0] == N - 1 || N >= color[0] * 2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		int right = color[1], x = color[0];
		int rem = right - cnt[x];
		if(right - x == 1 && rem >= 1 && rem * 2 <= cnt[right]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 5368
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    let line = chunk.toString().split(' ');
    let a = parseInt(line[0]);
    let b = parseInt(line[1]);
    if (a > b) { 
        console.log("a > b");
    } else if (a < b) { 
        console.log("a < b");
    } else {
        console.log("a == b");
    }
});


Measured memory_bytes: 15492
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << std::endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 1.5*1e5 + 10;
// make sure N size is correctttt!!!!!!!!!

int dp[N], n, h[N];
int solve(int idx){
   if(idx == n-1){
      return 0;
   }
   else if(idx > n){
      return inf;
   }
   int &ans = dp[idx];
   if(ans != -1)
      return ans;
   ans = inf;
   ans = min(solve(idx+1)+abs(h[idx]-h[idx+1]), solve(idx+2)+abs(h[idx]-h[idx+2]));
   return ans;
}

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

int32_t main(){_

   // n = 1e5;
   cin>>n;
   for (int i = 0; i < n; ++i)
   {
      // h[i] = 1+rng()%(N);
      cin>>h[i];
   }

   for (int i = n; i < n+10; ++i)
   {
      h[i] = inf;
   }

   memset(dp, -1, sizeof dp);
   cout<<solve(0);

   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 3840
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a % 3 == 0){
        printf("Possible");
    }
    else if(b % 3 == 0){
        printf("Possible");
    }
    else if((a+b) % 3 == 0){
        printf("Possible");
    }
    else{
        printf("Impossible");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    string S;
    cin >> S;
    if (S=="ABC") cout << "ARC\n";
    else cout << "ABC\n";
}


Measured memory_bytes: 3656
N = int(raw_input())
W = []
ans = True
for i in range(N):
    W.append(raw_input())
    
for i in range(0,len(W)):
    if W.count(W[i]) != 1:
        ans = False
        break

for i in range(0,len(W)-1):
    A = W[i]
    B = W[i+1]
    if A[-1] != B[0]:
        ans = False
        break

if ans:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x;
    cin>>x;
    int ret = 0;
    ll t = 100;
    while(t < x)
    {
        t = floor(t * 1.01);
        ret ++;
    }
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 3752
def main():
    n = int(input())
    res = {
        'AC': 0,
        'WA': 0,
        'TLE': 0,
        'RE': 0,
    }
    for _ in range(n):
        res[input()] += 1
    for k,v in res.items():
        print('{} x {}'.format(k, v))

main()

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

vector<string> v;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    int a, b, c, d, e;
    while (scanf("%d,%d,%d,%d,%d", &a, &b, &c, &d, &e) != EOF)
    {
        int arr[14];
        for (int i = 0; i < 14; ++i)
            arr[i] = 0;

        arr[a]++;
        arr[b]++;
        arr[c]++;
        arr[d]++;
        arr[e]++;

        bool checked = false;
        for (int i = 1; i <= 13; ++i)
        {
            if (arr[i] == 4)
            {
                cout << "four card" << endl;
                checked = true;
            }
        }
        if (checked)
            continue;

        bool two = false, two2 = false, three = false;
        for (int i = 1; i <= 13; ++i)
        {
            if (two == true && arr[i] == 2)
                two2 = true;
            if (arr[i] == 2)
                two = true;

            if (arr[i] == 3)
                three = true;
        }
        if (two && three)
        {
            cout << "full house" << endl;
            checked = true;
        }
        if (checked)
            continue;

        bool str = false;

        for (int i = 1; i <= 13 - 4; ++i)
        {
            if (arr[i] == 1 && arr[i + 1] == 1 && arr[i + 2] == 1 && arr[i + 3] == 1 && arr[i + 4] == 1)
                str = true;
        }

        if (str == true || (arr[1] == 1 && arr[1] == arr[2] && arr[2] == arr[3] && arr[3] == arr[4] && arr[4] == arr[5]) || (arr[1] == 1 && arr[1] == arr[10] && arr[10] == arr[11] && arr[11] == arr[12] && arr[12] == arr[13]))
        {
            cout << "straight" << endl;
            checked = true;
        }

        if (checked)
            continue;

        if (three)
        {
            cout << "three card" << endl;
            checked = true;
        }
        if (checked)
            continue;

        if (two && two2)
        {
            cout << "two pair" << endl;
            checked = true;
        }
        if (checked)
            continue;

        if (two)
        {
            cout << "one pair" << endl;
            checked = true;
        }
        if (checked)
            continue;

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


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x[100010];
int main()
{
    int n,m;
    int t;
    while(scanf("%d%d%d",&t,&n,&m)!=EOF)
    {
        if(abs(n-t)<abs(m-t)) printf("A\n");
        else printf("B\n");
    }





}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int l , r ;
	cin >> l >> r ;
	if( l / 2019 != r / 2019 ){
		puts("0");
		return 0 ;
	}
	l %= 2019 , r %= 2019; 
	int ans = 2020;
	for(int i = l ; i <= r ; i++){
		for(int j = i+1 ; j <= r ; j++){
			int tmp =  ( i * j ) % 2019 ;
			chmin(ans,tmp);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
x = input().split()

a = int(x[0])
b = int(x[1])

if a < b:
    s = ""
    for i in range(b):
        s = s+str(a)
    print(s)
else:
    s = ""
    for i in range(a):
        s = s+str(b)
    print(s)

Measured memory_bytes: 3060
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
import re
#solve
def solve():
    s = S()
    if re.fullmatch("(A?)KIH(A?)B(A?)R(A?)", s):
        print("YES")
    else:
        print("NO")
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 4700
import std.stdio;

void main() {
    int N, M; readf("%d %d\n", &N, &M);
    int[] ans;
    int i;
    for (i = 0; i < N / 2 + 1; i++) {
        ans ~= 0;
    }
    for (; i < N; i++) {
        ans ~= M;
    }
    writefln("%(%s %)", ans);
}

Measured memory_bytes: 2528
#include<bits/stdc++.h>
#define maxn 200010
#define mod 1000000007
using namespace std;
int a[maxn], f[maxn], sum[maxn];
int main()
{
	int n, cur = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		if (cur == 0 || x != a[cur]) a[++cur] = x;
	}
	f[0] = 1;
	for (int i = 1; i <= cur; i++)	
	{
		sum[a[i]] = (sum[a[i]] + f[i - 1]) % mod;
		f[i] = sum[a[i]];
	}
	printf("%d\n", f[cur]);
	return 0;
}

Measured memory_bytes: 2560
//#define _GLIBCXX_DEBUG
//#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
using namespace std;
///typedef long long ll;

int main() {
    int n;
    scanf("%d",&n);
    printf("%d",10-n/200);
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define pi pair<int,int>
#define si second
#define fi first
#define show_(x) cerr<<"-> "<<#x<<endl;F(x){cerr<<it<<" ";}cout<<endl;
#define show(x) cerr<<#x<<"-> "<<x<<endl;
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("F:\\inout\\input.txt", "r", stdin); freopen("F:\\inout\\output.txt", "w", stdout);
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rb;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=p(a,b/2); if(b%2==0)return t*t; else return a*t*t; } 
//---------------------------------------------------------------------------------------------------------------------------------------------


signed main(){
	//FILEIO
	//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	//----sure_am-----
	
	int n,m;
	cin>>n>>m;
	map <int,int> m1 ,m2;
	f(n){
		m2[i+1]=0;
		m1[i+1]=0;
	}

	f(m){
		int x;
		string s;
		cin>>x>>s;
		if(s=="AC"){ 
			m1[x]=1;

		}
		else{
			if(m1[x]==0){
				m2[x]++;
			}
			
		}
	}

	int ans=0;
	int count=0;
	F(m1){
		if(it.si==1){
			ans++;
		}
	}
	F(m2){
		if(m1[it.fi]==1){
			count+=it.si;
		}
	}
	cout<<ans<< " "<<count<<endl;
	
	
	






	return 0;
}





Measured memory_bytes: 12800
if __name__ == '__main__':
    [N, C, K] = [int(i) for i in input().split()]

    T = []
    for i in range(N):
        T.append(int(input()))
    T.sort()

    counter = 1

    num_people = 0

    flag = False

    for num in T:
        num_people += 1
        if flag:
            if num - first_time <= K and num_people <= C:
                continue
            else:
                counter += 1
                num_people = 1
                first_time = num

        else:
            first_time = num
            flag = True

    print(counter)


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

int main(void){
	int n;
	vector<int> car;

	cin >> n;
	car.push_back(n);

	while(cin >> n){
		if(n!=0) car.push_back(n);
		else{
			cout << car.back() << endl;
			car.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 1212
N, K = map(int, input().split())
dice = list(map(int, input().split()))

#dice.sort(reverse=True)
MAXX = 1001
ave = [0.0]*MAXX

ans = 0.0
right = 0
#sumz = [0.0]*(N+1)
# #累積和
# for i in range(N):
#     x = dice[i]
#     if ave[x] <= 0.000001:
#         ave[x] = (x + 1) / 2.0
#     sumz[i+1] = sumz[i]+ ave[x]
#
# #find max
# for i in range(K, N+1):
#     if ans < sumz[i] - sumz[i-K]:
#         ans = sumz[i] - sumz[i-K]
#
# print(ans)
#
sumz = 0.0
for left in range(0, N):
    if right <= left: right = left+1
    while right <= N and right - left <= K:
        x = dice[right-1]
        if ave[x] <= 0.000001:
            ave[x] = (x+1)/2.0
        sumz += ave[x]
        right += 1

    if ans < sumz:
        ans = sumz

    sumz -= ave[dice[left]]

print(ans)


Measured memory_bytes: 91920
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

int main(){
    SS(ll,n);
    vector<pair<ll,ll>>A;
    rep(i,n){
        SS(ll,a,b);
        A.push_back({a,b});
    }
    sort(A.begin(),A.end(),cmp);
    ll aoki=0,takahasi=0;
    rep(i,n){
        if(i%2==0)takahasi+=A[i].first;
        else aoki+=A[i].second;
    }
    p(takahasi-aoki);
}

Measured memory_bytes: 3444
import pprint

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

day = 0
check = set(range(n))

while True:
    end = 1
    game = set()
    for i in check:
        if a[i] != []:
            end = 0
            if a[a[i][0]-1] != []:
                if a[a[i][0]-1][0]-1 == i:
                    game.add(i)
                    game.add(a[i][0]-1)
    if end == 0:
        if game == set():
            print(-1)
            exit()
        else:
            for i in game:
                a[i].pop(0)
    else:
        print(day)
        exit()
    day += 1
    check = game

Measured memory_bytes: 35708
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
  int n, q;
  cin >> n >> q;
	int a[n];
  for(int i = 0; i < n; i++)
    cin >> a[i]; 
	Query queries[q]; 
  for(int i = 0; i < q; i++) {
    cin >> queries[i].l >> queries[i].r;
    queries[i].l--;
    queries[i].r--;
    queries[i].idx = i;
  } 
	sort(queries, queries + q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
} 


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll R[510][510], sum[510][510];

int main(int argc, char **argv)
{
	ll N, M, Q; cin >> N >> M >> Q;
	REP(i, M)
	{
		ll l, r; cin >> l >> r;
		++R[l][r];
	}

	memset(sum, 0, sizeof sum);
	for (ll i = 1; i <= N; ++i)
		for (ll j = 1; j <= N; ++j) sum[i][j] = sum[i][j-1] + R[i][j];

	REP(_, Q)
	{
		ll l, r; cin >> l >> r;
		ll res{0};
		for (ll i = l; i <= r; ++i)
			res += sum[i][r] - sum[i][l-1];

		std::cout << res << std::endl;
	}
}


Measured memory_bytes: 4992
#include <stdio.h>

int main()
{
	int H, W, N;
	scanf("%d %d %d", &H, &W, &N);

	int ans;

	if (H > W) {
		ans = N / H;
		if (N % H != 0) {
			ans++;
		}
	}
	else {
		ans = N / W;
		if (N % W != 0) {
			ans++;
		}
	}

	printf("%d", ans);

	return 0;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        int[] nabc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int N = nabc[0];
        int A = nabc[1];
        int B = nabc[2];
        int C = nabc[3];

        var bambooList = Enumerable.Range(0, N).Select(n => Console.ReadLine()).Select(s => int.Parse(s)).ToArray();

        //各竹はAの材料にするかBの材料にするかCの材料にするか何の材料にもしないか4択

        var mpMin = int.MaxValue;

        var nnn = (int)Math.Pow(4, N) - 1;
        for(int i = 0; i <= nnn; i++)
        {
            var pattern = Enumerable.Range(0, N).Select(n => ((i / (int)Math.Pow(4, n)) % 4)).ToArray();
            int[] arr = new int[4];

            var mp = 0;

            for(int j = 0; j < pattern.Length; j++)
            {
                if (pattern[j] == 3) continue;

                if (arr[pattern[j]] != 0)
                {
                    mp += 10;
                }
                arr[pattern[j]] += bambooList[j];
            }

            if (arr[0] * arr[1] * arr[2] == 0) continue;

            mp += Math.Abs(arr[0] - A);
            mp += Math.Abs(arr[1] - B);
            mp += Math.Abs(arr[2] - C);

            mpMin = Math.Min(mpMin, mp);
        }

        Console.WriteLine(mpMin);
    }
}

Measured memory_bytes: 15424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int N, ll Y, int &a, int &b, int &c){

    ll money;
    bool flg = false;
    for(a = 0; a != N+1; ++a){
        for(b = 0; b != N+1-a; ++b){
            c = N - (a + b);
            money = a*10000 + b*5000 + c*1000;

            if(money == Y){
                flg = true;
                break;
            }
        }
        if(flg) break;
    }

    if(!flg){
        a = -1;
        b = -1;
        c = -1;
    }

    return;
}

int main(){

    int N;
    ll Y;
    cin >> N >> Y;

    int a{}, b{}, c{};
    solver(N, Y, a, b, c);

    cout << a << " "s << b << " "s << c << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
const int MAXN=2000000+10;
long long w[MAXN],v[MAXN],f[MAXN];
int main()
{
	long long n,m,ans=-1;
	cin>>n>>m;
	for(int i=0;i<n;++i)
	{
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			f[j]=max(f[j],f[j-w[i]]+v[i]);
			ans=max(ans,f[j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5120
from collections import deque
 

N = int(input())
edge = [[] for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  edge[a-1] += [b-1]
  edge[b-1] += [a-1]
A = list(map(int, input().split()))
A.sort(reverse = 1)
print(sum(A[1:]))

ans = [[0, A[0]]]#0番目の頂点には最大値を入れる
cnt = 1#頂点数
visited = [1] + [0]*(N-1)#訪問フラグ
que = deque([0]) 
while que:
  u = que.pop()
  for v in edge[u]:
    if visited[v] == 0:#未訪問なら値を入れる
      que.append(v)
      visited[v] = 1
      ans += [[v,A[cnt]]]
      cnt += 1
ans.sort()

ans2 = []
for i in range(N):
  ans2 += [ans[i][1]]
print(' '.join(map(str, ans2)))

Measured memory_bytes: 7532
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = [0] + list(map(int, input().split())) + [0]

    cost_init = 0
    for i in range(1, n + 2):
        cost_init += abs(A[i - 1] - A[i])

    for i in range(1, n + 1):
        if A[i - 1] <= A[i] <= A[i + 1] or A[i - 1] >= A[i] >= A[i + 1]:
            print(cost_init)
        elif A[i - 1] <= A[i] and A[i] >= A[i + 1] or A[i - 1] >= A[i] and A[i] <= A[i + 1]:
            cost = cost_init - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1])) + abs(A[i - 1] - A[i + 1])
            print(cost)


if __name__ == '__main__':
    resolve()


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

int main () {
    
    int N;
    
    cin >> N;
    
    double sum;
    
    while (N-->0) {
        double A;
        string S;
        cin >> A >> S;
        if (S=="JPY") {
            sum+=A;
        } else {
            sum+=A*380000;
        }
    }
    
    cout << sum;
    
    return 0;
    
}


Measured memory_bytes: 256
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>


int main() {

	int a, b, c, d, e;
	int aa, bb, cc, dd, ee;
	int time = 0;
	int tmp;
	int max = 0;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);

	

	if (a % 10 > 0)aa = 10 - a % 10; else aa = 0;
	if (b % 10 > 0)bb = 10 - b % 10; else bb = 0;
	if (c % 10 > 0)cc = 10 - c % 10; else cc = 0;
	if (d % 10 > 0)dd = 10 - d % 10; else dd = 0;
	if (e % 10 > 0)ee = 10 - e % 10; else ee = 0;

	if (max < aa)max = aa; if (max < bb)max = bb; if (max < cc)max = cc; if (max < dd)max = dd; if (max < ee)max = ee;
	

	time = a+b+c+d+e+aa+bb+cc+dd+ee-max;

	
	printf("%d", time);


	return(0);
}

Measured memory_bytes: 128
import math
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N,M,R=[int(x) for x in input().split()]
r=[int(x)-1 for x in input().split()]

route_list=[[10**9]*N for i in range(N)]

for i in range(M):
    a,b,c=[int(x) for x in input().split()]
    route_list[a-1][b-1]=c
    route_list[b-1][a-1]=c

wa_list=warshall_floyd(route_list)
ans=30**9

for perm in permutations(r):
    #print(perm)
    cur = sum(wa_list[v][u] for v, u in zip(perm, perm[1:]))
    ans = min(ans, cur)

print(ans)

Measured memory_bytes: 50520
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e15
#define mod 1000000007
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
#define lb lower_bound
#define ub upper_bound
#define fr(a,b,c) for(ll a = b ; a <= c ; ++a )
#define frn(a,b,c) for(ll a = b ; a >= c ; a -- )
#define fra(a,b) for(auto a: b)
#define ms(a) memset(a,0,sizeof a);
#define alla(a) a,a+n
#define allv(a) a.begin(),a.end()
#define size(a) (ll)a.size()
#define getMat(x,n,m,val) vector<vector<ll>>x(n,vector<ll>(m,val))
const ll MAXN = 1e5+5;
#define pii 3.14159265358979323846 
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
struct node{
	ll d,c,p;
};
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,w;cin>>n>>w;
	pi arr[n];fr(i,0,n-1)cin>>arr[i].ff>>arr[i].ss;
	ll dp[n+1][100010];ms(dp);
	ll ans = 0 ; 
	fr(i,0,n){
		if(!i){
			fr(j,1,100000)dp[i][j]=inf;
			continue;
		}
		fr(j,0,100000){
			dp[i][j]=dp[i-1][j];
			if(arr[i-1].ss<=j){
				dp[i][j]=min(dp[i][j],dp[i-1][j-arr[i-1].ss]+arr[i-1].ff);
			}
			if(dp[i][j]<=w){
				ans = max(ans,j);
			}
		}
	}
	cout<<ans<<en;
	return 0 ;

}

Measured memory_bytes: 82532