akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ff first
#define ss second

typedef pair<int, int> ii;

vector <int> nums;
vector <ii> tree;



struct ctnr{
    int mxa, mxb;
};

ii giveMe(ii x, ii y)
{
    ii ret;
    ret.ff = max(x, y).ff;
    ret.ss = max(max(x, y).ss, min(x, y).ff);
    return ret;
}

void buildtree(int node, int s, int e)
{
    if(s==e){
        tree[node] = {nums[s], -1};
        return;
    }
    buildtree(node*2, s, (s+e)/2);
    buildtree(node*2 + 1, (s+e)/2 + 1, e);

    tree[node] = giveMe(tree[node*2], tree[node*2 + 1]);
}

ii query(int node, int s, int e, int rs, int re)
{
    if(max(s, rs)>min(e, re)) return {-1, -1};
    if(s>=rs && e<=re) return tree[node];
    else return giveMe(query(node*2, s, (s+e)/2, rs, re), query(node*2+1, (s+e)/2 + 1, e, rs, re));
}

int main()
{
    int n;
    scanf("%d", &n);

    nums.resize(n + 3);
    tree.resize(n * 3 + 15);

    for(int i = 0; i<n; i++){
    	sf("%d", &nums[i+1]);
    }

    buildtree(1, 1, n);
    long long ans = 0;

    for(int i = 1; i<=n; i++){
        //find x1
        int x1 = 0, x2 = 0;
        int lo = 1, hi = i - 1, mid;
        while(hi>=lo){
            int mid = (hi+lo)/2;
            ii x = query(1, 1, n, mid, i);
            if(x.ff == nums[i]) hi = mid - 1;
            else{
                if(x.ss==nums[i]) x1 = mid;
                lo = mid + 1;
            }
        }

        // find x2
        lo = 1, hi = x1 - 1, mid;
        while(hi>=lo){
            int mid = (hi+lo)/2;
            ii x = query(1, 1, n, mid, i);
            if(x.ss == nums[i]) hi = mid - 1;
            else{
                if(x.ss > nums[i]) x2 = mid;
                lo = mid + 1;
            }
        }

        //find y1
        int y1 = 0, y2 = 0;
        lo = i + 1, hi = n, mid;
        while(hi>=lo){
            int mid = (hi+lo)/2;
            ii x = query(1, 1, n, i, mid);
            if(x.ff == nums[i]) lo = mid + 1;
            else{
                if(x.ss==nums[i]) y1 = mid;
                hi = mid - 1;
            }
        }

        // find y2
        lo = y1, hi = n, mid;
        while(hi>=lo){
            int mid = (hi+lo)/2;
            ii x = query(1, 1, n, i, mid);
            if(x.ss == nums[i]) lo = mid + 1;
            else{
                if(x.ss > nums[i]) y2 = mid;
                hi = mid - 1;
            }
        }
        //printf("%d\n", nums[i]);
        //printf("%d %d\n", nums[x1], nums[x2]);
        //printf("%d %d\n", nums[y1], nums[y2]);

        long long int delta = 0;

        if(!x1 && !y1) delta += 0;
        if(y1){
            if(y2) delta += (y2 - y1) * (i - x1);
            else delta += (n - y1 + 1) * (i - x1);
        }

        //cout<<"MID-DELTA: "<<delta<<endl;

        if(x1){
            if(!y1) y1 = n + 1;
            if(x2) delta += (x1 - x2) * (y1 - i);
            else delta += (x1) * (y1 - i);
        }

        //cout<<"DELTA: "<<delta<<endl;

        ans += (delta * nums[i]);

    }

    printf("%lld\n", ans);


    return 0;

}


Measured memory_bytes: 2944
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=5e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

