akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n, q;
vector<vector<ll>> g;
vector<ll> ans;

void dfs(ll v, ll p = -1) {
    for(auto u : g[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n >> q;
    g.resize(n);
    rep(i, n - 1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    ans.resize(n, 0);
    rep(i, q) {
        ll p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i, n) printf("%lld%s", ans[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 24320
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    reverse(all(A));
    ll l = P - 1, r = N; // ok, ng;
//    cout << M * V << endl;
    while(r - l > 1) {
        ll m = (l + r) / 2;
        ll sum = 0;
        bool ok = true;
        rep(i, N) {
            if(i < P - 1) sum += M;
            else if(i >= P - 1 && i < m) {
                sum += M - (A[i] - A[m]);
                if(M - (A[i] - A[m]) < 0) {
                    ok = false;
                    break;
                }
            }
            else sum += M;
        }
//        cout << m << ":" << sum << endl;
        if(sum < M * V || !ok) r = m;
        else l = m;
    }
    output(l + 1);
    
    
    return 0;
}


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

public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int rect = 0;
      int diam = 0;
      while(sc.hasNext()) {
         //get information from the user
         String[] input = sc.nextLine().split(",");
         int a = Integer.parseInt(input[0]);
         int b = Integer.parseInt(input[1]);
         int c = Integer.parseInt(input[2]);
         
         if(a == b) {
            diam ++;
         } else if (c * c == a * a + b * b) {
            rect ++;
         }
      }
      System.out.println(rect + "\n" + diam);
   }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,N; cin>>X>>N;
    set<int> S;
    rep(i,N){
        int p; cin>>p;
        S.ins(p);
    }
    int mini=INT_MAX;
    int ans=-1;
    FOR(i,-1,101){
        if (!S.count(i) && mini>abs(X-i)){
            mini = abs(X-i);
            ans = i;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


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

int main() {
    string n;
    cin >> n;
    if(n[0]=='7' || n[1]=='7' || n[2]=='7'){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include "iostream"
#include "string"
using namespace std;
int main(){
  string s;
  cin>>s;
  if((s[0]==s[1])||(s[1]==s[2])||(s[2]==s[3])){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int n,m,k,sum=0;
    scanf("%d%d%d",&n,&m,&k);
    int i=min(n,m);
    for(;i>=1;i--)
    {
        if(n%i==0 && m%i==0)sum++;
        if(sum==k)break;
    }
    printf("%d",i);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ctype.h>
using namespace std;
int main() {
    string S,T; cin >> S >> T;
    bool ans=false;
    for (int i=0;i<S.size();i++){
        if (S[i]!=T[0]) continue;
        string U;
        for (int j=0;j<S.size();j++){
            if (i+j<S.size()) U += S[i+j];
            else U += S[i+j-S.size()];
        }
        if (U==T) {
            ans = true;
            break;
        }
    }
    cout << ((ans) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
def main():
    n,m = map(int,input().split())
    box = [1] * n
    red = [0] * n
    red[0] += 1
    op = [list(map(int,input().split())) for _ in range(m)]
    for o in op:
        x, y = o[0]-1, o[1]-1
        if box[x] < 1:
            continue
        box[x] -= 1
        if red[x] > 0:
            red[y] = 1
        if box[x] == 0:
            red[x] = 0
        box[y] += 1
    print(sum(red))

if __name__ == "__main__":
    main()

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

using namespace std;

int a,b,c,d;

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

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

void output_array(vector<int> &v)
{
  for (int i = 0; i < v.size(); i++)
    cout << (i ? " " : "") << v[i];
  cout << "\n";
}

int get_gcd(int x, int y)
{
  if (x < y)
    swap(x, y);

  while (y > 0)
  {
    int t = y;
    y = x % y;
    x = t;
  }
  return x;
}

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

  int x, y;
  cin >> x >> y;

  cout << get_gcd(x, y) << "\n";

  return 0;
}



Measured memory_bytes: 3220
N = int(input())
l = []
l.append(list(map(int, input().split())))
for i in range(N - 1):
    l.append(list(map(int, input().split())))
    if (l[i][0] > l[i + 1][0]) or (l[i][1] > l[i + 1][1]):
        T = l[i][0] // l[i + 1][0]
        A = l[i][1] // l[i + 1][1]
        if l[i][0] % l[i + 1][0] != 0:
            T += 1
        if l[i][1] % l[i + 1][1] != 0:
            A += 1
        l[i + 1][0] *= max(T, A)
        l[i + 1][1] *= max(T, A)
print(sum(l[-1]))

Measured memory_bytes: 3188
a = int(input())
import collections
b = [input() for i in range(a)]
clist = collections.Counter(b)
#print(clist)
V = clist.keys()
#print(V)
L = clist.most_common()[0][1]
#print(L)

d=[]
f=[]
g=[]
for i in clist.values():
    d.append(i)
for i in clist.keys():
    f.append(i)
#print(d)
for j in range(len(d)):
    if d[j] == L:
        g.append(f[j])
g.sort()
for i in range(len(g)):
    print(g[i])

Measured memory_bytes: 45052
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

ll lcm (ll a, ll b) {
	return (a / gcd (a, b)) * b;
}

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	int a, b; cin >> a >> b;
	cout << (a > b ? a-1 : a) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=2*1e5,M=1e9+7;
int a[mxn],n;
	void solve(){
		cin>>n;	ll sum=0;

		for(int i=0;i<n;i++){
			cin>>a[i];
			sum+=a[i];
			sum%=M;
		}
					ll ans=0;
		for(int i=0;i<n;i++){
			sum-=a[i];
			if(sum<0)sum+=M;
					ans+=sum*a[i];
			ans%=M;
		}
	cout<<ans;	
	}
int main(){
	solve();
}


Measured memory_bytes: 4404
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int n = Integer.parseInt(br.readLine());
			int a = Integer.parseInt(br.readLine());
			System.out.println(n%500<=a?"Yes":"No");

		}
	}
}

Measured memory_bytes: 25360
#include <iostream>
#include <map>
const int INF = 1e9;
using namespace std;

int main(void) {
    int N;cin>>N;
    map<string, int> S, T;
    for (int i = 0; i < N; i++) {
        string s;cin>>s;
        if (S.find(s) != S.end()) S[s] += 1;
        else S[s] = 1;
    }
    int M;cin>>M;
    for (int i = 0; i < M; i++) {
        string t;cin>>t;
        if (T.find(t) != T.end()) T[t] += 1;
        else T[t] = 1;
    }
    int ma = -INF;
    for (map<string, int>::iterator it = S.begin(); it != S.end(); ++it) {
        string t = it->first;
        int tmp = it->second;
        if (T.find(t) != T.end()) {
            tmp -= T[t];
        }
        if (ma < tmp) ma = tmp;
    }
    if (ma < 0) cout << 0 << endl;
    else cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N; SCD(N);
	if (N<=999){
		printf("ABC\n");
	}else{
		printf("ABD\n");
	}
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;

	cout << n * 800 - (n / 15) * 200 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
	double a, b, c, d, e, f, x, y;
	while( cin >> a >> b >> c >> d >> e >> f ){
		x = (c*e - b*f) / (a*e - b*d);
		y = (c*d - a*f) / (b*d - a*e);
		if( fabs(x) < 0.0005 ) x = 0.0;
		if( fabs(y) < 0.0005 ) y = 0.0;
		cout << fixed << std::setprecision(3) << x << " " << y << "\n";
	}
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
    using namespace std;
    int main(){
      int n,t,a,p=0;
      double h,d,min=100000000;
      cin>>n>>t>>a;
      for(int i=1;i<=n;i++){
        cin>>h;
        d=a-(t-h*0.006);
        if(d<0) d*=-1;
        if(d<min){
          min=d;
          p=i;
        }
      }
        cout<<p;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> value, cost, diff;
	for(int i =0;i<n;i++)
	{
		int v;
		cin>>v;
		value.push_back(v);
	}
	for(int i =0;i<n;i++)
	{
		int c;
		cin>>c;
		diff.push_back(value[i] - c);
	}
	sort(diff.begin(),diff.end());
	reverse(diff.begin(),diff.end());
	int cnt = 0;
	for(int i =0;i<diff.size();i++)
	{
		//cout<<diff[i]<<" ";
		if(diff[i] >= 0)
			cnt += diff[i];
		else
			break;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 100005


// Driver code to tes above functions
int32_t main()
{
    
 
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int x = b/c - (a-1)/c;
    int y = b/d - (a-1)/d;
    int k = (c*d)/__gcd(c, d);
    int z = b/k - (a-1)/k;

    //cout << x << " " << y << " " << z << endl;

    cout << b - a + 1 - x - y + z;

    return 0;
    
} 

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;



int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());

	long long ans = A.back();
	A.pop_back();

	if (N == 2) {
		cout << ans << endl;
		return 0;
	}

	int cnt = 0;
	while (true) {
		ans += A.back();
		cnt += 1;
		if (cnt % 2 == 0) A.pop_back();
		if (cnt >= N - 2) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  map<int, int> mp;
  ll sum = 0;
  REP(i, n) {
    int a;
    cin >> a;
    mp[a]++;
    sum += a;
  }
  int q;
  cin >> q;
  REP(i, q) {
    int b, c;
    cin >> b >> c;
    sum += mp[b] * (c - b);
    mp[c] += mp[b];
    mp[b] = 0;
    cout << sum << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 8068
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define pr pair<int, int>
#define x first
#define y second
using namespace std;

template<typename T>
void read(T& n){
	char ch; int sign = 1;
	while (!isdigit(ch = getchar())) if (ch == '-') sign = -1;
	n = ch - '0';
	while (isdigit(ch = getchar())) n = n * 10 + ch - '0';
	n *= sign;
}
typedef long long ll;
const int INF = 1e9 + 7;
const int N = 2111;
int n, m, head, tail;
int a[N][N], vis[N][N], up[N][N], prv[N], suf[N], que[N];

int main(){
	read(n), read(m);
	rep(i, 1, n) rep(j, 1, m){
		char opt; scanf(" %c", &opt);
		a[i][j] = opt == '.' ? 0 : 1;
	}
	rep(i, 1, n - 1) rep(j, 1, m - 1){
		int sum = a[i][j] + a[i+1][j] + a[i][j+1] + a[i+1][j+1];
		if (sum % 2) vis[i+1][j+1] = 1;
	}
	rep(j, 1, m + 1) rep(i, 2, n + 1) up[i][j] = vis[i-1][j] ? 1 : up[i-1][j] + 1;
	rep(i, 1, n + 1) up[i][1] = up[i][m+1] = 0;
	int ans = 0;
	rep(i, 1, n + 1){
		memset(prv, 0, sizeof(prv)), memset(suf, 0, sizeof(suf));
		head = tail = 1, que[1] = 1;
		rep(j, 1, m + 1){
			int l = head, r = tail + 1;
			while(l + 1 < r){
				int mid = (l + r) >> 1;
				if (up[i][que[mid]] < up[i][j]) l = mid; else r = mid;
			}
			prv[j] = que[l];
			while(head <= tail&&up[i][que[tail]] >= up[i][j]) tail--;
			que[++tail] = j;
		}
		head = tail = 1, que[1] = m + 1;
		per(j, m + 1, 1){
			int l = head, r = tail + 1;
			while(l + 1 < r){
				int mid = (l + r) >> 1;
				if (up[i][que[mid]] < up[i][j]) l = mid; else r = mid;
			}
			suf[j] = que[l];
			while(head <= tail&&up[i][que[tail]] >= up[i][j]) tail--;
			que[++tail] = j;
		}
		rep(j, 1, m + 1) ans = max(ans, up[i][j] * (suf[j] - prv[j]));
	}
	printf("%d\n", max(ans, max(n, m)));
	return 0;
}

Measured memory_bytes: 51584
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int to_num(char c){
	int n=c-'0';
	return n;
}
int main() {
	string s;
	int a[10][10];
	while(true){
		cin>>s;
		if (cin.eof())break;
		for(int i=0;i<s.size();i++){
			a[0][i]=to_num(s[i]);
		}
		for(int i=1;i<10;i++){
			for(int j=0;j<10-i;j++){
				a[i][j]=a[i-1][j]+a[i-1][j+1];
				int x=(a[i-1][j]+a[i-1][j+1])/10;
				x*=10;
				a[i][j]-=x;
			}
		}
		cout<<a[9][0]<<endl;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				a[i][j]=0;
			}
		}
	}
}

Measured memory_bytes: 3124
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

enum type {
    COMMAND_UPDATE,
    COMMAND_FIND
};

#define NUM2_MAX (1<<17)
#define QUERY_MAX 100000
#include <limits.h>

struct range {
    int start;
    int end;
};

struct pair {
    int val;
    int time;
};
#define ROOT_NODE 1

int is_contain(struct range this, struct range box) {
    return box.start <= this.start && this.end <= box.end;
}

int is_overlap(struct range r1, struct range r2) {
    return r1.end > r2.start && r2.end > r1.start;
}

void update_range(struct pair *seg, struct range r, struct pair val, int node, struct range nr) {
    if(!is_overlap(r, nr)) return;
    if(is_contain(nr, r)) {
        seg[node] = val;
#ifdef DEBUG
        printf("update: %d -> (%d, %d)\n", node, val.val, val.time);
#endif
        return;
    }
    struct range left = { nr.start, (nr.start + nr.end) / 2 };
    struct range right = { (nr.start + nr.end) / 2, nr.end };
    update_range(seg, r, val, node*2, left);
    update_range(seg, r, val, node*2+1, right);
    return;
}

struct pair find(struct pair *seg, int num2, int idx) {
    int node = num2 + idx;
    struct pair ans = seg[node];
    while((node = node/2)) {
        struct pair this = seg[node];
        ans = ans.time > this.time ? ans : this;
    }
    return ans;
}

int main(void) {
    int num, qs;
    get_int2(&num, &qs);
    int i;
    int num2 = 1;
    while(num > num2) num2 *= 2;
    // initialization
    static struct pair seg[NUM2_MAX*2];
    for(i = ROOT_NODE; i < num2*2; i++) seg[i] = (struct pair){.val = INT_MAX, .time = -1};
    struct range whole = {0, num2};
    static int ans[QUERY_MAX];
    int aidx = 0;
    int t;
    for(t = 0; t < qs; t++) {
        int type = get_int();
        switch(type) {
            case COMMAND_UPDATE:
                {
                    int start, end;
                    int val;
                    get_int3(&start, &end, &val);
                    end++;
                    struct range r = {start, end};
                    struct pair np = {val, t};
                    update_range(seg, r, np, ROOT_NODE, whole);
                }
                break;
            case COMMAND_FIND:
                {
                    int idx = get_int();
                    struct pair p = find(seg, num2, idx);
                    ans[aidx++] = p.val;
                }
                break;
            default:
                break;
        }
    }

    for(i = 0; i < aidx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

#define int ll

signed main() {
  int N, Q;
  cin >> N >> Q;

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

  vector<int> p(Q), x(Q);
  rep(i, Q) {
    cin >> p[i] >> x[i];
    p[i]--;
  }

  vector<vector<int>> G(N);
  rep(i, N) {
    G[a[i]].pb(b[i]);
    G[b[i]].pb(a[i]);
  }

  vector<int> count(N);
  rep(i, Q) {
    count[p[i]] += x[i];
  }
  vector<int> visited(N, false);

  queue<int> q;
  q.push(0);

  while (!q.empty()) {
    int now = q.front();
    q.pop();
    visited[now] = true;

    for (int next : G[now]) {
      if (visited[next])
        continue;
      count[next] += count[now];
      q.push(next);
    }
  }

  rep(i, N) {
    cout << count[i] << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 25712
#include<stdio.h>

int main(void){

char s[3];

scanf("%s",&s);

if(s[0]=='S'&&s[1]=='U'&&s[2]=='N'){printf("7");}
if(s[0]=='M'&&s[1]=='O'&&s[2]=='N'){printf("6");}
if(s[0]=='T'&&s[1]=='U'&&s[2]=='E'){printf("5");}
if(s[0]=='W'&&s[1]=='E'&&s[2]=='D'){printf("4");}
if(s[0]=='T'&&s[1]=='H'&&s[2]=='U'){printf("3");}
if(s[0]=='F'&&s[1]=='R'&&s[2]=='I'){printf("2");}
if(s[0]=='S'&&s[1]=='A'&&s[2]=='T'){printf("1");}


  return 0;
}


Measured memory_bytes: 1620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {
    
    ll ans=LLINF;
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll mo=x%d;
    ll _k=(x-mo)/d;
    
    if(_k>k){
        x-=k*d;
        fin(x);
    }else{
        k-=_k;
        k%=2;
        if(k==0)chmin(ans,abs(mo));
        else{
            mo-=d;
            chmin(ans,abs(mo));
        }
        fin(ans);
    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

const int MOD = 1000000007;
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

mint calc(ll N, ll K) { 
    mint res = 1;
    for(ll i = 0; i < K; ++i) {
        res *= (N - i);
        res /= (i + 1); // K!を同時に割っている！
    }
    return res;
}

int main() {
    ll n, a, b; cin >> n >> a >> b;

    mint res = modpow(mint(2), n) - 1;

    res -= calc(n , a);
    res -= calc(n , b);

    cout << res << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;

const int N=100005;

int n,l,r,last;
ll s,ans;
ll a[N],x[N];

int main(){
	int i;
	scanf("%d%lld",&n,&s);
	for (i=1;i<=n;i++) scanf("%lld%lld",&x[i],&a[i]);
	if (n==1){
		printf("%lld\n",abs(s-x[1]));
		return 0;
	}
	l=1; r=n; last=0;
	while (s>=x[l]&&s<=x[r]){
		if (a[l]>=a[r]){
			a[l]+=a[r];
			if (last!=1) ans+=x[r]-x[l];
			last=1;
			r--;
		}
		else{
			a[r]+=a[l];
			if (last!=2) ans+=x[r]-x[l];
			last=2;
			l++;
		}
	}
	if (l<=r){
		if (s>=x[l]) ans+=s-x[l];
		else if (s<=x[r]) ans+=x[r]-s;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var eightDivisorCount int
	for i := 1; i <= n; i += 2 {
		var count int
		for j := 1; j <= n; j++ {
			if i%j == 0 {
				count++
			}
		}
		if count == 8 {
			eightDivisorCount++
		}
	}
	fmt.Println(eightDivisorCount)
}


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

void solve(){
  int H, W, h, w; cin >> H >> W >> h >> w;
  bool a[H][W];
  for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) a[i][j] = true;
  for(int i = 0; i < h; i++) for(int j = 0; j < W; j++) a[i][j] = false;
  for(int i = 0; i < w; i++) for(int j = 0; j < H; j++) a[j][i] = false;

  int ans = 0;
  for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) if(a[i][j] == true) ans++;
  cout << ans << endl;

  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = 15 - s.size();
  for (int i = 0; i < s.size(); i++) if (s[i] == 'o') n++;
  if (n >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll n,m;
cin>>n>>m;
V<ll> a(n),b(n);
for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
    b[i]/=2;
}
for(int i=0;i<n;i++){
  if(b[i]>m){
    cout<<0<<endl;
    return 0;
  }
}
bool check=true;
for(int i=40;i>=0;i--){
    ll tpow=(1ll<<i);
    if(a[0]%tpow==0){
         for(int j=0;j<n;j++){
            if(a[j]%tpow!=0){
                cout<<0<<endl;
                return 0;
            }
        }
        break;
    }
    else{
        for(int j=0;j<n;j++){
            if(a[j]%tpow==0){
                cout<<0<<endl;
                return 0;
            }
        }
    }
}

ll d=b[0];
for(int i=1;i<n;i++){
    d=lcm(d,b[i]);
    if(d>m){
        cout<<0<<endl;
        return 0;
    }
}
cout<<(m/d+1)/2<<endl;

}




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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
long long INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

#define MAX_N 40
pair<int,int> Y[MAX_N],ps[1<<(MAX_N/2)];

int inline bs(int begin, int end, int x){
    int left=begin,right=end-1,mid;
    if(x<ps[left].first || x>ps[right].first) return -1;
    while(left<=right){
        mid = (left+right)/2;
        if(x<ps[mid].first) right = mid-1;
        else left = mid+1;
    }
    if(x==ps[right].first) return right;
    else return -1;
}

int main(){
    int ans=MOD,n,ma,mb;

    scanf("%d %d %d",&n,&ma,&mb);
    REP(i,n){
        int a,b;
        scanf("%d %d %d",&a,&b,&Y[i].second);
        Y[i].first = ma*b - mb*a;
    }

    int n2 = n / 2;
    REP(i,1<<n2){
        int s=0,v=0;
        REP(j,n2){
            if(i>>j&1){
                s += Y[j].first;
                v += Y[j].second;
            }
        }
        ps[i] = make_pair(s,v);
    }

    ps[0] = ps[1];
    sort(ps,ps+(1<<n2));
    int m=1;
    FOR(i,1,1<<n2) if(ps[m-1].first != ps[i].first) ps[m++] = ps[i];

    REP(i,1<<(n-n2)){
        int s=0,v=0;
        REP(j,n-n2){
            if(i>>j&1){
                s += Y[n2+j].first;
                v += Y[n2+j].second;
            }
        }
        if(s!=0||v==0){
            if(bs(0,m,-s)!=-1) ans = min(ans,v+ps[bs(0,m,-s)].second);
        }else ans = min(ans,v);
    }

    if(ans!=MOD&&ans!=0) printf("%d\n",ans);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 8448
#include <stdio.h>

char s[1001];
int d[4];

int main () {
	scanf("%s", s);
	
	int i = 0;
	while(s[i] != '\0') {
		if(s[i] == 'N') { d[0]++; }
		if(s[i] == 'S') { d[1]++; }
		if(s[i] == 'E') { d[2]++; }
		if(s[i] == 'W') { d[3]++; }
		
		i++;
	}
	
	printf("%s\n", ( ((d[0] == 0) == (d[1] == 0)) && ((d[2] == 0) == (d[3] == 0)) ) ? "Yes" : "No" );
	
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int A1;
	int A2;
	int A3;
	
	scanf("%d %d %d", &A1, &A2, &A3);
	if (A1 + A2 + A3 >= 22){
		printf("bust\n");	
	}
	else {
		printf("win\n");
	}
	return 0;
	
}


Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b;
  cin >> a >> b;
  auto ans = [&]{
    if(a<6) return 0;
    if(a<13) return b/2;
    return b;
  };
  cout << ans() << endl;
}


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

int main()
{
  int n, a[200000] = {0};
  cin >> n;
  for (int i = 0; i < n - 1; i++)
  {
    int tmp;
    cin >> tmp;
    a[tmp - 1]++;
  }
  for (int i = 0; i < n; i++)
  {
    cout << a[i] << endl;
  }
}


Measured memory_bytes: 4416
a,b,k = map(int,input().split())
if b - a + 1  >= 2*k:
    for i in range(a,a+k):
        print(i)
    for j in range(b-k+1,b+1):
        print(j)
else:
    for i in range(a,b+1):
        print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define pb push_back
#define ms(a, x) memset(a, x, sizeof(a))
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i) 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e3+10;
/*=======================================================================*/

int n, m;
char mp[N][N];
ll dp[N][N];

int main() {
   dp[1][1] = 1;
   scanf("%d%d", &n, &m);
   for1(i, n) {
      for1(j, m) {
         cin >> mp[i][j];
         if(mp[i-1][j] == '.') {
            dp[i][j] += dp[i-1][j];
         }
         if(mp[i][j-1] == '.') {
            dp[i][j] += dp[i][j-1];
         }
         dp[i][j] %= mod;
      }
   }
   cout << dp[n][m] << endl;
   return 0;
}

Measured memory_bytes: 9216
#include<iostream>
int R,C,s[10000][10],f[10],N,i,j,n,m;void rec(int k){if(k==R){for(n=i=0;i<C;i++,n+=m>R-m?m:R-m)for(m=j=0;j<R;j++)m+=s[i][j]^f[j];N=N>n?N:n;return;}f[k]=0;rec(k+1);f[k]=1;rec(k+1);}main(){for(;std::cin>>R>>C,R;rec(0),printf("%d\n",N))for(j=R;j-->0;)for(i=C;i-->0;)std::cin>>s[i][j];}

Measured memory_bytes: 1260
import math
n,m = (int(i) for i in input().split())
if abs(m-n)>1:
	print(0)
elif abs(m-n)==1:
	print((math.factorial(m)*math.factorial(n))%(10**9+7))
else:
	print((2*(math.factorial(m)**2))%(10**9+7))

Measured memory_bytes: 5172
a1, b1 = gets.split(' ')
a2, b2 = gets.split(' ')
a3, b3 = gets.split(' ')
 
arr = [a1,a2,a3,b1,b2,b3]
result = 'YES'
4.times.with_index do |i|
  result = 'NO' if arr.count((i+1).to_s) == 3 || arr.count((i+1).to_s) == 0
end
 
puts result


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

public interface Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int[] d = {a,b,c};
		Arrays.sort(d);
		System.out.printf("%d %d %d\n", d[0], d[1],d[2]);
	}
}



Measured memory_bytes: 26380
#include <iostream>

int main(){
    
    int x,y,z;
    std::cin >> x >> y >> z;
    int temp;
    
    temp=x;
    x=y;
    y=temp;
    
    temp=x;
    x=z;
    z=temp;
    
    std::cout << x << " " << y << " " << z << " " << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  char s[n+1];
  scanf("%s", s);

  long r = 0;
  long g = 0;
  long b = 0;

  long count = 0;

  for (long i = 0; i < n; i++) {
    if (s[i] == 'R') {
      r++;
    }
    if (s[i] == 'G') {
      g++;
    }
    if (s[i] == 'B') {
      b++;
    }
  }

  for (long i = 0; i < n; i++) {
    for (long j = i+1; j < n; j++) {
      if (s[j] == s[i]) {
        continue;
      }
      if (j*2-i >= n) {
        continue;
      }
      if (s[j*2-i] != s[i] && s[j*2-i] != s[j]) {
        count++;
      }
    }
  }

  long answer = r*g*b-count;

  printf("%ld\n", answer);

  return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a) & 1)cout << "Borys" << endl;
	else cout << "Alice" << endl;
}


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

using namespace std;

void Main() {
    long long H, W;
    cin >> H >> W;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return;
    }

    long long ans = 0;
    if (W % 2 == 0) {
        ans = H * (W / 2);
    }
    else {
        if (H % 2 == 0) {
            ans = W * (H / 2);
        }
        else {
            ans = W * (H - 1) / 2;
            ans += (W + 1) / 2;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <cctype>
using namespace std;
typedef long long ll;

int main( void ) {
    string s, p;
    cin >> s >> p;
    s += s;
    int len1 = s.length(), len2 = p.length();
    bool ok;
    for( int i = 0; i <= len1 - len2; ++i ) {
        ok = true;
        for( int j = i, k = 0; k < len2; ++k, ++j ) {
            if( s[j] != p[k] ) {
                ok = false;
                break;
            }
        }
        if( ok ) break;
    }
    if( ok ) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}



Measured memory_bytes: 3212
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1000000000000000;

ll n, m, h[100000], x, d[100000];
vector<P> e[100000];

int main() {
  scanf("%lld%lld%lld", &n, &m, &x);
  for (ll i = 0; i < n; i++) scanf("%lld", &h[i]);
  ll a, b, t;
  for (ll i = 0; i < m; i++) {
    scanf("%lld%lld%lld", &a, &b, &t);
    a--, b--, e[a].push_back(P(b, t)), e[b].push_back(P(a, t));
  }
  priority_queue<P, vector<P>, greater<P> > que;
  for (ll i = 0; i < n; i++) d[i] = INF;
  que.push(P(-x, 0));
  d[0] = -x;
  while (!que.empty()) {
    P p = que.top(); que.pop();
    ll from = p.second, cost = p.first;
    for (ll i = 0; i < e[from].size(); i++) {
      ll to = e[from][i].first, c2 = e[from][i].second, sumcost = 0;
      if (c2 > h[from]) continue;
      if (cost >= 0) sumcost = c2 * 2 + cost;
      else if (c2 >= -cost) sumcost = cost + c2 + (c2 + cost);
      else {
        sumcost = cost + c2;
        if (-sumcost > h[to]) sumcost = -h[to];
      }
      if (d[to] > sumcost) {
        d[to] = sumcost;
        que.push(P(sumcost, to));
      }
    }
  }
  if (d[n-1] == INF) printf("-1\n");
  else if (d[n-1] < 0) printf("%lld\n", h[n-1] + d[n-1] * 2 + x);
  else printf("%lld\n", d[n-1] + x + h[n-1]);
}



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

using namespace std;

int shiki(int a, int b, int x) {
	if (pow(a, 5) - pow(b, 5) == x)return 1;
	if (pow(a, 5) - pow(-b, 5) == x)return 2;
	if (pow(-a, 5) - pow(-b, 5) == x)return 3;
	return 0;
}

int main() {
	
	int x,a=0,b=0;
	cin >> x;
	while (1) {
		while (a >= b) {

			if (shiki(a, b, x) == 1) {
				cout << a << " " << b;
				return 0;
			}
			if (shiki(a, b, x) == 2) {
				cout << a << " " << -b;
				return 0;
			}
			b++;
		}
		a++;
		b = 0;
	}
}

Measured memory_bytes: 3976
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

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

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;
struct BIT {
	vector< int > container;
	BIT(int n) {
		container = vector< int >(n + 1, 0);
	}
	void add(int i, int x) {
		if (i > container.size())
			return;
		container[i] += x;
		add(i + (i & -i), x);
	}
	int sum(int i) {
		if (i == 0)
			return 0;
		return container[i] + sum(i - (i & -i));
	}
	int sum(int l, int r) {
		return sum(r - 1) - sum(l - 1);
	}
};
int N, M, K, T, Q;
signed main() {
	cin >> N >> K;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	vector< int > S(N + 1, 0);
	rep(i, N) S[i + 1] = S[i] + A[i];
	vector< pii > T(N + 1);
	rep(i, N + 1) {
		T[i].first = S[i] - K * i;
		T[i].second = i;
	}
	sort(T.begin(), T.end());
	BIT bt(N + 1);
	int ans = 0;
	rep(i, N + 1) {
		ans += bt.sum(T[i].second);
		bt.add(T[i].second + 1, 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8064
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {
	public static void main(String[] args)throws IOException{
		Scanner scan = null;
		try{
			scan = new Scanner(new InputStreamReader(System.in));
			while(scan.hasNext()){
				int n = scan.nextInt();
				if(n == 0)break;
				int max;
				List<Integer> dataset = new ArrayList<Integer>();
				dataset.add(max = scan.nextInt());
				for(int i = 1;i<n;i++)
					dataset.add(max = scan.nextInt());
				for(int i = 0; i < n; i++){
					int sum = 0;
					for(int j = i; j<n;j++){
						max = Math.max(sum += dataset.get(j), max);
					}
				}
				System.out.println(max);
			}
		}finally{
			scan.close();
		}

	}
}

Measured memory_bytes: 26584