akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

struct BIT {
  int n;
  vector<int> xs;
  BIT (int n) : n(n) {
    xs.resize(n+1, INF);
  }
  void update(int i, int v) {
    for (int x=i+1; x<=n; x+=x&-x) xs[x] = min(xs[x], v);
  }
  int query(int i) {
    int s = 0;
    for (int x=i+1; x>0; x-=x&-x) s = min(s, xs[x]);
    return s;
  }
};

int N;
int A[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;

  rep(i, N) cin >> A[i];
  long long c = 0;
  int b = 1;
  rep(i, N) {
    int t = (A[i]-1)/b;
    c += t;
    if (t > 0) A[i] = 1;
    b = max(b, A[i]+1);
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 768
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
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;}
 
const ll INF=1e9+7;

vector<vector<ll>> G;

ll dp[100100];

vector<ll> used;
ll dfs(ll v){
    ll res=0;
    for(auto x:G[v]){
        if(dp[x]!=-1){
            res=max(res,dp[x]+1);
        }
        else{
            res=max(res,dfs(x)+1);
        }
    }
    return dp[v]=res;
}

int main(){
    ll n,m;
    cin >> n >> m;
    G.resize(n);
    used.resize(n);
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
    }
    ll ans=0;
    rep(i,100100){
        dp[i]=-1;
    }
    rep(i,n){
        ans=max(ans,dfs(i));
    }
    cout << ans <<endl;
    return 0;
} 

Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int a[105],sum=0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	int r = sum % (4 * m);
	int lm;
	if (r > 0) lm = sum / (4 * m) + 1;
	else lm = sum / (4 * m);
	bool ok = false;
	int cnt = 0;
	rep(i, n) {
		if (a[i] >= lm)cnt++;
		if (cnt == m) {
			ok = true;
			break;
		}
	}
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int n;
    int cnt[5] = {};
    long long int ans = 0;
    cin >> n;

    string s[n];

    for (int i = 0; i < n; i++) {
        cin >> s[i];
        if (s[i][0] == 'M') {
            cnt[0]++;
        }
        if (s[i][0] == 'A') {
            cnt[1]++;
        }
        if (s[i][0] == 'R') {
            cnt[2]++;
        }
        if (s[i][0] == 'C') {
            cnt[3]++;
        }
        if (s[i][0] == 'H') {
            cnt[4]++;
        }
    }

    for (int bit = 0; bit < (1<<5); bit++) {
        vector<int> v;

        for (int i = 0; i < 5; i++) {
            if (bit & (1<<i)) {
                v.push_back(i);
            }
        }
        if (v.size() == 3) {
            long long int tmp = 1;
            for (auto x: v) {
                tmp *= cnt[x];
            }
            ans += tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6144
#!/usr/bin/env ruby
h , w = STDIN.readline().split(' ').map(&:to_i)
ss = []
ss << '.' * (w + 2)
h.times.each {|i| ss << ('.' + STDIN.readline().strip + '.').split('') }
ss << '.' * (w + 2)
def sum(a)
  a.inject(0){|sum, i| sum += i }
end
def count_bombs(ss, h, w)
  ns = []
  for y in (1..h) do
    n = ''
    for x in (1..w) do
      n += ss[y][x] == '#' ? '#' : count(x, y, ss).to_s
    end
    ns << n
  end
  ns
end
def print_bomb_nums(ns, w)
  ns.each{|n| puts n}
end
def b(x, y, ss)
  ss[y][x] == '#' ? 1 : 0
end
def count(x, y, ss)
  sum([b(x-1, y-1, ss), b(x, y-1, ss), b(x+1, y-1, ss),
       b(x-1, y, ss), b(x, y, ss), b(x+1, y, ss),
       b(x-1, y+1, ss), b(x, y+1, ss), b(x+1, y+1, ss)])
end
print_bomb_nums(count_bombs(ss, h, w), w)


Measured memory_bytes: 2172
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int i,p,l[4]={5,7,5,6};
	string s,d[4]={"dream","dreamer","erase","eraser"};
	bool flag,ans = true;
	cin >> s;
	p = s.length();
	while(p > 0){
		flag = true;
		for(i=0; i<4; ++i){
			if(l[i] > p){
				continue;
			}
			if(s.substr(p-l[i],l[i]) == d[i]){
				p -= l[i];
				flag = false;
				break;
			}
		}
		if(flag){
			ans = false;
			break;
		}
	}
	cout << ((ans)?"YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
#define Maxn 1005
bool f[Maxn];
int pre[Maxn];
char ch[Maxn][Maxn];
char c3[10][10]={
	{'a','a','.'},
	{'.','.','a'},
	{'.','.','a'} 
};
char c4[10][10]={
    {'a','a','b','c'},
    {'d','d','b','c'},
    {'b','c','a','a'},
    {'b','c','d','d'}
};
char c5[10][10]={
    {'a','a','b','b','a'},
    {'b','c','c','.','a'},
    {'b','.','.','c','b'},
    {'a','.','.','c','b'},
    {'a','b','b','a','a'}
};
char c7[10][10]={
    {'a','a','b','b','c','c','.'},
    {'d','d','.','d','d','.','a'},
    {'.','.','d','.','.','d','a'},
	{'.','.','d','.','.','d','b'},
	{'d','d','.','d','d','.','b'},
	{'.','.','d','.','.','d','c'},
	{'.','.','d','.','.','d','c'} 
};


inline void output(){
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j)printf("%c",ch[i][j]);
		puts("");
	}
}

int main(){
	scanf("%d",&n);
	f[0]=true;
	for(int i=1;i<=n;++i){
		if(i>=4&&f[i-4]){
			f[i]=true;
			pre[i]=4;
		}
		if(i>=5&&f[i-5]){
			f[i]=true;
			pre[i]=5;
		}
		if(i>=7&&f[i-7]){
			f[i]=true;
			pre[i]=7;
		}
	}
	for(int i=1;i<=n;++i)
	    for(int j=1;j<=n;++j)ch[i][j]='.';
	if(n%3==0){
		for(int i=1;i<=n;i+=3)
		    for(int j=0;j<3;++j)
		        for(int k=0;k<3;++k)
		            ch[i+j][i+k]=c3[j][k];
		output();
	}else if(f[n]){
		int tmp=n;
		while(n){
			if(pre[n]==4){
				for(int i=n-3;i<=n;++i)
				    for(int j=n-3;j<=n;++j)
				         ch[i][j]=c4[i-n+3][j-n+3];
			}
			if(pre[n]==5){
				for(int i=n-4;i<=n;++i)
				    for(int j=n-4;j<=n;++j)
				        ch[i][j]=c5[i-n+4][j-n+4];
			}
			if(pre[n]==7){
				for(int i=n-6;i<=n;++i)
				   for(int j=n-6;j<=n;++j)
				        ch[i][j]=c7[i-n+6][j-n+6];
			}
			n-=pre[n];
		}
		n=tmp;
		output(); 
	}else puts("-1");
	return 0;
}

Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define ll long long 
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi <vector<vector<vector<int>>> 
#define vc vector<char> 
#define vvc vector<vector<char>>
#define vvvc vector<vector<vector<char>>> 
#define INF 2000000000

using namespace std;

int main() {
	while (1) {
		string s, t;
		vector<string> ss;
		vector<string> tt;
		int starts=0, startt = 0;
		getline(cin, s);
		if (s == ".")break;
		getline(cin, t);

		if (s == t) cout << "IDENTICAL" << endl;
		else {
			for (int i = 0; i < s.length(); i++) {
				if (s[i] == '"') {
					ss.push_back(s.substr(starts, i - starts));
					starts = i + 1;
				}
				if (i == s.length() - 1) ss.push_back(s.substr(starts, s.length()-1 - starts ));
			}

			for (int i = 0; i < t.length(); i++) {
				if (t[i] == '"') {
					tt.push_back(t.substr(startt, i - startt));
					startt = i + 1;
				}
				if (i == t.length() - 1) tt.push_back(t.substr(startt, t.length() - 1 - startt ));
			}

			int count = 0;
			for (int i = 0; i < ss.size(); i++) {
				if (ss[i] != tt[i]) {
					if (i % 2 == 0) {
						cout << "DIFFERENT" << endl;
						goto AWAY;
					}
					else count++;
				}
			}
			if (count == 1) cout << "CLOSE" << endl;
			else cout << "DIFFERENT" << endl;
		}
	AWAY:;
	}

	return 0;
}

Measured memory_bytes: 3180
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 15;
int e[N];
int cnt[N][1 << N];
int dp[1 << N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    e[x] |= 1 << y;
  }
  for (int i = 0; i < n; ++i) {
    for (int k = 0; k < (1 << n); ++k) {
      if (k & (1 << i)) continue;
      cnt[i][k] = __builtin_popcount(e[i] & k);
    }
  }
  dp[0] = 1;
  for (int S = 1; S < (1 << n); ++S) {
    for (int T = S; T; T = (T - 1) & S) {
      int U = S ^ T;
      if (((T & 1) == 1 && (U & 2) == 2) ||
          ((U & 1) == 1 && (T & 2) == 2)) continue;
      int cur = dp[U];
      for (int i = 0; i < n; ++i) {
        if (T & (1 << i)) {
          cur = (int64)cur * (1 << cnt[i][U]) % MOD;
        } else if (U & (1 << i)) {
          cur = (int64)cur * ((1 << cnt[i][T]) - 1) % MOD;
        }
      }
      dp[S] = (dp[S] + cur) % MOD;
    }
  }
  int ret = 1;
  while (m--) ret = ret * 2LL % MOD;
  ret = (ret + MOD - dp[(1 << n) - 1]) % MOD;
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 2048
package main

import "fmt"

var (
	N, A, B, C int
	l          []int
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func dfs(i, a, b, c int) int {
	if i == N {
		if min(min(a, b), c) == 0 {
			return 1000000000
		}
		return abs(a-A) + abs(b-B) + abs(c-C) - 30
	}
	v1 := dfs(i+1, a, b, c)
	v2 := dfs(i+1, a+l[i], b, c) + 10
	v3 := dfs(i+1, a, b+l[i], c) + 10
	v4 := dfs(i+1, a, b, c+l[i]) + 10
	return min(min(min(v1, v2), v3), v4)
}

func main() {
	fmt.Scan(&N, &A, &B, &C)
	l = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&l[i])
	}
	ans := dfs(0, 0, 0, 0)
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n,check=0;
	string con = { "" };
	cin >> n;
	vector<char>s(n);
	for (int i = 0; i < n; i++)cin >> s[i], con += s[i];
	if (con.find("P") != string::npos)check += 1;
	if (con.find("W") != string::npos)check += 1;
	if (con.find("G") != string::npos)check += 1;
	if (con.find("Y") != string::npos)check += 1;
	cout << (check == 3 ? "Three" : "Four") << endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    string s;
    bool exists[26] = {};
    
    cin >> s;
    for(int i = 0; i < s.size(); i++)
        exists[s[i]-'a'] = true;

    for(int i = 0; i < 26; i++)
        if(exists[i] == false){
            cout << (char)('a' + i) << endl;
            return 0;
        }
        
    cout << "None" << endl;
    
    return 0;
}

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

