akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

int dist(const vector<int> x, const vector<int> y) {
    int sum = 0;
    for (size_t i = 0; i < x.size(); i++) {
        sum += (x.at(i) - y.at(i)) * (x.at(i) - y.at(i));
    }
    return sum;
}

int main() {
    fastIO;
    int n, d;
    cin >> n >> d;
    vector<vector<int>> Pi(n, vector<int>(d));
    rep(i, n) {
        rep(j, d) { cin >> Pi.at(i).at(j); }
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; j++) {
            int x = dist(Pi.at(i), Pi.at(j));
            int isZ = sqrt((double)x) * 10000;
            if (isZ % 10000 == 0)
                cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli N=1e3+5;
vector<pair<pair<lli,lli>,lli>> v;
lli dp[20005];

bool cmp(const pair<pair<lli,lli>,lli> &a,const pair<pair<lli,lli>,lli> &b)
{
    return a.first.first+a.first.second < b.first.first+b.first.second;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,j,ans=0,w,s,va;
    
    for(i=0;i<n;i++) 
    {
        cin>>w>>s>>va;
        v.push_back({{w,s},va});
    }
    sort(v.begin(), v.end(), cmp);
    
    for(i=0;i<n;i++)
    {
        for(j=v[i].first.second;j>=0;j--)
        {
            dp[j+v[i].first.first]=max(dp[j+v[i].first.first], dp[j]+v[i].second);
        }
    }
    
    for(i=0;i<20005;i++) ans=max(ans, dp[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int b[100001];
int main(void){
    long N,i,cnt=0;
    scanf("%ld",&N);
    int a[N];
    for(i=0;i<N;i++) scanf("%d",&a[i]);
    i=0;
    while(1){
        if(i==1){
            printf("%ld\n",cnt);
            return 0;
        }
        if(b[a[i]-1]==1){
            printf("-1");
            return 0;
        }
        else{
            b[a[i]-1]++;
            cnt++;
            i=a[i]-1;
        }
    }
}

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

int main(){
	int sales_sum[10];
	int n;
	int sales;
	
	for(;;){
		for(int i = 0; i < 10; i++){
			sales_sum[i] = 0;
		}
		cin >> n;
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin >> sales;
			sales_sum[sales]++;
		}
		for(int i = 0; i < 10; i++){
			if(sales_sum[i] == 0){
				cout << '-' << endl;
				continue;
			}
			for(int j = 0; j < sales_sum[i]; j++){
				cout << '*';
			}
			cout << endl;
		}
	}
	
	return 0;
}
		
	
	

Measured memory_bytes: 1152
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		Arrays.fill(a, -1);
		int len = 0;
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			int r = len;
			int l = -1;
			while(r-l>1) {
				int mid =(r+l)/2;
				if(a[mid] < b) r = mid;
				else l = mid;
			}
			a[r] = b;
			if(r == len) len++;
		}
		System.out.println(len);
	}
}


Measured memory_bytes: 50532
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
# readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
n, a, b = gets.split.map(&:to_i)

if n <= a + b
  if n <= a
    puts n
  else
    puts a
  end
else
  tmp = n / (a + b)
  if (n - (a + b) * tmp) > a
    puts a * tmp + a
  else
    puts a * tmp + (n - (a + b) * tmp)
  end
end


Measured memory_bytes: 1788
#include<stdio.h>

const int ans[]={0,13,1,2,3,4,5,6,7,8,9,10,11,12};
int A,B;

int main(void){
	scanf("%d%d",&A,&B);
	if(ans[A]>ans[B])
		puts("Alice");
	else if(ans[A]==ans[B])
		puts("Draw");
	else
		puts("Bob");
	return 0;
}

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

int n, m, x, y, colMax;
int a[200005], b[200005];
vector <int> v[200005];
std::map<pair<int, int>, int> H;
bool viz[200005];

void dfs(int node, int col)
{
    viz[node] = true;
    int color = 0;
    for (int j = 0; j < v[node].size(); j++)
        if (!viz[v[node][j]])
        {
            color++;
            if (color == col)
                color++;
            colMax = max(colMax, color);
            int son = v[node][j];
            int n1 = node, n2 = son;
            if (n1 > n2)
                swap(n1, n2);
            H[make_pair(n1, n2)] = color;
            dfs(son, color);
        }
}

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

    for (int i = 1; i < n; i++)
    {
        scanf("%d %d", &x, &y);
        v[x].push_back(y);
        v[y].push_back(x);
        if (x > y)
            swap(x, y);
        H[make_pair(x, y)] = 1;
        a[i] = x;
        b[i] = y;
    }

    colMax = 1;

    dfs(1, 0);

    printf("%d\n", colMax);
    for (int i = 1; i < n; i++)
    {
        x = a[i];
        y = b[i];
        if (x > y)
            swap(x, y);
        printf("%d\n", H.at(make_pair(x, y)));
    }

	return 0;
}