int ans[N];
char s[N];
int32_t main()
{
    sf("%s",s);
    int n=strlen(s);
    for(int i=0;i<=n;i++) {
        if(i==0||s[i-1]=='>') if(i==n||s[i]=='<'){
            ans[i]=max(ans[i],0);
            for(int k=i-1;k>=0&&s[k]=='>';k--) ans[k]=max(ans[k],ans[k+1]+1);
            for(int k=i+1;k<=n&&s[k-1]=='<';k++) ans[k]=max(ans[k],ans[k-1]+1);
        }
    }
    ll res=0;
    for(int i=0;i<=n;i++) res+=ans[i];
    pf1ll(res);
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 2688
package main

import "fmt"

const (
	mod   = 998244353
	limit = 200001
)

var (
	fac  = make([]int, limit)
	finv = make([]int, limit)
	inv  = make([]int, limit)
)

func powMod(a, n int) int {
	rst := 1
	for n > 0 {
		if n&1 != 0 {
			rst = rst * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return rst
}

func combModInit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < limit; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combMod(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod
}

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)

	combModInit()
	ans := 0
	for i := 0; i <= k; i++ {
		ans += (((m * (combMod(n-1, i) % mod)) % mod) * powMod(m-1, n-i-1)) % mod
		ans %= mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6736
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int r, g;
    cin >> r >> g;
    int p = 2 * g - r;
    cout << p << endl;
    return 0;
}

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

using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
int mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    int n,m,i;
    cin>>n>>m;
    vi adj[n+1];
    vi vis(n+1);
    int u,v;
    REP(i,1,m) {
        cin>>u>>v;
        adj[u].EB(v);
        adj[v].EB(u);
    }
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int f=q.front();
        q.pop();
        for(auto u:adj[f]){
            if(vis[u]) continue;
            vis[u]=f;
            q.push(u);
        }
    }
    REP(i,1,n) 
        if(!vis[i]) {
            cout<<"No";
            return 0;
        }
    cout<<"Yes\n";
    REP(i,2,n) cout<<vis[i]<<"\n";
    return 0;
}


Measured memory_bytes: 10316
import numpy as np

N = int(input()) 
H = list(map(int, input().split()))

def count(b):
    b = np.clip(b, 0, 1)
    return int(b[0] > 0) + np.sum(np.diff(b) > 0)

heights = np.array(H)

cnts = []
for water in range(100):
    arr = np.clip(heights - water, 0, 101)
    cnts.append(count(arr))

print(np.sum(cnts))

Measured memory_bytes: 26916
#include <iostream>
#include <vector>
#include <string>

#define YEAR 2004

using namespace std;

int main() {
	vector<string> week;
	week.push_back("Monday");
	week.push_back("Tuesday");
	week.push_back("Wednesday");
	week.push_back("Thursday");
	week.push_back("Friday");
	week.push_back("Saturday");
	week.push_back("Sunday");
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

	int m,d;
	int index = 3; //1月1日が木曜日なので

	while(cin>>m>>d){
		if(m==0 || d==0){ break; }
		for(int i=0; i<m; i++){
			for(int j=1; j<=month[i]; j++){
				if(i+1==m and j==d){ break; }
				index++;
				if(index == 7) index=0;
			}
		}
		cout<<week[index]<<endl;
		index = 3;
	}
	return 0;
}

Measured memory_bytes: 1196
lN = list(input())

if lN[len(lN)-1]=='3':
  print('bon')

elif lN[len(lN)-1]=='0' or lN[len(lN)-1]=='1' or lN[len(lN)-1]=='6' or lN[len(lN)-1]=='8':
  print('pon')

else:
  print('hon')


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

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

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N-1);
    rep(i, N-1) {
        cin >> A[i];
        A[i]--;
    }

    vector<int> ans(N);
    rep(i, N-1) {
        ans[A[i]]++;
    }

    rep(i, N) cout << ans[i] << endl;
}

Measured memory_bytes: 4840
function Main(input) {
	var C = 1e+9 + 7;
	var C2 = 1e+5;	
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let N = parseInt(input[0][0], 10);
	let A = input[1].map(e => parseInt(e, 10));
	let ruisekiwa = [0];
	for (let i = 0; i < N; i++){
		ruisekiwa.push((ruisekiwa[i] + A[i]) % C);
	}
	// console.log(ruisekiwa);

	let ans = 0;
	for (let i = 0; i < (N - 1); i++){
		ans += kakeruR(A[i], mod(ruisekiwa[N] - ruisekiwa[i + 1],C), C, C2);
		ans = mod(ans, C)
	}
	console.log(ans);
}