using namespace std;

int main(){
    map<string, int> votes;
    int n;
    cin>>n;
    string s;
    for (int i=0; i<n; i++){
        cin>>s;
        if (votes.find(s)==votes.end()){
            votes.insert(make_pair(s, 1));
        }   
        else {
            votes.find(s)->second ++;
        }
    }
    
    int max_value = 0;
    map<string, int>::iterator itr;
    for (itr=votes.begin(); itr!=votes.end(); itr++){
        if (itr->second>max_value){
            max_value = itr->second;
        }
    }
    
    for (itr=votes.begin(); itr!=votes.end(); itr++){
        if (itr->second==max_value)
        cout<<itr->first<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 25216
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    ll a;
    cin >> a;
    string b;
    cin >> b;
    ll b1 = b[0]-'0';
    ll b2 = stoi(b.substr(2, 2));
    ll bb = b1*100+b2;
    cout << a*bb/100 << endl;

    
    return 0;
}

Measured memory_bytes: 3192
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            List<int> a = new List<int>();
            string str;
            str = Console.ReadLine();
            for (int i = 0;i < 3 ; i++)
            {
                a.Add(int.Parse(str.Split(' ')[i]));
            }
            a.Sort();
            Console.WriteLine(a[0] + " " + a[1] + " " + a[2] );
        }
    }
}