Measured memory_bytes: 19072
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <unordered_map>
using namespace std;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

bool compare_by_b(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<2>(a) != get<2>(b)){
        return get<2>(a) > get<2>(b);
    }
}

bool compare_by_string(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
      	return get<2>(a) > get<2>(b);
    }
}

int check(vector<int> &v, int k, long weight)
{
  int i=0;
  for(int j=0;j<k;j++)
  {
    long tmp = 0;
    while(tmp + v[i] <= weight)
    {
      tmp += v[i];
      i++;
      if(i == v.size()) return v.size();
    }
  }
  return i;
}


long binary_search(vector<int> &v, int k)
{
	long left = 0;
  	long right = v.size() * 10000;
  	long mid;
  	while(right - left > 1)
    {
      	mid = (left + right) / 2;
      	int num = check(v,k,mid);
      	if(num >= v.size()) right = mid;
      	else left = mid;
    }
  	return right;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  	const long div = 1000000007;
	int n, k;
  	cin >> n >> k;
  	int idx = 0;
  	vector<int> w(n);
  	while(cin >> w[idx])
    {
      idx++;
    }
  	cout << binary_search(w, k) << endl;
  	return 0;
}



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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int s = 0;
    rep(i, n) s += a[i];
    int ans = 0;
    rep(i, n)
    {
        if(a[i] * (4 * m) >= s)
        ans++;
    }
    if(ans >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void){

   int a, b;
   cin >> a >> b;

   for (int ans = 0; ans <= 10000;ans++){
      int aa = ans * 8 / 100;
      int bb = ans * 10 / 100;
      if(aa == a && bb == b){
         cout << ans << endl;
         return 0;
      }
   }

   cout << -1 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n); int sum=0;
    rep(i,n){
        cin >> a[i];
        sum^=a[i];
    }
    rep(i,n){
        int tmp=sum^a[i];
        cout<<tmp<<' ';
    }
}

Measured memory_bytes: 4760
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
x1 = y[n // 2 - 1]
x2 = y[n // 2]
for i in range(n):
    if x[i] <= x1:
        print(x2)
    else:
        print(x1)

Measured memory_bytes: 26772
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}

int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n;
    for(i=19;i>=0;--i){
    	if((n>>i)&1)break;
    }
    i--;
    j=1;
    map<pii,set<ll> > mp;
    map<ll,ll> h;
    while(i>=0){
    	// trace(i,j,j+1,1<<i);
    	mp[{j,j+1}].ins(0);

    	mp[{j,j+1}].ins(1<<i);
    	h[i]=j;
    	i--;
    	j++;
    }
    h[-1]=j;
    p=0;
    k=log2(n);
    n-=(ll)pow(2,k);
    p+=(ll)pow(2,k);
    while(n){
    	k=log2(n);
    	t=h[k-1];
    	// trace(n,k,p,t);;
    	mp[{1,t}].ins(p);
    	n-=(ll)pow(2,k);
    	p+=(ll)pow(2,k);
    }
    p=0;
    for(auto x:mp){
    	p+=x.S.sz();
    }
    cout<<j<<" "<<p<<"\n";
    for(auto x:mp){
    	for(auto _x:x.S)cout<<x.F.F<<" "<<x.F.S<<" "<<_x<<"\n";
    }













    

}



Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int N, M;
bool _ac[100010];
int _wa[100010];

