akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll a, b, c;

    cin >> a >> b >> c;

    if (4 * a * b < (c - a - b) * (c - a - b) && c - a - b >= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  a = a % 2;
  b = b % 2;
  if(a == 0 || b == 0){
  	cout << "Even" << endl;
  }
  else {
  	cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }
    static object Solve() {
        var S = Console.ReadLine();
        var N = S.Length;
        var b = new int[N];
        var w = new int[N];
        for (int i = 0; i < N; i+=2) {
            b[i] = 1;
        }
        for (int i = 1; i < N; i+=2) {
            w[i] = 1;
        }
        var bc = 0;
        var wc = 0;
        for (int i = 0; i < N; i++) {
            if (S[i] - '0' != b[i]) bc++;
            if (S[i] - '0' != w[i]) wc++;
        }
        return Math.Min(bc, wc);
    }
}

Measured memory_bytes: 27016
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 998244353;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

#define No -1
#define Done -2

int n, m, k, w, req;
vector<int> g[MX];
vector<int> stk, rec(MX, No), color(MX);

void dfs(int x, int par, int c){
	color[x] = c;
	if(c == 0) w++;
	for(auto &y : g[x]){
		if(y == par) continue;
		dfs(y, x, c ^ 1);
	}
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int x, n;
	cin >> x >> n;
	vector<int> a(n), seen(102);
	for(auto &y : a){
		cin >> y;
		seen[y] = true;
	}

	int df = 1e9, val = 1e9;
	
	for(auto &y : a){
		if(!seen[y - 1]){
			int ss = abs(x - (y - 1));
			if(ss < df || (ss == df && y - 1 < val)){
				df = ss;
				val = y - 1;
			}
		}
		if(!seen[y + 1]){
			int ss = abs(x - (y + 1));
			if(ss < df || (ss == df && y + 1 < val)){
				df = ss;
				val = y + 1;
			}
		}
	}

	if(val == 1e9) val = x;

	cout << val << endl;

	return 0;
}