function mod (i, j){
	return(i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

function kakeruR(a, b, C, C2){
    var tmpQ, tmpR, ans;
    tmpQ = Math.floor(b / C2);  // CAUTION!!
    tmpR = b - (tmpQ * C2);
    ans = (a * tmpQ % C) * C2 % C + (a * tmpR);
    ans %= C;
    return ans;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 56292
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveA();
    }
    
    private void solveA() {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int p = 0;
	int ans = 0;

	for (int i=0;i < n;i++){
	    int a = sc.nextInt();
	    if (a==p){
		p = 0;
		ans++;
	    }
	    else p = a;
	}
    	System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, K;
	cin >> N >> K;
	map<int, int>m;
	rep(i, K) {
		int d;
		cin >> d;
		rep(i, d) {
			int A;
			cin >> A;
			m[A]++;
		}
	}
	int ans = N - m.size();
	cout << ans;
}

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

int main()
{
 long long int test;
 //cin>>test;
 test=1;
 while(test--)
 {
  int n,x,t;
  cin>>n>>x>>t;
  long long int ans;
  if(n%x)
   ans=(n/x)+1;
  else
   ans=n/x;
 ans=ans*t;
 cout<<ans;
 }
}

Measured memory_bytes: 3580
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d%d", &a,&b);
    if(a == 1){
        a = 14;
    }
    if(b == 1){
        b = 14;
    }
    
    if(a > b){
        printf("Alice");
    }
    else if(a == b){
        printf("Draw");
    }
    else{
        printf("Bob");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define maxN	100001
#define nl		"\n"
using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x;
	cin >> x;
	cout << (x/500)*1000 + ((x-500*(x/500))/5)*5 << nl;
	return 0;
}


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

int main()
{
	while (1)
	{
		int s;
		cin >> s;
		if (s == -1)break; 
		if (s == 0)cout << 0 << endl;
		else {
			int a;
			for (a = 1; a <= s; a *= 4) {
			}
			a /= 4;
			for (int b = a; b != 0; b /= 4) {
				cout << s / b;
				s -= s / b*b;
			}
			cout << endl;
		}
	}
}

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

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> p(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &p[i]);

  sort(p.begin(), p.end());
  int s = 0;
  for (int i = 0; i < k; i++)
    s += p[i];

  printf("%d\n", s);

  return 0;
}

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

typedef long long ll;
static const ll INF = 1ll<<60;
static const int MOD = 1e9+7;

struct PrimeFact {
    vector<ll> spf;
    PrimeFact(ll N) { init(N); }
    void init(ll N) { 
        spf.assign(N + 1, 0);
        for (ll i = 0; i <= N; i++) spf[i] = i;
        for (ll i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (ll j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }

    map<ll, ll> get(ll n) { 
        map<ll, ll> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

int main(){
    ll N;
    ll ans = 0;
    cin>>N;
    PrimeFact p(N);

    for(ll i=1; i<=N; i++){
        ll add = 1;
        map<ll,ll> m = p.get(i);
        for(auto a : m) add *= (a.second+1);
        add *= i;
        ans += add;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 81348
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int c = r.read();
        int nextC = c + 1;

        System.out.println((char)nextC);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 0 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }
}

Measured memory_bytes: 21076
// inputに入力データ全体が入る
function Main(input) {
	var input = input.split("\n");
    str = String(input);
    var sum = 0;
	for (  var i = 0;  i < 3;  i++  ) {
      sum = sum + parseInt(str.charAt(i), 10);
    }
	//出力
	console.log('%d',sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n, m = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

if n > m:
    print(0)
    exit()

X.sort()
D = []

for i in range(m-1):
    D.append(X[i+1] - X[i])

D.sort()

print(sum(D[:m - n]))

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

int main() {
	int n = 0;
	int result = 0;
	scanf("%d", &n);

	for (int i = 1; i < 10; i++) {
		if (n % i == 0 && n / i <= 9) {
			result = 1;
			break;
		}
	}
	
	if (result == 1) {
		printf("Yes");
	}
	else if (result == 0) {
		printf("No");
	}
	
	//system("PAUSE");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long double p=3.14159265358979323846;
    long double a;
    cin>>a;
    cout<<2.0*p*a<<endl;
}

Measured memory_bytes: 3820
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    int n;
    cin >> n;

    vector<int> cnts(128, 0);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        cnts[s[0]] += 1;
    }

    string S = "MARCH";
    int m = S.length();
    long long res = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = i + 1; j < m; ++j) {
            for (int k = j + 1; k < m; ++k) {
                long long cnt = cnts[S[i]] * 1LL * cnts[S[j]] * 1LL * cnts[S[k]];
                res += cnt;
            }
        }
    }

    cout << res << '\n';

    return 0;
}

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

int main(){

  int d;
  cin>>d;
  
  if (d==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  
  else if (d==23){
        cout<<"Christmas Eve Eve"<<endl;
  }
  
  else if (d==24){
        cout<<"Christmas Eve"<<endl;
  }
  
  else if (d==25){
       cout<<"Christmas"<<endl;
  }
  
 
  
}
  













Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int main(){
	ll x,y;
	cin>>x>>y;
	ll ans=1;
	while(2*x<=y){
		x *=2;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.awt.geom.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main{
    public static void main(String[] args){

    int N = 1001;
    Scanner sch = new Scanner(System.in);
    int i,k,l,m[][]=new int[N+1][N+1],p[]=new int[N+1];
    int[] c = new int[201];
    int n = sch.nextInt();
    
    for( i = 1; i <= n; i++){
        p[i-1] = sch.nextInt();
        p[i] = sch.nextInt();
        m[i][i]=0;
    }
    
    
    for( i = 2; i <= n; ++i) {
        for(int j = 1; j <= n - i + 1; j++){
        k = j + i - 1;
        m[j][k] = Integer.MAX_VALUE;
      
        for( l = j; l <= k - 1; ++l){
            m[j][k] = Math.min(m[j][k],m[j][l] + m[l+1][k] + p[j-1] * p[l] * p[k]);
        }
        }
    }
    System.out.println(m[1][n]);

    }
}


Measured memory_bytes: 30356
result = 0

dice = input().split()

moves = {
    'S' : ((5, 1), (1, 2), (2, 6), (6, 5), (4, 4), (3, 3)),
    'N' : ((1, 5), (2, 1), (6, 2), (5, 6), (4, 4), (3, 3)),
    'E' : ((4, 1), (1, 3), (3, 6), (6, 4), (2, 2), (5, 5)),
    'W' : ((1, 4), (3, 1), (6, 3), (4, 6), (2, 2), (5, 5))
         }

shaked = input()

for s in shaked:
    temp = dice[:]
    for f, t in moves[s]:
        temp[t - 1] = dice[f - 1]
    dice = temp[:]

print(dice[0])


Measured memory_bytes: 5564
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      if 500 * i + 100 * j + 50 * k == x:
        count += 1
        
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

signed main() {
    int a,b;
    cin >> a >> b;

    set<int> sta, stb;
    for(int i = 1; i * i <= a; i++) {
        if(a % i == 0){
            sta.insert(i);
            sta.insert(a/i);
        }
    }

    for(int i = 1; i * i <= b; i++) {
        if(b % i == 0){
            stb.insert(i);
            stb.insert(b/i);
        }
    }

    vector<int> v;
    for(auto it : sta){
        if(stb.count(it)) v.push_back(it);
    }

    int m = v.size();
    sort(v.begin(),v.end());


    set<int> ans;
    for(int i = 0; i < m; i++){
        bool flag = true;
        for(int j = 0; j < i; j++){
            int x = v[i];
            int y = v[j];
            if(y == 1) continue;
            if(x % y == 0) flag = false;
        }
        if(flag) ans.insert(v[i]);
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

void dfs(vector<int> &dp, vector<vector<int>> &graph_f, vector<vector<int>> &graph_b, int v){
    for (int next_v : graph_b[v]){
        dp[next_v] =  max(dp[next_v], dp[v] + 1);
        vector<int> &forward = graph_f[next_v];
        forward.erase(remove(forward.begin(), forward.end(), v), forward.end());
        if (forward.empty()){
            dfs(dp, graph_f, graph_b, next_v);
        }
    }
}

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> graph_f(n);
    vector<vector<int>> graph_b(n);
    rep(i, m){
        int x, y; cin >> x >> y;
        x--; y--;
        graph_f[x].push_back(y);
        graph_b[y].push_back(x);
    }
    vector<int> starts;
    rep(i, n){
        vector<int> outcome = graph_f[i];
        if (outcome.empty()) starts.push_back(i);
    }
    vector<int> dp(n, 0);
    for (int start : starts) dfs(dp, graph_f, graph_b, start);
    int ans = 0;
    rep(i, n) ans = max(ans, dp[i]);
    cout << ans << endl;
}


Measured memory_bytes: 19328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n,0);
    bool j = true;
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--;
         if(n >= 2){
             if(a == 0 && b == 0)j = false;
        }
        if(v[a] == b && j|| v[a] == 0 && j)v[a] = b;
        else{
            cout << "-1" << endl;
            return 0;
        }
    }
    if(n >= 2 && v[0] == 0)v[0]++;
    rep(i, 0, n) cout << v[i];
    cout << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0
for s in range(0, 1000):
    s = str(s).zfill(3)
    i = 0
    for d in s:
        if d in S[i:]:
            i += S[i:].index(d) + 1
        else:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numX = sc.nextInt();
		int numY = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		Integer xs[] = new Integer[numX];
		int ys[] = new int[numY];
		for(int i = 0; i < numX;i ++) {
			xs[i] = sc.nextInt();
		}
		for(int i = 0; i < numY;i ++) {
			ys[i] = sc.nextInt();
		}
		Arrays.sort(xs, Collections.reverseOrder());
		Arrays.sort(ys);
		boolean noConflicts = xs[0] < ys[0];
		if(noConflicts) {
			noConflicts = false;
			for(int z = xs[0] + 1; z <= ys[0]; z ++) {
				if(z > x && z <= y) {
					noConflicts = true;
					break;
				}
			}
		}
		System.out.println(noConflicts ? "No War" : "War");
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll H; cin>>H;
    ll ans=0;
    ll kazu=1;
    while(H>0){
        H/=2;
        ans+=kazu;
        kazu*=2;
    }
    cout<< ans <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int[] a=new int[n];
    int[] wa=new int[n+1];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    for(int i=1;i<=n;i++){
      wa[i]=(wa[i-1]+a[i-1])%m;
    }
    Map<Integer,Integer> mp=new HashMap<>();
    for(int i=0;i<n+1;i++){
      mp.put(wa[i],mp.getOrDefault(wa[i],0)+1);
    }
    long ans=0;
    for(Map.Entry<Integer,Integer> me:mp.entrySet()){
      ans=ans+(1L*me.getValue()*(me.getValue()-1));
    }
    System.out.println(ans/2);
  }
}

Measured memory_bytes: 61872
# D 3424320
S = input()
N = len(S)
center_i = N//2
center = S[center_i]

ans = N//2
l = r = center_i
if N%2==0:
    l -= 1
while l >= 0:
    if not (S[l] == center == S[r]):
        break
    l -= 1
    r += 1
    ans += 1
print(ans)

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

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

    //行ボタンをi回やったのち列をj回やると
    //i * M + (N - i) * j 個が黒になる

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= M; ++j) {
            if (i * M + (N - i) * j  - i * j== K
                    || j * N + (M - j) * i - i * j== K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
H,W = map(int, input().strip().split(' '))
N = input().strip()
A = list(map(int, input().strip().split(' ')))

color = []
for i,c in enumerate(A):
  color.extend([i+1]*c)

board = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H*W):
  x = i//H
  y = i%H if x%2 == 0 else (H-1)-i%H
  board[y][x] = color[i]

for y in range(H):
  print(*board[y])

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 100001;
ll n;
priority_queue <pair< ll , pair<ll,ll> > > Q;

ll par[N];
ll a,ans=0;

void init(int n){
	FOR(i,1,n+1)par[i]=i;
}

int root(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}

void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}
pair<ll,ll> x[N],y[N];


int main(){
	cin>>n;
	init(n);
	FOR(i,0,n){
		cin>>x[i].first>>y[i].first;
		x[i].second=i;
		y[i].second=i;
	}
	sort(x,x+n);
	sort(y,y+n);
	FOR(i,0,n-1){
		Q.push(make_pair(-(abs(x[i].first-x[i+1].first)),make_pair(x[i].second,x[i+1].second)));
		Q.push(make_pair(-(abs(y[i].first-y[i+1].first)),make_pair(y[i].second,y[i+1].second)));
	}
	while(!Q.empty()){
		pair<ll,ll> e;
		ll cost,xx,yy;
		pair<ll,pair<ll,ll> > q;
		q=Q.top();
		e=q.second;
		cost=-q.first;
		xx=e.first;
		yy=e.second;
		Q.pop();
		if(root(xx)==root(yy))continue;
		unite(xx,yy);
		ans+=cost;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12400
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a <= c && c <= b) || (b <= c && c <= a)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,-1,-1,1};
const int dy[4]={1,1,-1,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

map<int, map<int, int>> w;

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

    vector<tuple<int, int, int>> xyw;
    rep(loop, n){
        int x, y, ww; cin >> x >> y >> ww;
        w[x][y] = ww;
        xyw.push_back(make_tuple(x, y, ww));
    }

    int res = 0;
    for(auto & e : xyw){
        int x, y;
        tie(x, y, ignore) = e;

        rep(i, 4){
            vi xs = { x, x + dx[i] };
            vi ys = { y, y + dy[i] };

            int cur = 0;
            for(auto & xx : xs){
                for(auto & yy : ys){
                    cur += w[xx][yy];
                }
            }

            chmax(res, cur);
        }
    }

    cout << res << " / 1" << endl;

    return 0;
}

Measured memory_bytes: 74248
N=1e7,a[10010000];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;scanf("%d",&N),N;printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);exit(0);}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int ans=0;
    int i=n-1;
    while(i>0){
        ans+=a[i--];
        ans-=a[i--];
    }
    if(i==0){
        ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : 
// 			C - Walking Takahashi
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define endl '\n'
#define pb push_back
#define int long long
#define vi vector<int>
#define mii map<int, int>
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a) for(auto x: a) cout<<x<<" "; cout<<endl;
#define pxy(a,n,m) rep(i,0,n) {rep(j,0,m) cout<<a[i][j]<<" "; cout<<endl;}