signed main()
{
	cin >> N >> M;

	int ac = 0;
	int wa = 0;

	REP(i, M)
	{
		int p;
		string s;
		cin >> p >> s;

		if (s == "AC")
		{
			if (!_ac[p])
			{
				ac++;
				_ac[p] = true;
			}
		}
		else
		{
			if (!_ac[p])
			{
				_wa[p]++;
			}
		}
	}

	for (int i = 1; i <= N; i++)
	{
		if (_ac[i])
		{
			wa += _wa[i];
		}
	}
	cout << ac << " " << wa << endl;
}




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

int main(){
  
  int A,B,C;
  
  cin >> A >> B >> C ;
  
  if(A==5 && B==5 && C==7){
    cout << "YES" << endl;
  }
  
  else if(A==5 && B==7 && C==5){
    cout << "YES" << endl;
  }
  
  else if(A==7 && B==5 && C==5){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
package main

import "fmt"

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

func solve(n, d int) int {
	if n < 6 {
		return n + d
	}
	v1 := 1
	for v1*6 <= n {
		v1 *= 6
	}
	v2 := 1
	for v2*9 <= n {
		v2 *= 9
	}
	return min(solve(n-v1, d+1), solve(n-v2, d+1))
}

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(solve(n, 0))
}


Measured memory_bytes: 512
n,k = map(int,input().split())
cnt = 0
cnt_2 = 0
if k%2==1:
    for i in range(1,n+1):
        if i%k==0:
            cnt += 1
    print(cnt**3)
else:
    for i in range(1,n+1):
        if i%k==0:
            cnt += 1
        elif i%k==k//2:
            cnt_2 += 1
    ans1 = cnt**3
    ans2 = cnt_2**3
    print(ans1+ans2)

Measured memory_bytes: 3060
from collections import defaultdict
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = [0] * n
s[0] = a[0]
for i in range(1, n):
    s[i] = s[i - 1] + a[i]

mod = defaultdict(int)
for i in range(n):
    mod[(s[i] % m)] += 1

num = 0
for i in mod.keys():
    if i == 0:
        num += mod[0]
        num += mod[0] * (mod[0] - 1) // 2
    else:
        num += mod[i] * (mod[i] - 1) // 2

print(num)

Measured memory_bytes: 16796
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int M;
	cin >> M;
	print(48 - M);




	return 0;
}

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