Measured memory_bytes: 9224
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include <unordered_map>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000009
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 111531;

int n, x;
int cost[N];
long long S, ans;
int new_cost[N];

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n >> x;
	for (int i = 0; i < n; i++)
	{
		cin >> cost[i];
	}

	ans = 1e18;

	for (int iter = 0; iter <= n; iter++)
	{
		S = 0;
		for (int i = 0; i < n; i++)
		{
			S += cost[i];
		}
		ans = min(ans, S + 1ll*iter*x);
		for (int i = 0; i < n; i++)
		{
			new_cost[i] = min(cost[i], cost[(i + n - 1) % n]);
		}
		for (int i = 0; i < n; i++)
		{
			cost[i] = new_cost[i];
		}
	}

	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    double x[3], y[3];
    REP(i, 3) cin >> x[i] >> y[i];
    double z[3];
    REP(i, 3){
    	z[i] = sqrt((x[i] - x[(i+1)%3]) * (x[i] - x[(i+1)%3]) + (y[i] - y[(i+1)%3]) * (y[i] - y[(i+1)%3]));
    }
    double S = abs((x[1]-x[0]) * (y[2]-y[0]) +-(x[2]-x[0]) * (y[1]-y[0]))/2;
    double r = 2.0*S/(z[0]+z[1]+z[2]);

    double zz = -1;
    REP(i, 3) zz = max(zz, z[i]);
 	dump(r)

    double lb = 0.0;
    double ub = r;
    double eps = 1e-10;
    while(ub-lb>eps){
    	double m = (lb+ub)/2.0;
    	//dump(m)
    	if((1.0-m/r) * zz >= 2*m) lb = m;
    	else ub = m; 
    }
    printf("%.10f\n", ub);
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))