//--------------------------------------------//

const long long MOD=LLONG_MAX;
void solve()
{
	int x,k,d;
	cin>>x>>k>>d;
	if(x<0) x*=-1;
	if(x==0){
		if(k%2)
		cout<<d<<endl;
		else
		cout<<0<<endl;
	}
	else{
		int y=x%d;
		int k2=(x-y)/d;
		if(k2>=k){
			cout<<x-k*d<<endl;
		}		
		else{
			int ans=y;
			if((k-k2)%2==0)
			{
				if(k-k2) ans=min(ans,abs(y-2*d));
			}
			else{
				ans=y+d;
				ans=min(abs(y+d),abs(y-d));
			}
			
			cout<<ans<<endl;
		}
	}
}
int32_t main()
{	
	std::ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1; 
	//cin>>t;
	while(t--) solve();
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

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

    int k, t;
    cin >> k >> t;

    vector<int> a(t);
    int mx = 0;
    int sum = 0;
    rep(i, t) {
        cin >> a[i];
        mx = max(mx, a[i]);
        sum += a[i];
    }

    sum -= mx;

    ppp(max(0, mx-1-sum));
    return 0;
}


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n,x; cin >> n >> x;
  int res = 0, ans = 0;
  for(int i = 0; i < n; i++){
    int l; cin >> l;
    res = res + l;
    if(res <= x) ans++;
  }
  cout << ans+1 << endl;

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    
    sort(d.begin(), d.end());
    
    int start_D = d[N/2-1];
    int goal_D = d[N/2];
    
    cout << goal_D - start_D << endl;
    
}



