akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const ll MOD = (ll)1e9 + 7LL;

// dp[i番目][j:a[i]を使った個数][k: kの値]
// dp[i+1][j][k] += dp[i][j][k]
// dp[i+1][j+1][a[i]^k] += dp[i][j][k]

ll dp[105][105][256];
ll fact[105];

void init_fact(void){
	fact[0] = 1LL;
	for (int i = 1; i < 105; ++i){
		fact[i] = ((ll)i*fact[i-1]) % MOD;
	} // end for
}

int main()
{
	memset(dp, 0LL, sizeof(dp));
	memset(fact, 0LL, sizeof(fact));
	init_fact();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, K; cin >> N >> K;
	vector<int> a(N, 0);
	rep (i, N) cin >> a[i];

	dp[0][0][0] = 1LL;
	for (int i = 0; i < N; ++i){
		for (int j = 0; j <= i; ++j){
			for (int k = 0; k < 256; ++k){
				ll & ans = dp[i+1][j+1][a[i] ^ k];
				ans = (ans + dp[i][j][k]) % MOD;
				dp[i+1][j][k] = (dp[i+1][j][k] + dp[i][j][k])% MOD;
			} // end for
		} // end for
	} // end for

	ll res = 0LL;
	for (int j = 0; j <= N; ++j){
 		res = (res + dp[N][j][K] * fact[j]) % MOD;
	} // end for
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 22400
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

constexpr int inf = (1 << 30) - 1;

int main() {
  std::string strA, strB;
  std::cin >> strA >> strB;
  int N = strA.length();
  if (strB == std::string(N, '0')) {
    std::cout << (strA == std::string(N, '0') ? 0 : -1) << '\n';
    return 0;
  }
  std::vector<bool> A(N), impB(3 * N);
  for (int i = 0; i < N; ++i) {
    A[i] = (strA[i] == '1');
    impB[i] = impB[i + N] = impB[i + 2 * N] = (strB[i] == '1');
  }
  auto B = impB.begin() + N;
  std::vector<int> nearL(N), nearR(N);
  {
    int cur = -N - 1;
    for (int i = -N; i < 0; ++i) {
      if (B[i]) cur = i;
    }
    for (int i = 0; i < N; ++i) {
      if (B[i]) cur = i;
      nearL[i] = i - cur;
    }
    cur = 2 * N;
    for (int i = 2 * N - 1; i >= N; --i) {
      if (B[i]) cur = i;
    }
    for (int i = N - 1; i >= 0; --i) {
      if (B[i]) cur = i;
      nearR[i] = cur - i;
    }
  }
  int ans = inf;
  auto chmin = [](int &lhs, int rhs) {
    if (lhs > rhs) lhs = rhs;
  };
  auto chmax = [](int &lhs, int rhs) {
    if (lhs < rhs) lhs = rhs;
  };
  auto min_dist = [](int maxL, int maxR, int endp) {
    return 2 * (maxL + maxR) - std::max(endp, -endp);
  };
  for (int endp = -N; endp <= N; ++endp) {
    std::vector<std::pair<int, int>> query;
    for (int i = 0; i < N; ++i) {
      if (A[i] != B[endp + i]) {
        query.emplace_back(nearL[i], nearR[i]);
      }
    }
    std::sort(query.begin(), query.end());
    int baseL = std::max(0, -endp), baseR = std::max(0, endp);
    std::vector<int> maxR(query.size() + 1);
    maxR.front() = baseR;
    for (int i = 0; i < query.size(); ++i) {
      maxR[i + 1] = std::max(maxR[i], query[query.size() - i - 1].second);
    }
    chmin(ans, min_dist(baseL, maxR.back(), endp) + query.size());
    for (int i = 0; i < query.size(); ++i) {
      chmax(baseL, query[i].first);
      chmin(ans, min_dist(baseL, maxR[query.size() - i - 1], endp) + query.size());
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
a = [0] * n
b = [0] * m
count = 0
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(n):
    for j in range(a[i][0]):
        b[a[i][j+1]-1] += 1
for i in range(m):
    if b[i] == n:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll k;
ll S[500][500];

ll i,j;

int main(){
    scanf("%lld",&N);
    ll n=0;
    for(k=1;n<N;k++)n+=k;
    if(N!=n){
        printf("No\n");
        return 0;
    }
    
    printf("Yes\n");
    printf("%lld\n",k);
    ll sc=1;
    fornum(i,0,k){
        printf("%lld ",k-1);
        fornum(j,0,i){
            S[i][j]=S[j][i-1];
            printf("%lld ",S[i][j]);
        }
        fornum(j,i,k-1){
           S[i][j]=sc;
           sc+=1;
           printf("%lld ",S[i][j]);
        }
        printf("\n");
    }
    
    
    return 0;
}

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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;

void solve(){
	int x,y,z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << "\n";
	
}

int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int main(){
	int n;
//		while(cin>>n,n){
	cin>>n;

	p(800*n-200*(n/15));
//		}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7, M = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n, k;
	cin >> n >> k;
	vi v;
	for(int i = 1; i <= n;) {
		v.PB(i);
		i = n / (n / i) + 1;
	}
	vi dp(v.size());
	for(int i = 0; i < dp.size(); i++) {
		dp[i] = i != dp.size() - 1 ? v[i+1]-v[i] : n+1-v[i];
	}
	for(int i = 0; i < k - 1; i++) {
		vi nw_dp(v.size());
		for(int i = 1; i < dp.size(); i++) dp[i] = (dp[i-1] + dp[i]) % M;
		for(int j = 0; j < dp.size(); j++) {
			int k = dp.size() - j - 1;
			nw_dp[j] = (ll) (j != dp.size() - 1 ? v[j+1]-v[j] : n+1-v[j]) * dp[k] % M;
		}
		dp = nw_dp;
	}
	int ans = 0;
	for(int i = 0; i < dp.size(); i++)
		ans = (ans + dp[i]) % M;
	cout << ans << endl;;
	
}





Measured memory_bytes: 4136
import sys
input = sys.stdin.readline
n = int(input())
ans = 0
x = [0] * n
for i in range(n):
    x[i] = tuple([int(x) for x in input().strip().split()])

x.sort()
pre = -float('inf')
for xx in x:
    if pre > xx[0] - xx[1]:
        if pre < xx[0] + xx[1]:
            continue
        else:
            pre = xx[0] + xx[1]
            continue
    
    ans += 1
    pre = xx[0] + xx[1]
print(ans)


Measured memory_bytes: 16992
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

#include <queue>
int const inf = 1<<29;
int n;
int p[100010];
int d[100010];

int main(){
    while(cin>>n && n){
        rep(i,n)cin>>p[i];
        rep(i,n)d[i] = inf;
        queue<int> q;
        q.push(0);
        d[0] = 0;
        while(q.size()){
            int x = q.front(); q.pop();
            if(x >= n) continue;
            dump(x,p[x]);
            if(p[x]){
                if(d[x+p[x]] > d[x]){
                    d[x+p[x]] = d[x];
                    q.push(x+p[x]);
                }
            }else{
                for(int i=1;i<=6;i++){
                    if(d[x+i] > d[x]+1){
                        d[x+i] = d[x]+1;
                        q.push(x+i);
                    }
                }
            }
        }
        cout << d[n-1] << endl;
    }
}

Measured memory_bytes: 2016
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)


using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;


int main(){
	fast_io; cout_precision;
	int a; cin >> a;	string str;	cin >> str;
	if(a>=3200)	cout<<str;
	else	cout<<"red";
	return 0;
}

Measured memory_bytes: 256
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif
#define REPP(i,j,n) for(LL i=j;i<n;++i)
#define REP(i,n) REPP(i,0,n)
#define F first
#define S second

using namespace std;
typedef long long LL;
typedef pair<LL,LL> PLL;
priority_queue<PLL,vector<PLL>,greater<PLL>> Xs,Ys;

auto scan = []{static LL a;scanf("%lld",&a);return a;};
#define MAXN 100000

PLL A[MAXN];
bool ninS[MAXN]={0};
int main(){
  LL X = scan(), Y = scan(), Z = scan(), n = X + Y + Z, C, finalAns = 0, lans = 0, rsub = 0,sumr = 0 , Csum = 0;
  REP(i, n){
    A[i] = {scan(),scan()};
    C = scan();
    Csum += C;
    A[i].F -= C, A[i].S -= C;
  }
  sort(A, A + n, [=](PLL J,PLL K){
    return K.F - K.S < J.F - J.S;
  });
  
  REP(i,X)Xs.push({A[i].F,i}), lans += A[i].F;
  
  REPP(i,X,n)Ys.push({-A[i].S,i}), ninS[i] = 1, sumr += A[i].S, rsub += A[i].S;
  
  while(Ys.size()>Z){
    PLL inS = Ys.top(); Ys.pop();
    rsub -= -inS.F;
    ninS[inS.S] = 0;
  }
  finalAns = lans + sumr - rsub;
  REPP(i, X, X + Z){
    Xs.push({A[i].F,i});
    lans += A[i].F;
    lans -= Xs.top().F;
    Xs.pop();
    
    if(ninS[i] == 0){
      rsub += A[i].S;
      PLL addto = Ys.top();Ys.pop();
      while(addto.S < i)addto = Ys.top(),Ys.pop();
      rsub -= -addto.F;
      ninS[addto.S] = 0;
    }
    
    finalAns = max(finalAns, lans + sumr - rsub);
  }
  printf("%lld\n",finalAns + Csum);
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
class Graph 
{ 
    int V;    
    list<int> *adj;    
public: 
    Graph(int V);  // Constructor 
  
    // function to add an edge to graph 
    void addEdge(int v, int w);  
  
    // prints BFS traversal from a given source s 
    void BFS(int s);   
}; 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<int>[V]; 
} 
  
void Graph::addEdge(int v, int w) //How to add edge
{ 
    adj[v].push_back(w); 
} 
  
void Graph::BFS(int s) //BFS 
{ 
   
    bool *visited = new bool[V]; 
    for(int i = 0; i < V; i++) 
        visited[i] = false; 
 
    list<int> queue; 
    visited[s] = true; 
    queue.push_back(s); 
    list<int>::iterator i; 
  
    while(!queue.empty()) 
    { 
        s = queue.front(); 
        cout << s << " "; 
        queue.pop_front(); 
  
        for (i = adj[s].begin(); i != adj[s].end(); ++i) 
        { 
            if (!visited[*i]) 
            { 
                visited[*i] = true; 
                queue.push_back(*i); 
            } 
        } 
    } 
} //To create a graph
//Graph g(4); 
    //g.addEdge(0, 1); 
    //g.addEdge(0, 2); 
int gcd(int x, int y) {
        if (x == 0) {
            return y;
        }
        
        return gcd(y % x, x);
    }
ll factorial(ll a)
{
  ll fact[a+1];
  fact[0]=1;
  fact[1]=1;
  for(int i=2;i<=a;i++)
  fact[i]=fact[i-1]*i;
  return fact[a];
  
}

int main()
{
 ll a,b;
 cin>>a>>b;
 ll res=a*(a-1)/2;
 res+=b*(b-1)/2;
 cout<<res<<"\n";
 
}


Measured memory_bytes: 256
from sys import stdin


def main():
    X = int(stdin.readline().rstrip())
    max_ = 1
    for a in range(1, X):
        if a ** 2 > X:
            break
        for b in range(2, X):
            if a ** b <= X:
                max_ = max(max_, a ** b)
            else:
                break
    print(max_)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N, M = map(int, input().split())
islands = [tuple(map(int, input().split())) for _ in range(M)]
islands.sort()

cnt = 0
l = 1
r = N
for left, right in islands:
    if r <= left:
        cnt += 1
        l = left
        r = right
    else:
        l = max(l, left)
        r = min(r, right)

print(cnt+1)

Measured memory_bytes: 16988
n = int(input())
a = [int(input()) for _ in range(n)]

sorted_a = a.copy()
sorted_a.sort()
if sorted_a[-1] == sorted_a[-2]:
  for i in range(n):
    print(sorted_a[-1])
else:
  for i in range(n):
    if a[i] == sorted_a[-1]:
      print(sorted_a[-2])
    else:
      print(sorted_a[-1])
  

Measured memory_bytes: 14112
# coding: UTF-8

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

tempertures = [t - 0.006 * height for height in heights]
temp_diff = [abs(temperture - a) for temperture in tempertures]

minimum_diff_point = 0

for i, diff in enumerate(temp_diff):
    if diff < temp_diff[minimum_diff_point]:
        minimum_diff_point = i

print(minimum_diff_point + 1)


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

typedef long long ll;

int main(){
	int n,d;
	cin >> n  >> d;

	double a = d*2+1;
	cout <<  ceil(n/a) <<endl;


	return 0;
}


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

int main(){
	int x;
	cin >> x;
	int h = x / 3600;
	int m = (x - 3600 * h) / 60;
	int s = x - 3600 * h - 60 * m;
	cout << h << ":"<<m <<":"<< s << endl;
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <stack>
#include <deque>
#define maxn 200005
#define ll long long
using namespace std;
int a[maxn];
ll seg1[4 * maxn], seg2[4 * maxn];
ll add = 0;
ll ab(ll a) {
	return a > 0 ? a : -a;
}
void modify(int type, int cur, int l, int r, int x, ll val) {
	if (r <= l || x >= r || x < l) return;
	if (r - l == 1 && x == l) {
		if (type == 1) {
			seg1[cur] = min(seg1[cur], val - add);
		}else {
			seg2[cur] = min(seg2[cur], val - add);
		}
		return;
	}
	int mid = (l + r) >> 1;
	modify(type, cur << 1, l, mid, x, val);
	modify(type, (cur<<1) | 1, mid, r, x, val);
	if (type == 1) seg1[cur] = min(seg1[cur<<1], seg1[(cur<<1)|1]);
	else seg2[cur] = min(seg2[cur<<1], seg2[(cur<<1)|1]);
}
ll query(int type, int cur, int l, int r, int ql, int qr) {
	if (r <= l || ql >= r || qr <= l) return 1LL<<60;
	if (ql <= l && qr >= r) {
		//cout << type << " " << l << " " << r << " " << (type == 1 ? seg1[cur] : seg2[cur]) << endl;
		return (type == 1 ? seg1[cur] : seg2[cur]);
	}
	int mid = (l + r) >> 1;
	ll ret = 1LL<<60;
	ret = min(ret, query(type, cur << 1, l, mid, ql, qr));
	ret = min(ret, query(type, (cur<<1)|1, mid, r, ql, qr));
	//cout << type << " " << l << " " << r << " " << ret << endl;
	return ret;
}
void init(int cur, int l, int r) {
	if (r <= l) return;
	if (r - l == 1) {
		seg1[cur] = 1LL<<60;
		seg2[cur] = 1LL<<60;
		return;
	}
	int mid = (l + r) / 2;
	init(cur * 2, l, mid);
	init(cur * 2 + 1, mid, r);
	seg1[cur] = min(seg1[cur * 2], seg1[cur * 2 + 1]);
	seg2[cur] = min(seg2[cur * 2], seg2[cur * 2 + 1]);
}
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n, q, p1, p2;
	cin >> n >> q >> p1 >> p2;
	n++;
	for (int i = 0;i < q;i++) cin >> a[i + 1];
	init(1, 0, n);
	modify(1, 1, 0, n, p1, -p1);
	modify(2, 1, 0, n, p1, p1);
	a[0] = p2;
	for (int i = 1;i <= q;i++) {
		ll con = ab(a[i] - a[i - 1]);
		ll res = min(query(1, 1, 0, n, 0, a[i]) + a[i], query(2, 1, 0, n, a[i], n) - a[i]) + add;
		add += con;
		//cout << res << endl;
		modify(1, 1, 0, n, a[i - 1], res - a[i - 1]);
		modify(2, 1, 0, n, a[i - 1], res + a[i - 1]);
	}
	ll ans = 1LL<<60;
	for (int i = 0;i <= n;i++) {
		ans = min(ans, query(1, 1, 0, n, i, i + 1) + i);
	}
	cout << ans + add << endl;
}

Measured memory_bytes: 12608
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static int mod = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();
		int a= sc.nextInt();
		int b = sc.nextInt();
		int total=0;
		boolean g=true;
		int count=0;
		if(b==1){
			System.out.println("0");
			return;
		}
		while(g==true){
			total+=(a);
			count++;
			if(total>=b)
				break;
			total-=1;
		}
		System.out.println(count);
		out.close();
	}
	
	public static int partition(int [] arr, int s, int e){
		
		int index=s;
		int pivot = arr[e];
		for(int i=s;i<=e-1;i++){
			if(arr[i]<=pivot){
				arr = swap(arr, index, i);
				index++;
			}
		}
		swap(arr,index,e);
		print(arr);
		return index;
	}
	
	public static int[] swap(int[] arr, int low, int high){
		int temp = arr[low];
		arr[low]=arr[high];
		arr[high]=temp;
		return arr;
	}
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static void print(int[] arr){
		for(int i=0;i<arr.length;i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
	public static class pair{
		int ai;
		int bi;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return o1.bi-o2.bi;
		}
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int k,p;
    cin>>k>>p;
    if(k%p == 0){
      cout<<p<<endl;
    }else{
      cout<<k%p<<endl;
    }
  }
}
    

Measured memory_bytes: 1164
n, p = map(int, input().split())
s = input()[::-1]
if p == 2:
  ans = 0
  for num, i in enumerate(s):
    if int(i)%2 == 0:
      ans += n-num
elif p == 5:
  ans = 0
  for num, i in enumerate(s):
    if int(i)%5 == 0:
      ans += n-num
else:
  C = [0]*p
  now = 0
  for num, i in enumerate(s):
    a = int(i)
    now = (now+pow(10, num, p)*a)%p
    C[now] += 1
  ans = C[0]
  for c in C:
    ans += c*(c-1)//2
print(ans)

Measured memory_bytes: 42096
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
const int maxN = 1e5 + 7;
const int maxS = (1 << 15) + 3;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int n, m;
int a[maxN];
bool ok[maxS];
int f[maxS];

int main() {

	m = n = ri();
	For (i, 1, n) {
		int x = ri() + 1, y = ri() + 1, d = ri();
		a[x] ^= d;
		a[y] ^= d;
	}

	sort(a+1, a+n+1, greater<int>());
	int res = 0, mask = 0;
	for (; n > 0 && a[n] == 0; --n) ++res;
	while (n > 0) {
		for (; n >= 2 && a[n] == a[n-1]; n -= 2) ++res;
		if (n >= 1) mask |= 1 << (a[n--] - 1);
	}

	for (int s = mask; s; (--s) &= mask) {
		int tp = 0;
		rep (i, 1, 15) if (s >> (i-1) & 1) tp ^= i;
		ok[s] = tp == 0;
	}
	ok[0] = true;
	rep (s, 1, mask) if ((mask & s) == s && ok[s]){
		for (int t = s; t; (--t) &= s) if (ok[t] && ok[s^t]) {
			f[s] = max(f[s], f[s ^ t] + 1);
		}
	}
	res += f[mask];
	printf("%d\n", m - res);

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main(){
  int r,g,b;
  cin>>r>>g>>b;
  if((10*g+b)%4==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;



}


Measured memory_bytes: 256
import sys
from itertools import combinations

import numpy as np

n = int(input())
points = np.array([list(map(int, line.split())) for line in sys.stdin], dtype=np.float64)

if n == 2:
    p1, p2 = points
    print(np.sqrt(((p1 - p2) ** 2).sum()) / 2)
    exit()

ans = 0
for p1, p2, p3 in combinations(points, 3):
    A = ((p2 - p3) ** 2).sum()
    B = ((p3 - p1) ** 2).sum()
    C = ((p1 - p2) ** 2).sum()
    sa, sb, sc = sorted([A, B, C])
    if sa + sb <= sc + 1e-7:
        R2 = sc / 4
    else:
        T = A * (B + C - A)
        U = B * (C + A - B)
        W = C * (A + B - C)
        c = (T * p1 + U * p2 + W * p3) / (T + U + W)
        R2 = ((c - p1) ** 2).sum()
    ans = max(ans, R2)
print(np.sqrt(ans))


Measured memory_bytes: 12516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    string S; cin >> S;
    cout << S[0] << S.size() - 2 << S.back() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <unordered_map>
#include <vector>
#define ALL(x) (x).begin(), (x).end()
using std::vector;
typedef long long lld;
int D, N, X;
lld ret;

struct Pair {
  lld L, R;

  bool operator < (const Pair& o) const {
    return (L != o.L) ? (L < o.L) : (R < o.R);
  }
};
std::unordered_map<lld, vector<Pair>> R;
vector<Pair> tmp;

lld sum(int x) { return 1LL * x * (x + 1) / 2; }

void merge_adjacent(vector<Pair>& B) {
  int sz = B.size();
  tmp.clear();
  tmp.reserve(sz);
  for (const Pair& cur: B) {
    if (tmp.empty() || (tmp.back().R < cur.L)) {
      tmp.push_back(cur);
    } else if (tmp.back().R < cur.R) {
      tmp.back().R = cur.R;
    }
  }
  B = move(tmp);
}

lld solve() {
  if (D == 0) {
    return (X == 0) ? 1 : (N + 1);
  }
  if (D < 0) {
    D *= -1;
    X *= -1;
  }
  R.clear();
  R.reserve(N+1);
  for (int k = 0; k <= N; ++k) {
    lld base = 1LL * k * X;
    lld offset = base / D;
    R[base % D].push_back({
      offset + sum(k-1),
      offset + sum(N-1) - sum(N-k-1)
    });
  }
  lld ret = 0LL;
  for (auto& itr: R) {
    auto& data = itr.second;
    std::sort(ALL(data));
    merge_adjacent(data);
    for (const Pair& cur: data) {
      ret += cur.R - cur.L + 1;
    }
  }
  return ret;
}

int main() {
  scanf(" %d%d%d", &N, &X, &D);
  printf("%lld\n", solve());
  return 0;
}

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

int main() {
    int N;
    int M;
    cin >> N;
    cin >> M;
    int p[M];
    string S[M];
    int succeed[N];
    int wrong[N];
    int flag[N];
    for (int i = 0; i < N; ++i){
        succeed[i] = 0;
        wrong[i] = 0;
        flag[i] = 0;
    }
    
    for (int i = 0; i < M; ++i){
        cin >> p[i] >> S[i];
        if (S[i] == "AC"){
            succeed[p[i]-1] = 1;
            flag[p[i]-1] = -1;
        } else {
            wrong[p[i]-1] += 1;
            wrong[p[i]-1] += flag[p[i]-1];
        }
    }
    int succeedsum = 0;
    int wrongsum = 0;
    for (int i = 0; i < N; ++i){
        succeedsum += succeed[i];
        if (succeed[i] == 1){
            wrongsum += wrong[i];
        }
    }
    
    /*for (int i = 0; i < N; ++i){
        cout << succeed[i] << " " <<  wrong[i] << endl;
    }*/
    cout << succeedsum << " " << wrongsum << endl;
    return 0;
}


Measured memory_bytes: 7296
while 1:
	n,a,b,c,x = map(int, raw_input().split(" "))
	if (n,a,b,c,x) == (0,0,0,0,0):
		break
	y = [0]
	y[1:] = map(int, raw_input().split(" "))
	frame = -1
	for i in range(1,n+1):
		frame += 1
		while frame <= 10000 :
			tmpx = x
			x = (a * x + b) % c
			if tmpx == y[i]:
				break
			frame += 1
		else :
			frame = - 1
			break
	print frame

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

class Program {
    static Scanner cin = new Scanner();
    static int N = cin.Int();
    static int K = cin.Int();
    static int[] D = cin.ArrayInt(K);
    static List<int> list = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    static List<int> ANS = new List<int>();
    static void Main() {
        foreach (var x in D) {
            list.Remove(x);
        }
        foreach (var x in list) {
            if(x != 0) hoge(x);
        }

        ANS = ANS.Where(x => x >= N).ToList();
        Console.WriteLine(ANS.Min());
        Console.ReadLine();
    }

    static void hoge(int n) {
        ANS.Add(n);
        if (n >= 100 * N) return;
        foreach (var x in list) {
            hoge(10 * n + x);
        }
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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


Measured memory_bytes: 74708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    cout << ((g * 10 + b) % 4 ? "NO\n" : "YES\n");
    return 0;
}


Measured memory_bytes: 3592
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long a, b, c;
    scan(a, b, c);
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
    {
        writeln(0);
        return;
    }
    auto abc = new long[](3);
    abc[0] = a;
    abc[1] = b;
    abc[2] = c;
    auto abc_so = abc.sort();
    // writeln(abc_so);
    writeln(abc_so[0] * abc_so[1]);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

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

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

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

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            count++;
        } else {
            if (d[i - 1] != d[i]) {
                count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>

int main(void){
    char character;
    int count[26] = {};
    while(scanf("%c", &character) != EOF){
        if('A'<=character && character<='Z'){
            character -= 'A';
        }else if('a'<=character && character<='z'){
            character -= 'a';
        }else{
            continue;
        }
        count[character]++;
    }
    for(int i=0; i<26; i++){
        printf("%c : %d\n", 'a'+i, count[i]);
    }
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	int t;
	cin >> t;
	rep(loop,t){
		int p,q;
		cin >> p >> q;
		int sum=p*p+q*q;
		int res=0;
		for(int m=-150;m<150;++m){
			for(int n=-150;n<150;++n){
				int d=m*m+n*n;
				if(d==0)
					continue;
				if(sum%d)
					continue;
				int g=__gcd(m*p+n*q,m*q-n*p);
				if(g%d==0)
					res++;
			}
		}
		if(res==8)
			puts("P");
		else
			puts("C");
	}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#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() {
  ll l, r;
  cin >> l >> r;
  int mod = 2019;
  r = min(r, l + mod * 2);
  ll ans = mod;
  for (ll i = l; i < r; i++) {
    for (ll j = l + 1; j <= r; j++) {
      ans = min(ans, (i * j) % mod);
      if (ans == 0) {
        cout << ans << endl;
        return 0;
      };
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;int flag=0;
  cin >> n;
  int d1[n],d2[n];
  for(int i=0;i<n;++i){
      cin >> d1[i] >> d2[i];
  }
  for(int i=0;i<n-2;++i){
      if(d1[i]==d2[i] && d1[i+1]==d2[i+1] && d1[i+2]==d2[i+2]){
          cout << "Yes" << endl;
          flag=1;
          break;
      }
  }
  if(flag==0){
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr *bufio.Reader

func main() {
	rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)
	solve()
}

func solve() {
	var N int
	fmt.Scanf("%d", &N)
	count := make(map[string]int, 0)

	for _, s := range []string{"AC", "WA", "TLE", "RE"} {
		count[s] = 0
	}

	for i := 0; i < N; i++ {
		var S string
		fmt.Scanf("%s", &S)
		count[S] += 1
	}
	for _, s := range []string{"AC", "WA", "TLE", "RE"} {
		fmt.Println(s, "x", count[s])
	}
}

func readline() string {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readIntSlice(size int) []int {
	slice := make([]int, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i(v)
	}
	return slice
}

func readInt64Slice(size int) []int64 {
	slice := make([]int64, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i64(v)
	}
	return slice
}

func readint() int {
	return s2i(readline())
}

func readint64() int64 {
	return s2i64(readline())
}

// For int64
func b2i64(b bool) int64 {
	if b {
		return 1
	}
	return 0
}

func abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int
func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

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

func min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i(s string) int {
	v, ok := strconv.Atoi(s)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int")
	}
	return v
}

func lcm(v1, v2 int) int {
	if v1 > v2 {
		v1, v2 = v2, v1
	}
	for v1 != 0 {
		v1, v2 = v2%v1, v1
	}
	return v2
}

func gcd(v1, v2 int) int {
	return v1 * v2 / lcm(v1, v2)
}

/* ------------------------------------------------ */
/* Data stracture                                   */
/* ------------------------------------------------ */
type IntHeap []int

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }


Measured memory_bytes: 8788
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="Sunny")
    cout<<"Cloudy\n";
  else if(s=="Cloudy")
    cout<<"Rainy\n";
  else if(s=="Rainy")
    cout<<"Sunny\n";
  return 0;
}

Measured memory_bytes: 256
def j():
    a,b,c,k=map(int,input().split())
    o=0
    x=k
    if a!=0:
        o+=a
        k-=a
        if k==0:
            return a
        elif k<0:
            return x
    if b!=0:
        k-=b
        if k<=0:
            return a
    if c!=0:
        k-=c
        o-=c
        if k==0:
            return o
        elif k<0:
            return o-k
print(j())

Measured memory_bytes: 9208
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long m, std::vector<long long> p, std::vector<std::string> s){
    int ans = 0;
    vector<int> cnt(n, 0);
    for(int i = 0; i < m; ++i){
        int k = p[i] - 1;
        if(s[i] == "AC" && cnt[k] != -1){
            ans += cnt[k];
            cnt[k] = -1;
        }
        else if(cnt[k] != -1){
            ++cnt[k];
        }
    }
    cout << count(cnt.begin(), cnt.end(), -1) << " " << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> p(M);
    std::vector<std::string> S(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&p[i]);
        std::cin >> S[i];
    }
    solve(N, M, std::move(p), std::move(S));
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main() {
  int n; cin >> n;
  vvll h(n,vll(3));
  rep(i, n) rep(j, 3) cin >> h[i][j];
  vvll dp(n+1, vll(3));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
      if (j != k) dp[i+1][k] = max(dp[i+1][k], dp[i][j] + h[i][k]);
  ll ans = 0;
  rep(i, 3) ans = max(ans, dp[n][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    string t;
    cin >> s >> t;
    int ret = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i])ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int res = 0;
    for(int i = 0; i <= N; i += R){
        for(int j = 0; i + j <= N; j += G){
            if((N - (i + j)) % B == 0){
                res++;
            }
        }
    }
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        
      int a =N/2;
      int b =(N/2)+1;
      
      double c =a;
      double d =b;
      
      if(N%2==0){
      System.out.print(c/N);
      }
      else if(N%2!=0){
      System.out.print(d/N);
      }
    }
 }

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#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)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int X, Y;
  cin >> X >> Y;

  X = max(0, 4 - X);
  Y = max(0, 4 - Y);

  int ans = 0;
  ans += 100000 * X;
  ans += 100000 * Y;

  if (X == Y && Y == 3)
    ans += 400000;
  cout << ans << "\n";
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()

ans = [False] * N
p = 0
b = 0
for i in range(N):
    if S[i] == 'a':
        if p < A + B:
            ans[i] = True
            p += 1
    elif S[i] == 'b':
        if p < A + B and b < B:
            ans[i] = True
            p += 1
            b += 1

for b in ans:
    print("Yes" if b else "No")

Measured memory_bytes: 4784
#include <cstdio>
#include <cstring>
#include <set>

using namespace std;

#define MAX 1500

int cnt[MAX*MAX];

int main(){
  int N, M;

  while(scanf("%d %d" ,&N ,&M), (N | M)){
    int h[MAX], w[MAX];
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0 ; i < N ; i++){      
      scanf("%d" ,&h[i]);
    }

    set<int> st;
    for(int i = 0 ; i < N ; i++){
      int S = 0;
      for(int j = i ; j < N ; j++){
        S += h[j];
        st.insert(S);
        cnt[S]++;
      }
    }
    for(int i = 0 ; i < M ; i++){
      scanf("%d" ,&w[i]);
    }
    int ans = 0;
    for(int i = 0 ; i < M ; i++){
      int S = 0;
      for(int j = i ; j < M ; j++){
        S += w[j];
        if(st.count(S)){
          ans += cnt[S];
        }
      }
    }
    printf("%d\n" ,ans);
  }

  return 0;
}

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

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

    static class GroupContest {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.readIntArray(3 * n);
            Arrays.sort(a);
            long sum = 0L;
            for (int i = n; i < 3 * n; i += 2) {
                sum += a[i];
            }
            out.println(sum);
        }

    }

    static class InputReader {
        private static BufferedReader in;
        private static StringTokenizer tok;

        public InputReader(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

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

        public int[] readIntArray(int n) {
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }

        public String next() {
            try {
                while (tok == null || !tok.hasMoreTokens()) {
                    tok = new StringTokenizer(in.readLine());
                    //tok = new StringTokenizer(in.readLine(), ", \t\n\r\f"); //adds commas as delimeter
                }
            } catch (IOException ex) {
                System.err.println("An IOException was caught :" + ex.getMessage());
            }
            return tok.nextToken();
        }

    }
}



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

int main(){
    int ans=0,sum=0;
    int n;
    cin >> n;
    
    int a[n];
    int box[n];
    int anslist[n];

    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    for (int i = n; i >= 1; i--){
        
        int k=2;
        int bit = a[i-1];
        
        while (k*i <= n){
            bit ^= box[k*i-1];
            k++;
        }
        box[i-1]=bit;
    }
    
    for (int i = 0; i < n; i++){
        if(box[i]==1){
            anslist[ans]=i+1;
            ans++;
        }
    }

    cout << ans << endl;
    
    for (int i = 0; i < ans; i++)
    {
        cout << anslist[i] << '\n';
    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 2944
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] strs = scan.nextLine().split(" ");
        int a = Integer.valueOf(strs[0]);
        int b = Integer.valueOf(strs[1]);
        int max = a + b;
        if(max < a - b) {
            max = a - b;
        }
        if(max < a * b) {
            max = a * b;
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 21716
#include <stdio.h>

int main(void){
	int W,H,x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if((x+r)<=W&&(x-r)>=0){
		if((y+r)<=H&&(y-r)>=0){
			
			printf("Yes\n");
			
			}else{
			
			printf("No\n");
			
			}
		}else{
			
			printf("No\n");
			
			}
	}


Measured memory_bytes: 2104