int main() {
  int x[6];
  for (int i=1; i<6; i++) cin>>x[i];
  for (int i=1; i<6; i++) {
    if (x[i] == 0) {
      cout<<i<<endl;
    }
  }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long
lli M=1e9;
 
#define MAXN  10000001 
 
int main()
{
    lli q=1;
    // cin>>q;
    time_t start, end;
    time(&start);
    for(lli tc=1;tc<=q;tc++)
    {
        lli n,k;
        cin>>n>>k;
        lli a[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        lli ans =0;
        for(int i=0;i<k;i++)
        {
            ans+=a[i];
        }
        cout<<ans<<endl;
    }
    
    time(&end);
    // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
    return 0;
}

Measured memory_bytes: 3596
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; double d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    double a, b;
    cin >> a >> b;
    ans += sqrt(a * a + b * b) <= d;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3772
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <array>

std::pair<std::string, std::vector<std::pair<int,int>>> input()
{
    int N,Q;
    std::cin >> N >> Q;
    std::string str;
    str.reserve(N);
    std::cin >> str;
    std::vector<std::pair<int,int>> ranges;
    for(int i = 0; i < Q; ++i) {
        int lhs, rhs;
        std::cin >> lhs >> rhs;
        ranges.push_back(std::make_pair(lhs,rhs));
    }
    return std::make_pair(str, ranges);
}

class ac_accumulator {
  public:
    ac_accumulator(const std::string& source) : accum(source.size(), 0) {
        int accum_num{};
        std::string target{"AC"};
        for(int i = 1; i < source.size(); ++i) {
            if(source[i-1] == target[0] && source[i] == target[1])
                ++accum_num;
            accum[i] = accum_num;
        }
    }
    std::vector<int> data() const { return accum; }
    int count(int lhs, int rhs) const { return accum[rhs] - accum[lhs]; }
  private:
    std::vector<int> accum;
};

int solve(const std::string& str, const std::pair<int,int>& pr)
{
    ac_accumulator acc(str);
    return acc.count(pr.first-1, pr.second-1);
}

int main()
{
    auto in = input();
    ac_accumulator acc(in.first);
    for(const auto& rgpr: in.second)
        std::cout << acc.count(rgpr.first-1, rgpr.second-1) << std::endl;
}


Measured memory_bytes: 2148
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <bitset>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, ans = 0;
		cin >> n;
		if (n <= 0) return 0;
		string s;
		cin >> s;
		vector<LL> counts[3];
		auto count = [&](char c, vector<LL> &v) {
			v.resize(n + 1);
			int cnt = 0;
			for (int i = n - 1; i >= 0; --i) {
				cnt += s[i] == c;
				v[i] = cnt;
			}
			return c;
		};
		count('R', counts[0]);
		count('G', counts[1]);
		count('B', counts[2]);
		for (LL i = 0; i < n - 2; ++i) {
			for (LL j = i + 1; j < n - 1; ++j) {
				int k = -1;
				char c;
				if (s[i] == 'R') {
					if (s[j] == 'G') k = 2, c = 'B';
					if (s[j] == 'B') k = 1, c = 'G';
				}
				if (s[i] == 'G') {
					if (s[j] == 'R') k = 2, c = 'B';
					if (s[j] == 'B') k = 0, c = 'R';
				}
				if (s[i] == 'B') {
					if (s[j] == 'R') k = 1, c = 'G';
					if (s[j] == 'G') k = 0, c = 'R';
				}
				if (k < 0) continue;
				LL cnt = counts[k][j + 1];
				int d = j - i;
				if (j + d < n && s[j + d] == c) {
					--cnt;
				}
				ans += cnt;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	bitset<64> bit(0);
	int q;
	cin >> q;
	Rep(k, q) {
		int n, i;
		cin >> n;
		switch (n) {
		case 0:
			cin >> i;
			cout << bit.test(i) << endl;
			break;
		case 1:
			cin >> i;
			bit.set(i);
			break;
		case 2:
			cin >> i;
			bit.reset(i);
			break;
		case 3:
			cin >> i;
			bit.flip(i);
			break;
		case 4:
			cout << bit.all() << endl;
			break;
		case 5:
			cout << bit.any() << endl;
			break;
		case 6:
			cout << bit.none() << endl;
			break;
		case 7:
			cout << bit.count() << endl;
			break;
		case 8:
			cout << bit.to_ullong() << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3096
T1,T2=map(x->parse(Int,x),split(readline()))
A1,A2=map(x->parse(Int,x),split(readline()))
B1,B2=map(x->parse(Int,x),split(readline()))
X=T1*A1+T2*A2
Y=T1*B1+T2*B2
if X==Y
	println("infinity")
else
	d=(X>Y ? -1 : 1)*(T1*A1-T1*B1)
	D=abs(X-Y)
	if d<0
		println(0)
	elseif d==0
		println(1)
	else
		ans=1
		d-=D
		if d>=0
			ans+=div(d,D)*2+2
			if d%D==0
				ans-=1
			end
		end
		println(ans)
	end
end


Measured memory_bytes: 167424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define mod 1000000007
#define inf 0x3f3f3f3f
#define lowb(x) (x & (-x))
#define lson (id << 1)
#define rson (id << 1 | 1)
#define maxm 
#define maxn 8100 
char a[maxn];
int b[maxn << 1], c[maxn << 1], e[maxn << 1], d[maxn << 1];
int main()
{
	int p, q;
	
	scanf("%s%d%d", a, &p, &q);
	int c1 = 0, c2 = 0, x = 0, fg = 1;
	int n = strlen(a);
	for (int i = 0; i < n; i++) {
		if (a[i] == 'T') {
			if (fg) b[c1++] = x;
			else c[c2++] = x;
			fg = 1 - fg;
			x = 0;
		} else {
			x++;
		}
	}
	if (fg) b[c1++] = x;
	else c[c2++] = x;
	d[8000 + b[0]] = 1;
	for (int i = 1; i < c1; i++) {
		memset(e, 0, sizeof e);
		for (int j = 0; j <= 16000; j++) {
			if (d[j]) e[j - b[i]] = e[j + b[i]] = 1;
		}
		memcpy(d, e, sizeof e);
	}
	if (p + 8000 < 0 || p + 8000 > 16000 || d[p + 8000] == 0) {
		puts("No");
		return 0;
	}
	memset(d, 0, sizeof d);
	d[8000] = 1;
	for (int i = 0; i < c2; i++) {
		memset(e, 0, sizeof e);
		for (int j = 0; j <= 16000; j++) {
			if (d[j]) e[j - c[i]] = e[j + c[i]] = 1;
		}
		memcpy(d, e, sizeof e);
	}
	if (p + 8000 >= 0 && p + 8000 <= 16000 && d[q + 8000]) {
		puts("Yes");
	} else puts("No");
}



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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  int sum_value = 0;
  for (int i = 0; i < N; ++i) {
    cin >> p.at(i);
    sum_value += p.at(i);
  }

  int half_value = *max_element(p.begin(), p.end());

  cout << sum_value - half_value + (half_value / 2) << endl;
  return 0;
}


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

using namespace std;

#define ll long long

const int mxN = 1e5;
int dp[mxN+1], h[mxN];

int main()
{
	int n; 
	cin >> n; 
	for(int i = 1; i <= n; ++i)
		cin >> h[i];
	if(n == 2){
		cout << abs(h[1]-h[2]);
		return 0;
	}
	dp[2] = abs(h[1]-h[2]);
	for(int i = 3; i <= n; ++i){
		dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]), dp[i-2] +abs(h[i-2]-h[i]));
	}
	cout << dp[n];
	return 0;
}


Measured memory_bytes: 4280
### constant

BLOCK = [[4, 2], [2, 4]]
NBRS = [[1, 0], [0, 1], [-1, 0], [0, -1]]

### main

while true
  w, h = gets.strip.split(' ').map{|s| s.to_i}
  break if w == 0 && h == 0

  bds = h.times.map{[0] * w}
  visited = h.times.map{[false] * w}

  xs, ys = gets.strip.split(' ').map{|s| s.to_i}
  xs -= 1
  ys -= 1

  xg, yg = gets.strip.split(' ').map{|s| s.to_i}
  xg -= 1
  yg -= 1

  n = gets.strip.to_i

  n.times.each do
    c, d, x, y = gets.strip.split(' ').map{|s| s.to_i}
    x -= 1
    y -= 1

    for dy in (0...BLOCK[d][1])
      for dx in (0...BLOCK[d][0])
        bds[y + dy][x + dx] = c
      end
    end
  end

  cs = bds[ys][xs]
  visited[ys][xs] = true
  q = [[xs, ys]]

  reached = false

  while ! q.empty?
    x, y = q.shift
    if x == xg && y == yg
      reached = true
      break
    end

    for nb in NBRS
      xn = x + nb[0]
      yn = y + nb[1]

      if xn >= 0 && xn < w && yn >= 0 && yn < h &&
          ! visited[yn][xn] && bds[yn][xn] == cs
        q << [xn, yn]
        visited[yn][xn] = true
      end
    end
  end

  puts (reached ? "OK" : "NG")
end

Measured memory_bytes: 6688
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

n,m,k = myinput()
mod = 998244353

comb = Combination(n,mod)

ans = 0
for i in range(k+1):
    t = comb(n-1,i)
    ans1 = pow(m-1,n-1-i,mod)
    ans += ( m * t * ans1 ) % mod
print(ans%mod)

Measured memory_bytes: 101556
n,*a=map(int,open(0).read().split())
x=s=l=c=0
for r,b in enumerate(a):
  x^=b
  s+=b
  while x<s:
    x^=a[l]
    s-=a[l]
    l+=1
  c+=r-l+1
print(c)

Measured memory_bytes: 24796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int main() {
	int n, in;
	cin >> n;
	int tw = 0, fo = 0;
	rep(i, n) {
		cin >> in;
		if (in % 4 == 0)fo++;
		else if (in % 2 == 0)tw++;
	}
	cout << ((n-1 <= fo * 2 + max(0,tw-1)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
typedef unsigned long long ULL;

int main() {
	int a, b;
	std::cin >> a >> b;

	if (b%a == 0) {
		std::cout << a + b << std::endl;
	}
	else {
		std::cout << b - a << std::endl;
	}
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0,i;
    string s;
    cin>>n>>s;
    for(i=0;i<n-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int A = 0;
    int B = 0;
    int C = 0;
    int ans = 0;
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d %d %d", &A, &B, &C);
    
    /* 入力を受け付ける部分終わり*/
    
    
    /* 何か処理*/
    ans = A + B + C;
    
    if(ans >= 22){
      /* 真の場合の処理 */
      printf("bust");
    }else{
      /* 偽の場合の処理 */
      printf("win");
    }
    
    for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    }
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
    // printf("%d", ans); // %dの部分にansの値が表示される
    
    /* 出力する部分*/
    
    
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  vector<string> c(h);
  for(int i=0;i<h;i++){
    cin>>c[i];
  }
  for(int i=0;i<h;i++){
    cout<<c[i]<<endl;
    cout<<c[i]<<endl;
  }
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
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; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{ 
  ll N;
  cin >> N;
  
  vector<ll> A(N);
  REP(i, N) { 
      cin >> A[i];
  }
  ll money = 1000;
  ll stock = 0;
  REP(i, N-1) {
    if (A[i+1] > A[i]) {
      stock += money / A[i];
      money = money % A[i];
    } else if (A[i+1] < A[i]) {
      money += stock * A[i];
      stock = 0;
    }
    // PRINT(stock);
    // PRINT(money);
  }
  money += A[N-1] * stock;
  PRINT(money);
  return 0;
} 


Measured memory_bytes: 3724
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

vector<ll>x;
vector<ll>y;

ll mod=1000000007ll;

int main(){

	ll n,m;

	scanf("%lld %lld",&n,&m);

	ll i;

	for(i=1ll;i<=n;i+=1ll){
		ll xi;
		scanf(" %lld",&xi);
		x.push_back(xi);
	}
	for(i=1ll;i<=m;i+=1ll){
		ll yi;
		scanf(" %lld",&yi);
		y.push_back(yi);
	}

	sort(x.begin(),x.end());
	sort(y.begin(),y.end());

	ll height=0ll;
	ll weight=0ll;

	for(i=1ll;i<=n;i+=1ll){
		ll add=x[i-1]*(2ll*i-n-1ll);	
		add%=mod;
		weight+=add;
		weight%=mod;
	}
	for(i=1ll;i<=m;i+=1ll){
		ll add=y[i-1]*(2ll*i-m-1ll);	
		add%=mod;
		height+=add;
		height%=mod;
	}

	ll ans=weight;
	ans*=height;
	ans%=mod;

	if(ans<0ll){ans+=mod;}

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

	return 0;
}

Measured memory_bytes: 2548
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[][] A = new int[N][N];
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                A[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(A));

        sc.close();
    }

    static long solve(int[][] A) {
        int N = A.length;

        boolean[][] redundants = new boolean[N][N];

        for (int k = 0; k < N; ++k) {
            for (int i = 0; i < N; ++i) {
                for (int j = i + 1; j < N; ++j) {
                    if (k != i && k != j) {
                        if (A[i][k] + A[k][j] < A[i][j]) {
                            return -1;
                        } else if (A[i][k] + A[k][j] == A[i][j]) {
                            redundants[i][j] = true;
                        }
                    }
                }
            }
        }

        long result = 0;
        for (int i = 0; i < N; ++i) {
            for (int j = i + 1; j < N; ++j) {
                if (!redundants[i][j]) {
                    result += A[i][j];
                }
            }
        }

        return result;
    }
}

Measured memory_bytes: 52388
fn readline<T: std::str::FromStr>() -> Vec<T> {
    let mut buff = String::new();
    std::io::stdin().read_line(&mut buff).ok();
    buff.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let input = readline::<i32>();
    let ans = if input[0] < input[1] && input[1] < input[2] {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans)
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200005;
int n,a[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	int b=a[(n+1)/2];
	LL ans=0;
	for (int i=1;i<=n;i++)
		ans+=abs(a[i]-b);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var AB = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B) = (AB[0], AB[1]);

        var ans = (B % A == 0) ? (A + B) : (B - A);

        WriteLine(ans);
    }
}


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

bool ok[1010] = {};

void init(){
    ok[1] = true;
    for(int b = 2; b <= 40; b++){
        int x = b;
        while(true){
            x *= b;
            if(x>1000) break;
            ok[x] = true;
        }
    }
}

int main(void){
    int x;
    cin>>x;
    init();
    for(int i = x; i >= 1; i--){
        if(ok[i]){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ta,ao;
  ta = (a+d-1)/d;
  ao = (c+b-1)/b;
  if(ao == ta){
    printf("Yes\n");
  }else if(ao > ta){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 3592
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <time.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define mod 1000000009
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
    int n;
    int a[100010];
    long ans = 0;
    long maxnum = 1;
    cin >> n;
    for(int i = 0;i < n; i++){
        cin >> a[i];
    }
    for(int i = 0;i < n; i++){
        /*if(i == 0){
            ans += (a[i] - 1);
            a[i] = 1;
        }else{
            int num = a[i] / maxnum;
            if(a[i] - maxnum > maxnum){
                ans += (a[i] / maxnum);
                a[i] -= maxnum * (a[i] / maxnum);
                if(a[i] == 0 && num >= 3){
                    a[i] = maxnum;
                    ans--;
                }else if(a[i] == 0 && num < 3){
                    a[i] = 1;
                    ans = ans - num + 1;
                }
            }else if(a[i] > maxnum){
                a[i] = 1;
                ans++;
            }
        }
        if(maxnum == a[i]){
            maxnum++;
        }*/
        int t = a[i];
        if(a[i] > maxnum){
            int t = a[i] - 1;
            if(t && maxnum <= t){
                ans += t / maxnum;
                if(maxnum > 2){
                    maxnum = maxnum;
                }else{
                    maxnum = 2;
                }   
            }else{
                maxnum = a[i] + 1;
            }
        }else if(maxnum == a[i]){
            maxnum++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> X(N+1), Y(M+1);

	cin >> X[0] >> Y[0];

	FOR(i, 1, N+1){
		cin >> X[i];
	}

	FOR(i, 1, M+1){
		cin >> Y[i];
	}

	VSORT(X);
	VSORT(Y);

//	cout << "X = ";
//	for(auto x : X){ cout << x << " "; }
//	cout << "Y = ";
//	for(auto y : Y){ cout << y << " "; }

	if(Y.front() - X.back() >= 1)
		cout << "No War" << endl;
	else
		cout << "War" << endl;

	return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N int
	con.Scan(&N)
	sieve := make([]int, N+1)
	for i := 2; i <= N; i++ {
		if sieve[i] != 0 {
			continue
		}
		for j := i; j <= N; j += i {
			sieve[j] = i
		}
	}
	primes := make([]int, N+1)
	for i := 2; i <= N; i++ {
		a := i
		for a > 1 {
			primes[sieve[a]]++
			a /= sieve[a]
		}
	}
	answer := 1
	for i := 2; i <= N; i++ {
		answer *= primes[i] + 1
		answer %= 1e9 + 7
	}
	con.Println(answer)
	return nil
}


Measured memory_bytes: 640
/*
*@author:mel0n
*
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;

const int MOD=1000000007;
const ll INF=1e18;
const int MX=100001;
const ld PI=4*atan((ld)1);

//void setIn(string s){freeopen(s.c_str(),"r",stdin);}
//void setOut(string s){freeopen(s.c_str(),"w",stdout); }
//void setIO(){ios_base::sync_with_sdtio(false);cin.tie(0);cout.tie(0);
//}

ll tri(ll a,ll b,ll c)
{

vector <ll> p={a,b,c};
sort(p.begin(),p.end());

if(p[2]<p[1]+p[0])
	return 1;
else
	return 0;


}


int main()
{

	ll n;
	cin>>n;
	vector <ll> v(n);
	for(auto &a:v)
		cin>>a;
	ll cnt=0;
	for(int i=0;i<n;i++)
	{
	
	for(int j=i+1;j<n;j++)
	{
	ll c=v[i],d=v[j];
	if(c!=d)
	{
	
	for(int k=j+1;k<n;k++)
	{
	if(tri(c,d,v[k]) && v[k]!=c && v[k]!=d)
	{cnt++;
	}
	
	}
	
	}
	
	}

	}
	
	cout<<cnt<<endl;

}







Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int sum_digit(int i){
  return i%10 + i/10%10 + i/100%10 + i/1000%10 + i/10000%10;
}

int main(){
	int n,a,b;
  cin >> n >> a >> b;
  long sum = 0;
  for(int i = 0; i <= n; i++){
    int k = sum_digit(i);
    if(k >= a && k <= b){
      sum += i;
    }
  }
  cout << sum << endl;
}


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

using namespace std;

int main(void) {
    int N, K;
    long A = 0;
    cin >> N >> K;

    vector<int> H(N);

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

    sort(H.begin(), H.end());

    for (int i = 0; i < N - K; i++) {
        A += H[i];
    }

    cout << A << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = (n + 1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	n := sc.getInt()
	ans := (n + 1) / 2
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  map<ll,ll> mp;
  rep(i,n){
    ll a;
    cin >> a;
    mp[a]++;
  }
  ll ans=0;
  for(auto p: mp){
    if(p.first<p.second){
      ans+=p.second-p.first;
    }else if(p.first>p.second){
      ans+=p.second;
    }
  }
  cout << ans;
}
 

Measured memory_bytes: 9500
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 (int) 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for(int i = 0; i < n; ++i){
    	cin >> a[i];
    }
    b = a;
	for(ll i =  n - 2 ; i >= 0 ; i--) {
		a[i] += a[i+1];
		a[i] %= MOD;
	}
	int ans = 0;

	for(int i = 0 ; i < n-1 ; i++) {
		ans += (b[i] * a[i+1]) % MOD;
		ans %= MOD;
	}

	cout << ans << '\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 6360