Measured memory_bytes: 640
#include <stdio.h>

int main() {
    int k = 0, n = 0;
    double max = 0;
    double sum = 0;
    double pkitai[200001] = {};
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%lf", &pkitai[i]);
        pkitai[i] = (pkitai[i] + 1) / 2;
    }
    for (int i = 0; i < k; i++) {
        sum += pkitai[i];
    }
    max = sum;
    for (int i = 0; i < n - k; i++) {
        sum = sum - pkitai[i] + pkitai[i + k];
        if (max < sum) {
            max = sum;
        }
    }
    printf("%f\n", max);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

typedef long long int lint;

const int NMAX = 100000 + 5;

int N;
lint A[NMAX];
lint APrim[NMAX];
lint mars[2 * NMAX];

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

    cin >> N;
    for (int i = 1; i <= N; ++ i)
        cin >> A[i];

    lint S = 0;
    for (int i = 1; i <= N; ++ i)
        S += A[i];

    lint onePass = N * (N + 1LL) / 2;
    if (S % onePass != 0) {
        cout << "NO\n";
        return 0;
    }

    lint passes = S / onePass;
    APrim[0] = A[N];
    for (int i = 1; i <= N; ++ i)
        APrim[i] = A[i];

    lint sumAPrim = 0;
    for (int i = N; i; -- i) {
        APrim[i] -= APrim[i - 1];
        APrim[i] -= passes;
        APrim[i] *= (-1);

        if (APrim[i] < 0 || APrim[i] % N != 0) {
            cout << "NO\n";
            return 0;
        }
        APrim[i] /= N;
        sumAPrim += APrim[i];
    }

    if (sumAPrim != passes)
        cout << "NO\n";
    else {
        //Build waves generators
        for (int i = 1; i <= N; ++ i) {
            mars[i] += APrim[i];
            mars[i + N] -= APrim[i];
        }
        for (int i = 1; i <= 2 * N; ++ i)
            mars[i] += mars[i - 1];

        //Propagate one -N for every wave, so that it suddenly stops
        for (int i = 1; i <= N; ++ i)
            mars[i + N] -= APrim[i] * N;
        for (int i = 1; i <= 2 * N; ++ i)
            mars[i] += mars[i - 1];

        //Build circularity
        for (int i = 1; i <= N; ++ i)
            mars[i] += mars[i + N];

        //Final check
        for (int i = 1; i <= N; ++ i)
            if (mars[i] != A[i]) {
                cout << "NO\n";
                return 0;
            }
    }

    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int mod = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int N;