accSum = list(accumulate(A))
ans = float('inf')
for m in range(1, N):
    # 左
    Lm = accSum[m] // 2
    Lx = bisect_left(accSum, Lm)
    if abs(accSum[Lx] - Lm) > abs(accSum[Lx - 1] - Lm):
        Lx -= 1

    # 右
    Rm = (accSum[m] + accSum[-1]) // 2
    Rx = bisect_left(accSum, Rm)
    if abs(accSum[Rx] - Rm) > abs(accSum[Rx - 1] - Rm):
        Rx -= 1

    P, Q, R, S = accSum[Lx], accSum[m] - accSum[Lx], accSum[Rx] - accSum[m], accSum[-1] - accSum[Rx]
    ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))

print(ans)


Measured memory_bytes: 24296
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        int[] a = new int[N];
        for(int i=0; i<N; i++){
            a[i] = nextInt();
        }

        int n = 1;
        int count = 0;
        for(int i=0; i<N; i++){
            if(a[i] != n){
                count++;
            }else{
                n++;
            }
        }

        if(a[0] != 1 && (count == 0 || count == N)){
            println(-1);
        }else{
            println(count);
        }
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


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

int main(){
    int n;
    cin>>n;
    long long a[n+1]={};
    int xo[n+1]={};
    
    for(int i=1;i<=n;i++){
        cin>>a[i];
        xo[i]=xo[i-1]^a[i];
        a[i]+=a[i-1];
    }

    long long ans=0;
    long long l=1;


    for(int r=1;r<=n;r++){
        for( ; (a[r]-a[l-1])!=(xo[r]^xo[l-1]) ; l++);
        ans+=r-l+1;
        cerr<<r<<" "<<l<<" "<<ans<<endl;
    }
    
    cout<<ans<<endl;


}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

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

		while (true) {
			int m = sc.nextInt();
			int nmin = sc.nextInt();
			int nmax = sc.nextInt();
			if (m == 0 && nmin == 0 && nmax == 0)
				break;

			int[] hito = new int[m];

			int i;
			for (i = 0; i < m; i++) {
				hito[i] = sc.nextInt();
			}

			int count = 0, check = 0, pass = 0;
			for (i = nmin - 1; i < nmax; i++) {
				count = hito[i] - hito[i + 1];
				if (count >= check) {
					check = count;
					pass = i + 1;
				}
			}
			System.out.println(pass);
		}

		sc.close();
	}
}



Measured memory_bytes: 57240
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,M = map(int, input().split())
A = list(map(int, input().split()))

Asum = [0]
for a in A:
    Asum.append(Asum[-1]+a)

for i in range(N+1):
    Asum[i] %= M
Asum.sort()

ans = 0
for c in Counter(Asum).values():
    ans += c*(c-1)//2

print(ans)

Measured memory_bytes: 26280
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
int dp[105][4][4][4];
signed main(){
	int n;
	cin>>n;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				dp[3][i][j][k] = 1;
				if( i==0 && j==1 && k==2)dp[3][i][j][k] = 0;
				if( i==1 && j==0 && k==2)dp[3][i][j][k] = 0;
				if( i==0 && j==2 && k==1)dp[3][i][j][k] = 0;
			}
		}
	}
	for(int p = 4; p<=n; p++){
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				for(int k=0;k<4;k++){
					dp[p][j][k][0] += dp[p-1][i][j][k];
					dp[p][j][k][0] %= inf;
				}
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				for(int k=0;k<4;k++){
					if( !(i==0 && j ==1) && !(j==0 && k==1) && !(i==0 && k==1) && !(k==0&&j==1) ){
						dp[p][j][k][2] += dp[p-1][i][j][k];
						dp[p][j][k][2] %= inf;
					}
				}
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				for(int k=0;k<4;k++){
					if( !(j==0 && k==2)){
						dp[p][j][k][1] += dp[p-1][i][j][k];
						dp[p][j][k][1] %= inf;
					}
				}
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				for(int k=0;k<4;k++){
					dp[p][j][k][3] += dp[p-1][i][j][k];
					dp[p][j][k][3] %= inf;
				}
			}
		}
	}
	ll ans = 0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				ans += dp[n][i][j][k];
				ans %= inf;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());

        int ans = 0;
        for (int b = 1; b < 1000; b++)
        {
            for(int p = 2; p <= 10; p++)
            {
                int x = (int) Math.Pow(b, p);
                if (x > n){ break; }
                ans = Math.Max(ans, x);
            }
        }

        WriteLine(ans);
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = 1050000000;
constexpr auto MOD = 1000000007;