Measured memory_bytes: 6208
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, m;
    int ans = 0;
    cin >> n >> m;
    if(n > m / 2){
        ans = m / 2;
        n -= ans;
        m -= ans * 2;
    }else{
        ans = n;
        m -= 2 * ans;
        ans += m / 4;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
function main(input) {
  const N = input;
  let n = 0;
  
  // Math.pow(x, y) xのy乗
  
  while (true) {
    if (Math.pow(2, n) === N) {
      n--;
      break;
    } else if (Math.pow(2, n) > N) {
      n--;
      break;
    } else {
      n++;
    }
  }
  // n = 0 => 0.5になるので切り上げておく
  console.log(Math.ceil(Math.pow(2, n)));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29556
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define ld long double
#define pii pair<ll,ll>
#define s second
#define M 1000000007
#define f first
ll x[102],y[102];

ld ang(ll y,ll x){
	ld a = atan2(y,x) * 180.0 / 3.141592653589793;
	return a;
}

int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    ll n;
    cin>>n;
    pii v[3*n+1];
    for(int i=0;i<n;++i){
    	cin>> x[i] >> y[i];
    	v[i] = {ang(y[i],x[i]),i};
    }
    sort(v,v+n);
    for(int i=0;i<n;++i)
    	v[i+n] = v[i];
    ll sx[3*n+1],sy[3*n+1];
    sx[0] = 0,sy[0]=0;
    for(int i=0;i<2*n;++i){
    	sx[i+1] = sx[i]+x[v[i].s];
    	sy[i+1] = sy[i]+y[v[i].s];
    }
    ld ans=0;
    for(ll d=n-1;d>=0;--d){
    	for(ll i=0;i+d<2*n;++i){
    		ld dis = (sx[i+d+1]-sx[i])*(sx[i+d+1]-sx[i]) \
    				 + (sy[i+d+1]-sy[i])*(sy[i+d+1]-sy[i]);
    		ans = max(ans,dis);
    	}
    }
    cout << setprecision(20) << sqrt(ans) << "\n";
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>  
# define  lcm(a, b)     (a * b) / __gcd(a, b)  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
void solve(){
	long n, d, res = 0;
	cin >> n >> d;
	for (int i = 0; i < n; ++i){
		long x, y;
		cin >> x >> y;
		if( sqrt( x * x + y * y ) <= d ) res ++;
	}
	cout << res;
} 
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        cout << fixed << setprecision(9);
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
} 													


Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

vector<ll> a(mx);
ll n,k;

bool finish(ll x){
  ll cnt=0;
  for(int i=0; i<n; i++){
    if(a[i]<0){
      ll v = (x<0?(x-a[i]+1):x)/a[i]; 
      cnt += a.begin()+i - lower_bound(a.begin(),a.begin()+i, v);
    } else if(a[i]==0){
      if(x>=0){ cnt += i; }
    } else {
      ll v = (x>=0?x:(x-a[i]+1))/a[i];
      cnt += upper_bound(a.begin(),a.begin()+i, v) - a.begin();
    }
  }
  return cnt>=k;
}
 
int main(){
  cin >> n >> k;
  a.resize(n);
  rep(i,n){cin>>a[i];}
  sort(a.begin(),a.end());
  ll l=-longinf,r=longinf,mid=(r+l)/2;
  while(r-l>1){
    mid=(r+l)/2;
    if(finish(mid)){ r=mid; }else{ l=mid; }
  }
  ll ans = r;
  cout << ans << endl;
  return 0;
}


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




int main(){

  int n;
  cin>>n;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int ans=0;
  for(int i=0;i<=n-3;i++){
    if(min({p[i],p[i+1],p[i+2]})!=p[i+1]  && max({p[i],p[i+1],p[i+2]})!=p[i+1]){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[5], k;
  for(int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  cin >> k;
  sort(a, a + 5);
  if(a[4] - a[0] > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
///**Bismillahir Rahmanir Rahim.**

#include <bits/stdc++.h>
#define clr(a, v)             memset(a, v, sizeof a)
#define all(v)                v.begin(), v.end()
#define ast(v)                sort(v.begin(),v.end())
#define dst(v)                sort(v.begin(),v.end(), greater <int> ())
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ass(tmp, v)           tmp.assign(v.begin(), v.end())
#define rep(i, l, r)          for (int i = l; i < r; i++)
#define rep2(i, l, r)         for (int i = l-1; i >= r; i--)
#define sf(n)                 scanf("%d", &n)
#define sff(n, m)             scanf("%d %d",&n,&m)
#define sfl(n)                scanf("%lld", &n)
#define sfu(n)                scanf("%llu", &n)
#define sffl(n, m)            scanf("%lld %lld",&n,&m)
#define sfff(n, m, o)         scanf("%d %d %d",&n,&m, &o)
#define pf(n)                 printf("%d", n)
#define sp                    printf(" ")
#define nl                    printf("\n")
#define prln(n)               printf("%d\n", n)
#define pfl(n)                printf("%lld", n)
#define pfu(n)                printf("%llu", n)
#define pb                    push_back
#define pii                   pair<int,int>
#define mp                    make_pair
#define S                     second
#define F                     first
#define PI                    3.1415926

struct greaters
{
    bool operator()(const long& a, const long& b) const
    {
        return a > b;
    }
};

//-----------------------------------***********************----------------------------------------------//


typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int N = 2050;
const int mod = 1e9+7;


int main()
{
    //freopen("test.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;
    int tcase = 1, cas = 0;
    while(tcase--)
    {
        ll n, k;
        cin >> n >> k;

        int a[N];
        rep(i, 1, n+1)
        cin >> a[i];

        ll ans = 0;
        for(int i = 1; i <= n; i++)
        {
            for(int j = i; j <= n; j++)
            {
                if(a[i] > a[j])
                    ans += (1LL*(k*(k+1))/2);
                else if(a[i] < a[j])
                    ans += (1LL*(k*(k-1))/2);
                     ans %= mod;
            }
        }

        cout << ans;

        ///printf("Case %d: %lld\n", ++cas, ans);
    }
    return 0;

}

//-----------------------------------***********************----------------------------------------------//



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    int n; cin>>n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i,n){
        cin>>p[i];
    }
    rep(i,n){
        cin>>q[i];
    }
    string ps;
    string qs;
    rep(i,n){
        ps+=p[i];
        qs+=q[i];
    }

    vector<int> combi(n);
    rep(i,n) combi[i]=i+1;
    int pcnt;
    int qcnt;
    int cnt=1;
    do{
        string s;
        rep(i,n){
            s+=combi[i];
        }
        if(s==ps) pcnt=cnt;
        if(s==qs) qcnt=cnt;
        cnt++;
    }while(next_permutation(all(combi)));

    cout<<abs(pcnt-qcnt)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, x; cin >> a >> b >> x;
  cout << b/x - (a+x-1)/x + 1 << endk;
  return 0;
}


Measured memory_bytes: 3648
class UnionFind
  def initialize(n)
    @size = Array.new(n, 1)
    @rank = Array.new(n, 0)
    @parent = []

    (0..n).each do |i|
      @parent[i] = i
    end
  end

  def find(x)
    if @parent[x] == x
      x
    else
      @parent[x] = find(@parent[x])
    end
  end

  def unite(x, y)
    x = find(x)
    y = find(y)
    return if x == y

    if @rank[x] < @rank[y]
      @parent[x] = y
      @size[y] += @size[x]
    else
      @parent[y] = x
      @size[x] += @size[y]

      @rank[x] += 1 if @rank[x] == @rank[y]
    end
  end

  def same?(x, y)
    find(x) == find(y)
  end

  def size(x)
    @size[find(x)]
  end
end

N, Q = gets.split.map(&:to_i)
uf = UnionFind.new(N + 1)

Q.times do
  com, x, y = gets.split.map(&:to_i)

  if com == 0
    uf.unite(x, y)
  else
    if uf.same?(x, y)
      puts 1
    else
      puts 0
    end
  end
end



Measured memory_bytes: 8952
#include<iostream>
#include<vector>

using namespace std;

void swap(int&, int&);

int main(){
  int w, n, a, b;
  char c;
  vector<int> x;

  cin >> w;
  cin >> n;

  for(int i=0; i<=w; ++i)
    x.push_back(i);

  for(int i=0; i<n; ++i){
    cin >> a >> c >> b;
    swap(x[a], x[b]);
  }

  for(int i=1; i<=w; ++i)
    cout << x[i] << endl;

  return 0;
}

void swap(int& a, int& b){
  int c;
  c = a;
  a = b;
  b = c;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
ll M = DIV0;
ll mpow(ll x, ll n){ //x^n (mod M)
    ll ans = 1;
    while(n != 0){
        //したの桁から見ていって、その桁にあったら*xして、nをシフトするにつれxを二乗する
        if (n & 1) ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}
int main()
{
    int N;
    cin >> N;
    ll ans = 0;
    ans = mpow(10,N)-mpow(9,N)-mpow(9,N)+mpow(8,N);
    ans %= M;
    ans = (ans + M)%M;
    fin(ans);
    return 0;
}

Measured memory_bytes: 3180
#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}
macro_rules ! readl { ( $ t : ty ) => { { let s = getline ( ) ; s . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,+ ) => { { let s = getline ( ) ; let mut iter = s . trim ( ) . split ( ' ' ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; }
macro_rules ! readlvec { ( $ t : ty ) => { { let s = getline ( ) ; let iter = s . trim ( ) . split ( ' ' ) ; iter . map ( | x | x . parse ( ) . unwrap ( ) ) . collect ::< Vec <$ t >> ( ) } } }
macro_rules ! mvec { ( $ v : expr , $ s : expr ) => { vec ! [ $ v ; $ s ] } ; ( $ v : expr , $ s : expr , $ ( $ t : expr ) ,* ) => { vec ! [ mvec ! ( $ v , $ ( $ t ) ,* ) ; $ s ] } ; }
macro_rules ! debug { ( $ x : expr ) => { println ! ( "{}: {:?}" , stringify ! ( $ x ) , $ x ) } }
fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}
struct ContestPrinter {
    s: String,
}
impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter { s: String::new() }
    }
    fn print<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}", x).as_str());
    }
    fn println<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}
impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}
fn is_max_i64(num: i64) -> bool {
    if num == i64::max_value() {
        true
    } else {
        false
    }
}

fn main() {
    let mut pr = ContestPrinter::new();
    
    
    let N = readl!(usize);
    
    let mut ps = Vec::new();
    for i in 0..N {
        let (a, b) = readl!(i32, i32);
        ps.push((a, b, 1));
    }
    for i in 0..N {
        let (c, d) = readl!(i32, i32);
        ps.push((c, d, -1));
    }

    ps.sort();

    let mut ans = 0;
    let mut hs = HashSet::new();
    for p in ps {
        let (x, y, t) = p;
        if t == 1 {
            hs.insert((x, y));
        } else {
            let (mut maxx, mut maxy) = (-1, -1);
            for h in hs.iter() {
                let &(hx, hy) = h;
                if (hy < y) & (maxy < hy) {
                    maxx = h.0;
                    maxy = h.1;
                }
            }
            if maxx != -1 {
                hs.remove(&(maxx, maxy));
                ans += 1;
            }
        }
    }

    pr.println(ans);
}

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

int dx[] = {1 , -1 , 0 ,  0};
int dy[] = {0 ,  0 , 1 , -1};
#define ll long long
#define vi vector <int>
#define pi pair< int , int >
#define pl pair< ll , ll >
#define pii pair< pi , int >
#define fr first
#define sc second
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define PI acos(-1)
#define eps 1e-6
#define OO   INT_MAX
#define infin LLONG_MAX
#define mod 1000000007
#define SPEED_UP ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SZ(x) ((int)(sizeof(x)))
#define sz(v) (int)v.size()
#define all(t) t.begin(),t.end()
#define frei freopen("in.in","r",stdin)
#define freo freopen("out.out","w",stdout)
#define SET(x,y)    x|=(1<<y)
#define CLEAR(x,y)  x&= ~(1<<y)
#define TOGGLE(x,y) x^=(1<<y)
#define READ(x,y)   ((bool)((ll)(x&(1<<y)) != 0))
#define I(x) scanf("%d",&x)
#define I2(x,y) scanf("%d%d",&x,&y)
#define I3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define I4(x,y,z,r) scanf("%d%d%d%d",&x,&y,&z,&r)
#define L(x) scanf("%I64d",&x)
#define L2(x,y) scanf("%I64d%I64d",&x,&y)
#define L3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define L4(x,y,z,r) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&r);
#define D4(x,y,z,r) scanf("%lf%lf%lf%lf",&x,&y,&z,&r);
#define MAX (int)1e5+100
int n,k,a[MAX][3];
ll dp[2][4];
/*
ll get(int i = 0,int state = 3)
{
    if(i > n)return -1e15;
    if(i == n)return 0;
    if(dp[i][state] + 1)return dp[i][state];
    ll ret = -1e15;
    if(state != 0)ret = max(ret,get(i+1,0) + a[i][0]);
    if(state != 1)ret = max(ret,get(i+1,1) + a[i][1]);
    if(state != 2)ret = max(ret,get(i+1,2) + a[i][2]);
    return dp[i][state] = ret;
}
*/
int main()
{
    memset(dp,-1,SZ(dp));
    scanf("%d",&n);
    FOR(i,0,n)scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    dp[1][0] = dp[1][1] = dp[1][2] = 0;
    for(int i = n-1 ; i >= 0 ; i--)
    {
        for(int state = 0 ; state <= 3 ; state ++)
        {
            ll ret = -1e15;
            if(state != 0)ret = max(ret,dp[1][0] + a[i][0]);
            if(state != 1)ret = max(ret,dp[1][1] + a[i][1]);
            if(state != 2)ret = max(ret,dp[1][2] + a[i][2]);
            dp[0][state] = ret;
        }
        for(int state = 0 ; state <= 3 ; state ++)
            dp[1][state] = dp[0][state];
    }
    printf("%I64d\n",dp[0][3]);
    return 0;
}


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

int main(){
    ll H,N,i,j,div;
    cin>>H>>N;
    vector<ll> A(N),B(N);
    vector<vector<ll>> dp(N,vector<ll>(H));
    for(i=0;i<N;i++)cin>>A[i]>>B[i];

    for(i=0;i<N;i++){
        for(j=0;j<H;j++){
            div=(j+1)/A[i];
            if((j+1)%A[i]!=0)div++;
            if(i==0){
                dp[i][j]=B[i]*div;
            }else{
                if((j+1)<=A[i]){
                    dp[i][j]=min(dp[i-1][j],B[i]);
                }else{
                    dp[i][j]=min(dp[i-1][j],dp[i][j-A[i]]+B[i]);
                }
            }
        }
    }

    cout<<dp[N-1][H-1]<<endl;
}

Measured memory_bytes: 78464
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    int fib[45];
    fib[0] = fib[1] = 1;
    FOR(i,2,44){
        fib[i] = fib[i-1] + fib[i-2];
    }
    cout << fib[n] << endl;
    return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;
 
Node *root;
 
void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}
 
void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
 
void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
int main(){
  int n,i,x;
  char com[20];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      }
  }
  return 0;
}

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

int main() {
  long int N;
  cin >> N;
  long int A[N];
  for (long int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] -= i + 1;
  }
  sort(A, A + N);
  long int ans = 0;
  for (long int i = 0; i < N; i++) ans += abs(A[i] - A[(N - 1)/ 2]);

  cout << ans << endl;
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  int a = 0, b = 0;
  for(int i = 0;i < n;i++)
  {
    string A, B;
    cin >> A >> B;
    if(A < B)
    b += 3;
    if(A == B)
    {
      a++;
      b++;
    }
    if(A > B)
    a += 3;
  }
  cout << a << " " << b << endl;
}