ll W, weight[110], value[110],dp[110][100100] = {0};
int main(){
    cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> weight[i] >> value[i];
    }
    for (int i = 0; i < N; i++)
    {
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {
            if(sum_w-weight[i] >= 0){
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]]+value[i]);
            }

            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	string n;
	cin >> n;
	rep(i, 3) {
		if (n[i] == '7') {
			cout << "Yes" <<endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	int n,k,x,y;cin>>n>>k>>x>>y;

	int ans=0;
	if(n<=k){ ans=n*x; }
	if(n>k){ ans=k*x+(n-k)*y; }
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



ll a, b = 100, c = 1;

signed main() {
    cin >> a;
    while (1) {
        b *= 1.01;
        if (a<=b) return cout<<c<<endl, 0;
        c++;
    }
}


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

int main() {
  string T;
  cin >> T;
  for (int i = 0; i < T.size(); i++) {
    if (T.at(i) == '?') {
      T.at(i) = 'D';
    }
  }
  cout << T <<endl;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define m 1000000007
int main()
{
    int n,m;
    int sum=0;
    cin>>n>>m;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        sum+=a;
        v.push_back(4*m*a);
    }
    sort(v.begin(),v.end());
    vector<int>::iterator it=lower_bound(v.begin(),v.end(),sum);
    if(v.end()-it<m)
        cout<<"No"<<"\n";
    else
        cout<<"Yes"<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

typedef long long int lld;
typedef unsigned long long int ulld;
const int mod = 1000000007;

using namespace std;
int m, n, x;

int c[16];
int a[16][16];
int re = 0x7FFFFFFF;

int Check(int state) {
	int co = 0;
	int levels[16];
	memset(levels, 0, sizeof(levels));
	for (int i = 0; i < n; i++) {
		if ((1 << i) & state) { // bingo
			co += c[i];
			for (int j = 0; j < m; j++) {
				levels[j] += a[i][j];
			}
		}
	}
	for (int i = 0; i < m; i++) {
		if (levels[i] < x)
			return -1;
	}
	return co;
}

int main(void) {
	ios::sync_with_stdio(false);
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int end = 1 << n;
	for (int i = 0; i <= end; i++) {
		int c = Check(i);
		if (c >= 0 && c < re) {
			re = c;
		}
	}
	if (re == 0x7FFFFFFF) {
		cout << "-1" << endl;
	} else {
		cout << re << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
  int n=kbd.nextInt();
  int m=kbd.nextInt();

  int x;
  if(n==0){
    x=(m*(m-1))/2;
  }else if(m==0){
    x=(n*(n-1))/2;
  }else{
  x=(n*(n-1))/2+(m*(m-1))/2;
}
  System.out.println(x);
}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>

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

const int MAX_M = 5;


int main() {

    int N, M;

    cin >> N >> M;
    
    vector<P> p(M);

    for (int i = 0; i < M; i++) {
        cin >> p[i].first >> p[i].second;
    }

    for (int x = 0; x < 1000; x++) {
        int digit = 1;
        int nx = x / 10;
        vector<int> pop(1, x % 10);
        while (nx != 0) {
            digit++;
            pop.push_back(nx % 10);
            nx /= 10;
        }
        if (digit != N) continue;
        bool ok = true;
        reverse(pop.begin(), pop.end());
        for (int i = 0; i < M; i++) {
            if (pop[p[i].first - 1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    
    return 0;

}

Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    char X, Y;
    scanf("%c %c", &X, &Y);
    ll x=X-'A', y=Y-'A';
    if(x==y) printf("=\n");
    else if(x>y) printf(">\n");
    else printf("<\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128