int main() {
	int h, w;
	cin >> h >> w;
	vs s(h);
	rep(i, h)cin >> s[i];

	int dark = 0;
	
	queue<P> q;
	vvi turn(h, vi(w, INF));

	rep(i, h)rep(j, w) if (s[i][j] == '#') {
		dark++;
		q.push(make_pair(i, j));
		turn[i][j] = 0;
	}

	while (!q.empty()) {

		int y = q.front().first;
		int x = q.front().second;
		q.pop();

		rep(i, 4) {
			int ey = y + dy[i];
			int ex = x + dx[i];
			if (ey < 0 || h <= ey || ex < 0 || w <= ex) continue;
			if (turn[ey][ex] != INF)continue;
			turn[ey][ex] = turn[y][x] + 1;
			q.push(make_pair(ey, ex));
		}
	}

	int ans = 0;

	rep(i, h)rep(j, w) ans = max(ans, turn[i][j]);

	cout << ans << endl;
}

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

int main()
{
    long long  a=0,i,j,n,t,b,c;
    string s,s1,s2;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
       a+=s[i]-'0';
    }
   // cout<<a;
    if(a%9==0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";

    return 0;
}


Measured memory_bytes: 3720
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let line = readInts()
    let k = line[1]
    let ps = readInts().sorted(by: <)
    
    var ans = 0
    for i in 0..<k {
        ans += ps[i]
    }
    
    print(ans)
}

main()


Measured memory_bytes: 8420
N = gets.to_i
limit = nil
(0...N).map{ gets.split.map &:to_i }.sort_by{ |a,b| [b,a] }.reverse_each{ |a,b|
  limit ||= b
  limit = [limit, b].min
  limit -= a
  if limit < 0
    puts "No"; exit
  end
}

puts "Yes"


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

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

  int temp = N%10;

  switch ( temp ) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout <<"hon" <<endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout <<"pon" <<endl;
      break;
    case 3:
      cout <<"bon" <<endl;
      break;
    default:
      break;
  }
}


Measured memory_bytes: 3592
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=19961993;
const long long LMOD=1000000007;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Beg begin
vector<Pii>v[100001];
int col[100001];
int f[100001];
int ypa(int k,int p=0)
{
	//cout<<k<<endl;
	int g=0;
	for(int i=0;i<v[k].Sz();i++)
	{
		if(v[k][i].Fi==p)continue;
		if(f[k]==++g)++g;
		f[v[k][i].Fi]=g;
		col[v[k][i].Se]=g;
		ypa(v[k][i].Fi,k);
	}
	return 0;
}
int main()
{
	int n;
	Sf("%d",&n);
	int x,y;
	for(int i=1;i<n;i++)
	{
		Sf("%d%d",&x,&y);
		v[x].Pb(Cb(y,i));
		v[y].Pb(Cb(x,i));
	}
	int mx=0;
	for(int i=1;i<=n;i++)
	{
		mx=max(mx,(int)(v[i].Sz()));
	}
	ypa(1);
	Pf("%d\n",mx);
	for(int i=1;i<n;i++)
	{
		Pf("%d\n",col[i]);
	}
	return 0;
}

Measured memory_bytes: 9472
import java.util.Scanner;
class Main{
	static Scanner sc;
	static int n,small,big;
	public static void main(String[]args){
		sc=new Scanner(System.in);
		while(sc.hasNext()){
			small=-1;
			big=-1;
			n=sc.nextInt();
			for(int j=n-1;j>1;j--){
				for(int i=j-1;i>1;i--){
					if(j%i==0){break;}
					if(i==2){small=j;}
				}
				if(small!=-1){break;}
			}
			int j=n;
			while(true){
				j++;
				for(int i=j-1;i>1;i--){
					if(j%i==0){break;}
					if(i==2){big=j;}
				}
				if(big!=-1){break;}
			}
			if(small==-1){small=2;}
			System.out.println(small+" "+big);
		}
	}
}

Measured memory_bytes: 19728
#include <bits/stdc++.h>
using namespace std;
signed main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  long long x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    long long cnt=x/d;
    if(cnt>=k)cout<<x-k*d<<endl;
    else {
      long long ans=x%d;
      k-=cnt;
      if(k%2)cout<<d-ans<<endl;
      else cout<<ans<<endl;
    }
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(){
	int a,b;
	int i,j;
	for(;;){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				printf("#");
			}
			puts("");
		}
		puts("");
	}
	return 0;
}



Measured memory_bytes: 2064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	int x,y,w,id;
}a[500001],b[500001];
int n,m,ans,fa[500001];
bool cmp(aaa a,aaa b){
	return a.x<b.x;
}
bool cmp1(aaa a,aaa b){
	return a.y<b.y;
}
void build(int x,int y,int w){
	/*tot++;
	e[tot]=y;val[tot]=w;
	nt[tot]=hd[x];hd[x]=tot;*/
	b[++m].x=x;b[m].y=y;b[m].w=w;
}
bool cmp2(aaa a,aaa b){
	return a.w<b.w;
}
int find(int x){
	if(x==fa[x])return x;
	return fa[x]=find(fa[x]);
}
int main(){
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	for(i=2;i<=n;i++)build(a[i-1].id,a[i].id,a[i].x-a[i-1].x);
	sort(a+1,a+n+1,cmp1);
	for(i=2;i<=n;i++)build(a[i-1].id,a[i].id,a[i].y-a[i-1].y);
	sort(b+1,b+m+1,cmp2);
	for(i=1;i<=n;i++)fa[i]=i;
	for(i=1;i<=m;i++){
		x=find(b[i].x);y=find(b[i].y);
		if(x!=y)fa[x]=y,ans+=b[i].w;
	}
	printf("%d",ans);
}
/*
最后选择的边一定是x相邻的或者y相邻的（不相邻替换成若干条相邻的更优） 
*/