Measured memory_bytes: 3080
import sys
input=lambda: sys.stdin.readline().rstrip()

n=int(input())
A=[int(i) for i in input().split()]
ans=1
mod=10**9+7
C=[0,0,0]
for i in range(n):
  cur=A[i]
  ct=0
  Chk=True
  for i,c in enumerate(C):
    if cur==c:
      ct+=1
      if Chk:
        C[i]+=1
        Chk=False
  ans=(ans*ct)%mod
  
print(ans)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    set<string>s;
    while(n--){
        string t;
        cin>>t;
        s.insert(t);
    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 19292
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    string s; cin >> s;
    int n = (int)s.size();
    map<char,int>mp;
    rep(i,n) mp[s[i]]++;
    int a = mp['a'];
    int b = mp['b'];
    int c = mp['c'];
    int dif = abs(a-b)+abs(a-c) + abs(b-c);
    if(dif <= 2)return puts("YES")*0;
    cout << "NO" << endl;
}



Measured memory_bytes: 512
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------
ll mod=998244353; 
struct mint {
int64_t x;
mint(int64_t x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod;return *this;}
mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod;return *this;}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(int64_t t) const {if (!t) return 1;mint a = pow(t>>1);a *= a;if (t&1) a *= *this;return a;}
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓




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

    ll mod=998244353; 

    ll n,k;
    cin>>n>>k;

    vll l(k);
    vll r(k);
    rep(i,k){
        cin>>l[i]>>r[i];
    }


    vec<mint> dp(1000000,0);
    dp[0]=1;
    dp[1]=-1;
    rep(i,n){
        if(i>0) dp[i]+=dp[i-1];
        rep(j,k){
            if(i+l[j]<n){dp[i+l[j]]+=dp[i];}
            if(i+r[j]+1<n){dp[i+r[j]+1]-=dp[i];}
        }
    }


    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 11112