Measured memory_bytes: 8960
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	m := sc.ReadInt()
	q := sc.ReadInt()
	abcds := make([]ABCD, q)
	for i := 0; i < q; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		c := sc.ReadInt()
		d := sc.ReadInt()
		abcds[i] = ABCD{a, b, c, d}
	}

	var nextSeqA func() (bool, []int)
	{
		cur := make([]int, n)
		for i := 0; i < n-1; i++ {
			// the last is 0
			cur[i] = 1
		}
		nextSeqA = func() (bool, []int) {
			carryDigitCount := 0
			for i := n - 1; i >= 0; i-- {
				if cur[i] == m {
					carryDigitCount++
				} else {
					break
				}
			}

			if carryDigitCount == 0 {
				cur[n-1]++
				return true, cur
			} else if carryDigitCount == n {
				return false, nil
			} else {
				min := cur[n-1-carryDigitCount] + 1
				for i := 0; i <= carryDigitCount; i++ {
					cur[n-1-i] = min
				}
				return true, cur
			}
		}
	}

	maxScore := 0
	for {
		ok, seqA := nextSeqA()
		if !ok {
			break
		}

		score := computeScore(abcds, seqA)
		if score > maxScore {
			maxScore = score
		}
	}

	fmt.Println(maxScore)
}

func computeScore(abcds []ABCD, seqA SeqA) int {
	totalD := 0
	for _, abcd := range abcds {
		if seqA[abcd.B-1]-seqA[abcd.A-1] == abcd.C {
			totalD += abcd.D
		}
	}
	return totalD
}

type SeqA []int

type ABCD struct {
	A int
	B int
	C int
	D int
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[][] a = new int[n][3];
        for (int i = 0; i < n; i++) {
            a[i][0] = Integer.parseInt(sc.next());
            a[i][1] = Integer.parseInt(sc.next());
            a[i][2] = Integer.parseInt(sc.next());
        }
        int x = 0;
        int y = 0;
        int t = 0;
        for (int i = 0; i < n; i++) {
            int xy = Math.abs(x - a[i][1]) + Math.abs(y - a[i][2]);
            x = a[i][1];
            y = a[i][2];
            int tt = a[i][0] - t;
            t = a[i][0];
            if (xy > tt) {
                System.out.println("No");
                return;
            } else if ((xy % 2 == 0 && tt % 2 != 0) || (xy % 2 != 0 && tt % 2 == 0)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 63712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define N 405
ll inf = 1e14;
ll mod = 1e9 + 7;
char en = '\n';

ll abs1(ll x) {
  if (x < 0)
    return -x;
  return x;
}
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll dp[N][N];
ll arr[N];
ll pre[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  memset(pre, 0, sizeof(pre));
  memset(dp, 0, sizeof(dp));

  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
    pre[i] = pre[i - 1] + arr[i];
  }

  for (ll len1 = 2; len1 <= n; len1++) {
    for (ll i = 1; i <= n - len1 + 1; i++) {
      ll j = i + len1 - 1;
      dp[i][j] = inf;
      for (ll k = i; k < j; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + pre[j] - pre[i - 1]);
      }
    }
  }

  cout << dp[1][n] << en;
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,m,l;
ll dist[301][301],dp[301][301];
const ll INF=0x3f3f3f3f3f3f3f3f;
int main(){
    cin>>n>>m>>l;
    memset(dist,0x3f,sizeof(dist));
    rep(i,n) dist[i][i]=0;
    int ai,bi,ci;
    rep(i,m){
        cin>>ai>>bi>>ci;
        --ai,--bi;
        dist[ai][bi]=ci;
        dist[bi][ai]=ci;
    }
    rep(k,n)rep(i,n)rep(j,n){
        if(dist[i][k]==INF||dist[k][j]==INF)continue;
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    }
    memset(dp,0x3f,sizeof(dp));
    rep(i,n) dp[i][i]=0;
    rep(i,n)rep(j,n)if(i!=j){
        if(dist[i][j]<=l) dp[i][j]=1;
    }
    rep(k,n)rep(i,n)rep(j,n){
        if(dp[i][k]==INF||dp[k][j]==INF)continue;
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    }
    int q,si,ti;
    cin>>q;
    rep(i,q){
        cin>>si>>ti;
        --si,--ti;
        if(dp[si][ti]!=INF){
            cout<<dp[si][ti]-1<<endl;
        }
        else cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1920
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    if s == "AAA" || s == "BBB" {
        println!("No");
    } else {
        println!("Yes");
    }
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  int fst_a = 0, last_z = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A') {
      fst_a = i;
      break;
    }
  }

  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'Z') {
      last_z = i;
    }
  }

  cout << last_z - fst_a + 1 << '\n';
  return 0;
}

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