#include<stdio.h>
int main()
{
    int h,w,n;
    scanf("%d",&h);
    scanf("%d",&w);
    scanf("%d",&n);
    int max=h;
    if(max<w)
        max=w;
    int a=n/max;
    if(a*max<n)
    printf("%d",a+1);
    else printf("%d",a);
    return 0;
}

Measured memory_bytes: 128
import bisect
N = 10**5
Q = int(input())
 
lst1 = set([2])
for L in range(3, N, 2):
    if all(L % L2 != 0 for L2 in lst1):
        lst1.add(L)

lst2 = [i for i in lst1 if (i+1)//2 in lst1]
 
lst2.sort()
 
for _ in range(Q):
  l, r = map(int, input().split())
  a = bisect.bisect_left(lst2, l)
  b = bisect.bisect_right(lst2, r)
  print(b-a)

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

int main(){
        int N;
        int K[1000];
        int P[1000];
        cin>>N;
        
        for(int i=0;i<N;i++){
                cin>>K[i]>>P[i];
               
       }
          for(int j=0;j<N;j++){
          if(K[j]%P[j]==0){
          cout<<P[j]<<endl;
       }
        else
        cout<<K[j]%P[j]<<endl;
}
        return 0;
}

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

int main()
{
	int N, a[100],max = 0,min = 1000;

	cin >> N;

	for (int n = 0; n < N; n++) {
		cin >> a[n];

		if (max < a[n])max = a[n];
		if (min > a[n])min = a[n];
	}

	cout << max - min << endl;

	return 0;
}

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

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

  rep(i,n){
    rep(j,n){
      if(4*(i)+7*(j) == n){
        cout << "Yes";
        return 0;
      }
    }
  }

  cout << "No";
}


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