char sute[1];
char m[8][8];
int w[12][2]={{-3,0},{-2,0},{-1,0},{3,0},{2,0},{1,0},{0,-3},{0,-2},{0,-1},{0,1},{0,2},{0,3}};
void bomb(int i,int j){
    int ni,nj;
    for (int k=0;k<12;++k) {
        m[i][j]='0';
        ni=i+w[k][0];
        nj=j+w[k][1];
        if (ni>=0 && ni<8 && nj>=0 && nj<8) {
            if (m[ni][nj]=='1') {
                bomb(ni,nj);
            } else {
                m[ni][nj]='0';
            }
        }
    }
    return;
}

int main(){
    int n,cnt=1,x,y;
    scanf("%d",&n);
    for (int i=0;i<n;++i){
        fgets(sute,1,stdin);
        for (int j=0;j<8;++j) {
            scanf("%s",m[j]);
        }
        scanf("%d",&x);
        scanf("%d",&y);
        bomb(y-1,x-1);
        printf("Data %d:\n",cnt);
        cnt++;
        for (int j=0;j<8;++j) {
            for (int k=0;k<8;++k) {
                printf("%c",m[j][k]);
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3180
N, X = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

x = X
count = 0

A.sort.each_with_index do |a, i|
    if i == A.size - 1
        if a == x
            count += 1
        end
    else
        if x >= a
            count += 1
            x -= a
        end
    end
end

puts count

Measured memory_bytes: 1788
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;


class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int X, Y, Z;
        X = cin.nextInt();
        Y = cin.nextInt();
        Z = cin.nextInt();

        Console.WriteLine((X - Z) / (Y + Z));
    }

}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;
 
 
int main(){
    double w,h,x,y; cin >> w >> h >> x >> y;
    double ans=w*h;
    ans=(double)ans/2;
    if(x*2==w && y*2==h) cout << ans << ' ' << 1 << endl;
    else cout << ans << ' ' << 0 << endl;
return 0;
}

Measured memory_bytes: 256
"Zero-Sum Ranges"
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
cum_sum = [A[0]]
for a in A[1:]:
    cum_sum.append(cum_sum[-1]+a)
count = Counter(cum_sum)
ans = 0
for k, v in count.items():
    ans += v * (v-1) // 2
print(ans + count[0])


Measured memory_bytes: 41984
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define x first
#define y second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

void solve()
{
    int n, x, m;
    cin>>n>>x>>m;
    vector<int> r = {x%m};
    bitset<111'111> vst;
    vst[x%m] = 1;
    int st_val = -1;
    for (int i=1;;++i)
    {
        int now = r[i-1]*r[i-1]%m;

        if (vst[now])
        {
            st_val = now;
            break;
        }
        vst[now] = 1;
        r.pb(now);
    }
    int st_idx = -1;
    for(int i=0; i<sz(r);++i)
    {
        if (r[i] == st_val)
        {
            st_idx = i;
            break;
        }
    }
    //
    //debug(st_idx);
    int cyc_sum = 0;
    for(int i=st_idx; i<sz(r);++i)
        cyc_sum = (cyc_sum + r[i]);
    //debug(cyc_sum);
    int len = sz(r) - st_idx;
    //debug(len);
    if (n <= sz(r))
    {
        int ret = 0;
        for(int i=0; i < n; ++i)
            ret = (ret + r[i]);
        cout << ret << '\n';
        return;
    }
    int ans = 0;
    for (int i = 0; i < st_idx; ++i) ans = (ans + r[i]);
    n -= st_idx;
    int n_c =n/len;
    ans = (ans + n_c * cyc_sum);
    n -= n_c * len;
    for (int i = st_idx; i< st_idx + n; ++i)
        ans = (ans + r[i]);
    cout << ans << '\n';
    //
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    // cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << '\n';
        solve();
    }
    return 0;
}


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

int main() {
  long n, m;
  cin >> n >> m;
  long a[m];
  for (long i = 0; i < m; i++) {
    cin >> a[i];
    n -= a[i];
    if (n < 0) {
      cout << -1;
      return 0;
    }
  }
  
  cout << n;
  
  return 0;
}

Measured memory_bytes: 3640
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    for( int i = 0; i <= 10100; i++) {
        if (int(i * 0.08) == A && int(i * 0.10) == B) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
}

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

using ll = long long;
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())

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

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

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0 && Narray[i] % 2 != 0)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#include <algorithm>