int main()
{
  int n,m,x;
  cin >> n >> m;
  priority_queue<int> qa;
  for(int i=0;i<n;++i){
    cin >> x;
    qa.push(x);
  }
  
  for(int i=0;i<m;++i){
    x=qa.top()/2;
    qa.pop();
    qa.push(x);
  }
  
  long ans=0;
  while(!qa.empty()){
    ans+=qa.top();
    qa.pop();
  }
  
  cout << ans;
  return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>


using namespace std;

int addnum(int num,int num2){
	int i;
	i=num/2;
	return num2+i;
}
int subnum(int hoge,int hoge2){
	int j;
	j=hoge/2;
	return hoge2-j;

}


int main(){

int a,b,k;
	cin>>a>>b>>k;
	int i=0;
	for(i=0;i<k/2;i++){
		if(a%2==1){
			b=addnum(a-1,b);
			a=subnum(a-1,a-1);
		}else{
			b=addnum(a,b);
			a=subnum(a,a);
		}
		
		if(b%2==1){
			a=addnum(b-1,a);
			b=subnum(b-1,b-1);
		
		}else{
			a=addnum(b,a);
			b=subnum(b,b);
		}
	}
	
	if(k%2==1){
	if(a%2==1){
			b=addnum(a-1,b);
			a=subnum(a-1,a-1);
		}else{
			b=addnum(a,b);
			a=subnum(a,a);
		}
	}
	
	
	
cout<<a<<" "<<b<<endl;

return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

struct Edge {
  int to, w;
};

using Graph = vector<vector<Edge>>;

Graph G;
vi color;

void dfs(int v, int p, int c) {
  color[v] = c;
  for (auto e : G[v]) {
    if (e.to == p) continue;
    if (e.w % 2)
      dfs(e.to, v, 1 - c);
    else
      dfs(e.to, v, c);
  }
}

int main() {
  int N;
  cin >> N;
  G.resize(N);
  rep(i, N - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].push_back(Edge{v, w});
    G[v].push_back(Edge{u, w});
  }

  color.assign(N, 0);
  dfs(0, -1, 1);

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

Measured memory_bytes: 8960
N = int(input())
arr = list(map(int, input().split()))
cnt = {}
sum_num = 0
for idx in arr:
    if idx in cnt:
        cnt[idx] += 1
    else:
        cnt[idx] = 1

for i in cnt.values():
    sum_num += i * (i - 1) // 2

for idx in arr:
    c = cnt[idx]
    ans = sum_num - c * (c - 1) // 2
    ans = ans + (c - 1) * (c - 2) // 2
    print(ans)


Measured memory_bytes: 26140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N;
  int64 W;
  cin >> N >> W;
  int64 inf = (int64)1e18 + 10;
  vector<int64> w(N + 1), v(N + 1);
  for (int64 i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  debug(w);
  debug(v);
  vector<vector<int64>> dp(N + 1, vector<int64>(304771, inf));
  dp[0][0] = 0;
  for (int64 i = 0; i < N; i++) {
    for (int64 j = 0; j < 304711; j++) {  // sum of the value
      dp[i + 1][j] = dp[i][j];
      if (j >= v[i]) dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
    }
  }
  int64 ans = 0;
  for (int64 i = 0; i < 304711; i++) {
    if (dp[N][i] <= W) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 243456
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define fi first
#define se second
const int inf = 1e9+7;
int mod = 1e9+7;

int v[100][11], a[100], n;
int dfs(int bit, int p){
	if(p == 10){
		if(bit == 0)return -inf;
		int sum = 0;
		rep(i,n){
			int t = __builtin_popcountll(a[i]&bit);
			sum += v[i][t];
		}
		return sum;
	}
	int ans = -inf;
	ans = max(ans, dfs(bit*2+1, p+1));
	ans = max(ans, dfs(bit*2, p+1));
	return ans;
}

signed main(){
	scanf("%lld", &n);
	rep(i,n)rep(j,10){
		int x;scanf("%lld", &x);
		a[i] = a[i]*2+x;
	}
	rep(i,n)rep(j,11)scanf("%lld", &v[i][j]);
	printf("%lld\n", dfs(0, 0));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N; cin >> N;
  ll X, L;
  vector<pair<ll,ll>> UD(N);
  rep(i,N){
    cin >> X >> L;
    UD[i] = {X+L, X-L};
  }
  sort(all(UD));

  int cnt = 0;
  ll U=UD[0].first;
  rep(i,N){
    if (i==0) cnt++;
    else if (UD[i].second < U) continue;
    else {
      cnt++;
      U = UD[i].first;
    }
  }

  cout << cnt << endl;

  
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define tp make_tuple
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
using namespace std;

int main()
{
    ll n,m,i,j,k,t;

    cin>>n;

    k=n%1000;

    if(k)k=1000-k;

    cout<<k<<endl;
}



Measured memory_bytes: 3652
S = list(input())
tmp = ''
line = ''
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp += s
    else:
        if len(tmp) > len(line): line = tmp
        tmp = ''
print(max(len(tmp), len(line)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	string s;
	cin >> n >> s;


	vs a0 = { "S","W","S","W" };
	vs a1 = { "S","S","W","W" };
	string ans = "";

	rep(k,4){
		
		vs t(n + 2, "");
		t[0] = a0[k];
		t[1] = a1[k];

		rep1(i, n) {
			if ((s[i - 1] == 'o') ^ (t[i] == "W"))t[i + 1] = t[i - 1];
			else if (t[i - 1] == "S")t[i + 1] = "W";
			else t[i + 1] = "S";
		}

		if (t[0] == t[n] && t[1] == t[n + 1]) {
			rep1(i, n)ans += t[i];break;
		}
	}

	if (ans == "")cout << -1 << endl;
	else cout << ans << endl;

}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
ll mod=1e9+7;


int main(){

  ll n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll ans=0;
  ll t=0;
  ll sum=0;
  ll l=0;
  rep(i,n){
    if((t^a[i])==(sum+a[i])){
      ans+=(i-l+1);
      t^=a[i];
      sum+=a[i];	
    }
    else {
      t^=a[l];
      sum-=a[l];
      i--;
      l++;
    }
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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 K, X;
  cin >> K >> X;
  if (500*K >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    vector<int>a(A);
    vector<int>b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    int miA = *min_element(a.begin(), a.end());
    int miB = *min_element(b.begin(), b.end());
    int price = miA + miB;
    rep(i, M){
        int x, y, c;
        cin >> x >> y >> c;
        price = min(price, a[x-1]+b[y-1]-c);
    }
    cout << price << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s,ss;

bool check(ll n){
    s="";
 while(n!=0){
    s.push_back(n%10+'0');
    n=n/10;
 }
 ll len=s.size();
 if(len%2==0)return false;
 else return true;

}



int main()
{
    ll r,i,j,mx,m,ans=0,a,b,c=0;
    while(cin>>a){
            c=0;
        for( i=1;i<=a;i++){
            if(check(i)==1)c++;
        }
        cout<<c<<endl;
    }


    return 0;
}



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

int main() {
    int n;
    cin >> n;
    long long a[200200], cnt_a = 0, cnt_b = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt_b += a[i];
    }

    long long ans = 1LL<<60;
    for (int i = 0; i < n - 1; i++) {
        cnt_a += a[i];
        cnt_b -= a[i];
        ans = min(ans, abs(cnt_a - cnt_b));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<(a%b==0 ? a/b : a/b+1)<<endl;
return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
using namespace std;



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

    if(a <= b)
    {
        for(int i = 0; i < b; i++)
        {
            cout << a;
        }
        cout << endl;
    }
    else
    {
        for(int i = 0; i < a; i++)
        {
            cout << b;
        }
        cout << endl;
    }


    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<deque>
#include<functional>
#include<ctime>
#include<cassert>
#include<cstring>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double ld;
typedef vector<int> vi;

template<class T> bool uin(T &a, T b){ return (a > b ? a = b, true : false); }
template<class T> bool uax(T &a, T b){ return (a < b ? a = b, true : false); }

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

int const N = 1e5 + 41;
int const M = 2e5 + 41;

int w[N], g[N];
int n, m;
vector<pii> e[N];
int deg[N];

void bad(){
	printf("No\n");
	exit(0);
}

void dfs(int x){
	w[x] = 1;
	for(pii p : e[x]){
		int y = p.first;
		if(w[y] == 2) continue;
		if(w[y] == 1) bad();
		dfs(y);
	}
	w[x] = 2;
}

int main(){
#ifdef LOCAL_DEFINE
	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
#endif

		scanf("%d %d",&n,&m);
		fi(0, m){
			int x, y, z;
			scanf("%d %d %d",&x,&y,&z);
			--x;--y;
			e[x].pb(mp(y, z));
			++deg[y];
		}

		vi st;
		fi(0, n){
			if(deg[i] == 0) st.pb(i);
		}
		while(sz(st)){
			int x = st.back();
			st.pop_back();
			for(pii p : e[x]){
				int y = p.first;
				int g0 = g[x] + p.second;
				if(!w[y]){
					w[y] = 1;
					g[y] = g0;
				}else{
					if(g[y] != g0) bad();
				}
				--deg[y];
				if(deg[y] == 0) st.pb(y);
			}
		}

		memset(w, 0, sizeof(w));
		fi(0, n) if(!w[i]) dfs(i);

		printf("Yes\n");

	
#ifdef LOCAL_DEFINE
	fprintf(stderr, "ELAPSED TIME: %.3lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 9856
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n;
  cin>>n;
  string s[200000],a[200000];
  int num[200000];

  
  for(int i=0;i<n;i++){
    cin>>s[i];
    num[i]=0;
  }
  sort(s,s+n);
  int j=0;
  for(int i=0;i<n;i++){
    if(i==0){
      a[j]=s[i];
      num[j]+=1;
    }else if(s[i]==s[i-1]){
      num[j]+=1;
    }else{
      j++;
      a[j]=s[i];
      num[j]+=1;
    }
    }
  j++;
  //cout<<j;
  int max=*max_element(num,num+j);
  
  for(int i=0;i<j;i++){
    //cout<<num[i]<<a[i];
    if(num[i]==max){
       cout<<a[i]<<endl;
      }
  }

  return 0;
}


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

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


int main(){

  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  rep(i,n){
    ll x,y;
    cin >> x >> y;
    if(x*x+y*y <= d*d){

      ans ++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			final int s = sc.nextInt() - 1;
			final int g1 = sc.nextInt() - 1;
			final int g2 = sc.nextInt() - 1;
			
			if(n == 0 && m == 0 && s == -1 && g1 == -1 && g2 == -1){
				break;
			}
			
			
			int[][] adj = new int[n][n];
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(i != j){
						adj[i][j] = Integer.MAX_VALUE / 4;
					}
				}
			}
			
			for(int i = 0; i < m; i++){
				final int b1 = sc.nextInt() - 1;
				final int b2 = sc.nextInt() - 1;
				final int c = sc.nextInt();
				
				adj[b1][b2] = c;
			}
			
			for(int k = 0; k < n; k++){
				for(int i = 0; i < n; i++){
					for(int j = 0; j < n; j++){
						adj[i][j] = Math.min(adj[i][j], adj[i][k] + adj[k][j]);
					}
				}
			}
			
			int min = Integer.MAX_VALUE;
			
			for(int k = 0; k < n; k++){
				final int s_cost = adj[s][k];
				final int g1_cost = adj[k][g1];
				final int g2_cost = adj[k][g2];
				
				min = Math.min(min, s_cost + g1_cost + g2_cost);
			}
			
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 63036