#define lli long long int

using namespace std;

lli pref[410], memo[410][410];

lli dp(lli l, lli r) {
	lli mini = 1000000000000000000;
	if (l == r)
		return 0;
	if (memo[l][r] != -1)
		return memo[l][r];
	for (lli j = l; j < r; j++)
		mini = min(mini, dp(l, j) + dp(j + 1, r) + (pref[r] - pref[l - 1]));
	memo[l][r] = mini;
	return mini;
}

int main() {
	lli n, ans;
	scanf("%lld", &n);
	pref[0] = 0;
	for (lli i = 1; i <= n; i++) {
		scanf("%lld", &pref[i]);
		pref[i] += pref[i - 1];
	}
	memset(memo, -1, sizeof memo);
	ans = dp(1, n);
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    int n, t;
    string s;
    pair<pair<string, int>, int> p[110];

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s >> t;
        p[i] = make_pair(make_pair(s, -t), i);
    }

    sort(p, p+n);

    for (int i = 0; i < n; i++) cout << p[i].second+1 << endl;
}

Measured memory_bytes: 3592
local read = io.read
local concat = table.concat
local char = string.char

local h, w = read("n", "n", "l")
local black = string.byte("#")

local a_t = {}
for i = 1, h do
	a_t[i] = read()
end

local del_i_t = {}
for i = 1, h do
	local is_breaked = false
	for j = 1, w do
		if a_t[i]:byte(j) == black then
			is_breaked = true
			break
		end
	end
	if not is_breaked then
		del_i_t[i] = true
	end
end

local del_j_t = {}
for j = 1, w do
	local is_breaked = false
	for i = 1, h do
		if a_t[i]:byte(j) == black then
			is_breaked = true
			break
		end
	end
	if not is_breaked then
		del_j_t[j] = true
	end
end

local copy_a_t = {}
local last_i = 0
for i = 1, h do
	if not del_i_t[i] then
		last_i = last_i + 1
		local last_j = 0
		copy_a_t[last_i] = {}
		for j = 1, w do
			if not del_j_t[j] then
				last_j = last_j + 1
				copy_a_t[last_i][last_j] = a_t[i]:sub(j, j) --char(a_t[i]:byte(j))
			end
		end
	end
end

local out_t = {}
for i = 1, #copy_a_t do
	out_t[i] = concat(copy_a_t[i], "")
end

print(concat(out_t, "\n"))


Measured memory_bytes: 2852
import java.util.Scanner;

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

		Scanner scnr = new Scanner(System.in);
		int k = scnr.nextInt();
		int a = scnr.nextInt();
		int b = scnr.nextInt();

		int counter = 0;

		for (int i = a; i <= b; i++) {
			if(i % k == 0) {
				counter = counter + 1;
			}
		}

		if (counter == 0) {
			System.out.print("NG");
		}
		else if (counter > 0) {
			System.out.print("OK");
		}
	}
}

Measured memory_bytes: 27004
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int a,b,h;
  cin >> a >> b >> h;
  int ans = 0;
  
  ans = (a + b)*h/2;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

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

func nextperm(p []int) bool {
	i := len(p) - 1
	for i > 0 && p[i-1] > p[i] {
		i--
	}
	if i == 0 {
		return false
	}
	i--
	j := len(p) - 1
	for p[j] < p[i] {
		j--
	}
	p[i], p[j] = p[j], p[i]
	i, j = i+1, len(p)-1
	for i < j {
		p[i], p[j] = p[j], p[i]
		i, j = i+1, j-1
	}
	return true
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	a := make([]int, n)
	for i := range a {
		a[i] = i + 1
	}
	// fmt.Println("a", a)
	wtr := bufio.NewWriter(os.Stdout)
	for {
		// fmt.Println(a)
		for i := 0; i < len(a); i++ {
			if i > 0 {
				fmt.Fprint(wtr, " ")
			}
			fmt.Fprint(wtr, a[i])
		}
		fmt.Fprintln(wtr)
		if !nextperm(a) {
			break
		}
	}
	wtr.Flush()
}



Measured memory_bytes: 6308
import java.util.Arrays;
import java.util.Scanner;

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

		if (A % 2 == 0 || B % 2 == 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


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

using namespace std;

typedef long long ll;
const int INF=10e7;
ll lcm(ll a, ll b) { return (a*b)/__gcd(a,b); }

int main() {
    ll A,B,C,D;
    cin >> A >> B >> C >> D;

    // CでもDでも割り切れない個数⇒CかDで割り切れる個数を数えて引く
    ll cnt=0;
    cnt += B/C - (A-1)/C;
    cnt += B/D - (A-1)/D;

    ll l=lcm(C,D);
    cnt -= (B/l - (A-1)/l);

    cout << (B-A+1)-cnt << endl;

    return 0;
}

Measured memory_bytes: 256