akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  set<string> S;
  string s;
  cin>>s;
  int k;
  cin>>k;
  REP(head,s.size()){
    FOR(len,1,6)if(head+len<=s.size())S.insert(s.substr(head,len));
  }
  REP(i,k-1)S.erase(S.begin());
  cout<<(*S.begin())<<endl;
  return 0;
}


Measured memory_bytes: 1664
w = str(input())
w =sorted(w)
import string
alp = str(string.ascii_lowercase)
c = []
for i in range(len(alp)): 
  c.append(0)
for i in range(len(alp)):
  W = alp[i]
  for j in range(len(w)):
    if W == w[j]:
      c[i] += 1
if c.count(0) == 0:
  print('None')
else:
  for i in range(len(c)):
    if c[i] == 0:
      print(alp[i])
      break

Measured memory_bytes: 49904
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k;
int x[100001],y[100001];
bool c[100001];
char s;
int h[10001];
int  main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d %c",&x[i],&y[i],&s);
		x[i]=x[i]%(2*k);
		y[i]=y[i]%(2*k);
		if(s=='B')
			c[i]=1;
	}
	int maxn=0,cnt;
	for(int i=0;i<=k;i++)
	{
		cnt=0;
		memset(h,0,sizeof(h));
		for(int j=1;j<=n;j++)
		{
			int p=(i<=x[j]&&x[j]<i+k);
			int q=(0<=y[j]&&y[j]<k);
			if(p^q==c[j])
			{
				cnt++;
				h[y[j]]++;
			}
			else
				h[y[j]]--;
		}
		for(int j=0;j<=k;j++)
		{
			maxn=max(max(cnt,n-cnt),maxn);
			if(j!=k)
				cnt=cnt-h[j]-h[k+j];
		}
	}
	printf("%d\n",maxn);
}

Measured memory_bytes: 1152
/*
 * ALDS1_5_A.cpp
 *
 *  Created on: Apr 27, 2018
 *      Author: 13743
 */

#include<iostream>

using namespace std;

int n;
int A[20];

bool makeSum(int i, int x) {
	if(x == 0) return true;
	if(i == n) return false;
	bool b1 = makeSum(i+1, x-A[i]);
	bool b2 = makeSum(i+1, x);
	return b1 || b2;
}

int main() {
	int q;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> A[i];
	}
	cin >> q;
	for(int i=0; i<q; i++) {
		int x;
		cin >> x;
		if(makeSum(0, x)) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
}





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

int main()
{
  long long n, p, c;
  std::cin >> n>> p>>c;
  std::vector<long long> score(n, p-c);
  for (int i = 0; i < c; i++)
  {
    int y;
    std::cin>>y;
    score[y-1]++;
    // for (long long j = 0; j < n; j++)
    // {
    //   if(j!=(y-1)){
    //     score[j]--;
    //   }
    // }
  }
  for(const auto& s: score)
  {
    if(s<=0)
    {
      std::cout << "No" << std::endl;
    }
    else
    {
      std::cout << "Yes" << std::endl;
    }

  }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
signed main(){
    int n,m;
    cin >> n >> m;
    using tp = tuple<int,int>;
    vector<tp>v;
    for(int i = 0; i < n; ++i){
        int day, reward;
        cin >> day >> reward;
        v.emplace_back(day, reward);
    }
    vector<int>ans;
    sort(v.begin(),v.end());
    priority_queue<int,vector<int>>que;
    size_t idx = 0;
    for(int d = 1 ; d <= m; ++d){
        for(;d == get<0>(v[idx]);++idx){
            int reward = get<1>(v[idx]);
            que.push(reward);
        }
        if(not que.empty()){
            ans.push_back(que.top());
            que.pop();
        }
    }
    cout << accumulate(ans.begin(),ans.end(),0LL) << endl;
}



Measured memory_bytes: 4464
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=998244353;	

signed main(){
	llin(n);
	vllin(v,n);
	vllin(c,n);
	ll a=0;
	FOR(i,0,n-1){
		if(v[i]-c[i]>0){
			a+=v[i]-c[i];
		}
	}
	sal(a);
}


Measured memory_bytes: 256
import qualified Data.IntSet as S

main :: IO ()
main = print =<< solve <$> readLn

solve :: Int -> Int
solve n = go (S.singleton 0)
  where
    go s
      | n `S.member` s = 0
      | otherwise      = 1 + go s'
      where
        s' = S.filter (<= n) $ S.unions [ S.map (+w) s | w <- ws ]

    ws = 1 : [ 6 ^ p | p <- [1..6] ] ++ [ 9 ^ p | p <- [1..7] ]

Measured memory_bytes: 2428
# -*- coding: utf-8 -*-

def calc(al, n):
    res = 0
    r = 0
    tmpsum = 0
    tmpxor = 0
    for l in range(n):
        while r<n and tmpsum+al[r]==tmpxor^al[r]:
            tmpsum += al[r]
            tmpxor ^= al[r]
            r += 1

        res += (r-l)

        if r==l:
            r += 1
        else:
            tmpsum -= al[l]
            tmpxor ^= al[l]

    return res


n = int(input())
al = list(map(int, input().split()))

print(calc(al,n))


Measured memory_bytes: 24712
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 + (y1 - y2)
y3 = y2 - (x1 - x2)

x4 = x3 + (x1 - x2)
y4 = y3 + (y1 - y2)

print(*[x3, y3, x4, y4])

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

int main() {
    string S;
    cin >> S;
    int diff = 753;
    for (int i=0; i<=S.size()-3; ++i) {
        string d = S.substr(i, 3);
        int X = stoi(d);
        diff = min(abs(X-753), diff);
    }

    cout << diff << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b,ans;
    while(cin>>n){
        ans=0;
        while(n--){
            cin>>a>>b;
            ans+=b-a+1;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String
    }
    let result = match &*s {
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => ""
    };
    println!("{}", result);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			String t = sc.next();
			long a = sc.nextLong();
			long b = sc.nextLong();
			String u = sc.next();
			if (s.equals(u)) {
				a = a - 1;
			}
			if (t.equals(u)) {
				b = b - 1;
			}
			System.out.println(a + " " + b);
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

vector<pair<int, int>> a;

int res = 0;
void go(int l, int r) {
  for (int cl = l; cl < r; ++cl) {
    if (a[cl].second == 1)
      continue;
    int cr = min(cl + 2, r);
    while (cr < r && a[cr - 1].first != 1)
      ++cr;
    ++res;
    for (int i = cl; i < cr; ++i) {
      int u = a[i].first;
      int v = a[i].second;
      a[i].first = u / 2;
      a[i].second = (v + 1) / 2;
      assert(a[i].second - a[i].first <= 1);
    }
    go(cl, cr);
    cl = cr - 1;
  }
}

signed main() {
#ifdef LOCAL
  assert(freopen("f.in", "r", stdin));
#endif
  int n;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = a[i].first;
  }
  go(0, n);
  cout << res << '\n';
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

void solve()
{
	int m;
	cin >> m;
	while(m--)
	{
		int a, year, n;
		int max = 0;
		cin >> a;
		cin >> year >> n;
		for(int i = 0; i < n; ++i)
		{
			int price = a;
			int method, charge;
			double interest;
			cin >> method;
			cin >> interest;
			cin >> charge;
			if(method == 1)
			{
				for(int j = 0; j < year; ++j)
				{
					price += price * interest - charge;
				}
				if(max < price)
				{
					max = price;
				}
			}
			else if(method == 0)
			{
				int temp = 0;
				for(int j = 0; j < year; ++j)
				{
					temp += price * interest;
					price -= charge;
				}
				price += temp;
				if(max < price)
				{
					max = price;
				}
			}
		}
		cout << max << endl;
	}
}

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

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll h,w;
	cin >> h >> w;

	ll ans = h*w;

	if(h%3==0)
		chmin(ans,0LL);
	else
		chmin(ans,w);

	if(w%3==0)
		chmin(ans,0LL);
	else
		chmin(ans,h);
		
	rep(i,1,h){
		const ll a = 1LL * i * w;
		const ll b = 1LL * (h-i) * (w/2LL);
		const ll c = 1LL * (h-i) * (w-w/2LL);
		chmin(ans,max({a,b,c})-min({a,b,c}));
	}

	rep(j,1,w){
		const ll a = 1LL * h * j;
		const ll b = 1LL * (h/2LL) * (w-j);
		const ll c = 1LL * (h-h/2LL) * (w-j);
		chmin(ans,max({a,b,c})-min({a,b,c}));
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,m,v,p,a[100001],tot;
ll sum[100001];
int main()
{
	read(n),read(m),read(v),read(p);
	for(res i=1;i<=n;++i) read(a[i]);
	sort(a+1,a+1+n),reverse(a+1,a+1+n);
//	for(res i=1;i<=n;++i) print(a[i],' ');puts("");
	for(res i=1;i<=n;++i) sum[i]=sum[i-1]+a[i];
	tot=p;
	for(res i=p+1;i<=n;++i) if(v<=p) {
		if(a[i]+m>=a[p]) ++tot;
	}
	else if(v-p<=n-i) {
		if(a[i]+m>=a[p]) ++tot;
	}
	else {
		if(a[i]+m<a[p]) continue;
		ll now=(ll)m*(v-p-n+i);
		if(((ll)a[i]+m)*(i-p)-(sum[i-1]-sum[p-1])>=now) ++tot;
	}
	print(tot,'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vll x(n);
    rep(i, n) cin >> x[i];
    vll path(n);
    ll l, q;
    cin >> l >> q;
    rep(i,n-1){
        ll idx = upper_bound(all(x), x[i] + l) - x.begin();
        idx--;
        path[i] = idx;
    }
    path[n - 1] = n;
    vector<pll> query;
    map<int, pll> que_idx;
    rep(i,q){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        if (a<b)
            swap(a, b);
        query.eb(mp(a, b));
        que_idx[i] = mp(a, b);
    }
    map<pll, int> ans;
    vll goal(n, -1);
    vll dist(n, -1);
    goal[n - 1] = n - 1;
    dist[n - 1] = 0;
    //query：bからaに行くというクエリ
    //終点の昇順で考える。
    sort(all(query));
    rep(i,q){
        int a = query[i].S, b = query[i].F;
        int now = a, cnt = 0;
        vector<pll> visited;
        //どこからどれだけ移動したか
        while (now<b){
            //goalを使うと必ずb以前につくから気にせず使う（スキップすることはない）
            if (goal[now]!=-1){
                visited.eb(mp(now, dist[now]));
                cnt += dist[now];
                now = goal[now];
            }
            else{
                visited.eb(mp(now, 1));
                cnt++;
                now = path[now];
            }
        }
        ans[query[i]] = cnt;
        rep(j,visited.size()){
            goal[visited[j].F] = now;
            dist[visited[j].F] = cnt;
            cnt -= visited[j].S;
        }
    }
    rep(i, q) cout << ans[que_idx[i]] << ENDL;
}

Measured memory_bytes: 18288
# coding: utf-8
# Your code here!
h,w = [int(i) for i in input().split()]

def once(h,w):
    res = 10**9
    if h > 1:
        a,b = h//2*w, (h-h//2)*w
        res = abs(a-b)
    if w > 1:
        c,d = w//2*h, (w-w//2)*h
        if abs(c-d) < res:
            a,b = c,d
    return a,b    


def hsaki(h,w):
    res = 10**9
    for i in range(1,h):
        p1 = i*w
        p2,p3 = once(h-i,w)
        a = max(p1,p2,p3) - min(p1,p2,p3) 
        res = min(res, a)
#        print(p1,p2,p3)
    return res

#print(hsaki(h,w), hsaki(w,h))

ans = min(hsaki(h,w), hsaki(w,h))
print(ans)

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

using ll = long long;
using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int H, N;
vector<int> A, B;
vector<vector<ll>> dp(1010, vector<ll>(10010, INF));

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

    cin >> H >> N;
    A.resize(N); B.resize(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
    }

    dp[0][0] = 0;



    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= H; j++) {
            chmin(dp[i + 1][j], dp[i][j]);
            if (j + A[i] >= H) {
                chmin(dp[i + 1][H], dp[i + 1][j] + B[i]);
            } else {
                chmin(dp[i + 1][j + A[i]], dp[i + 1][j] + B[i]);
            }

        }
    }

    cout << dp[N][H] << endl;



    return 0;
}

Measured memory_bytes: 82716
#include<iostream>

using namespace std;

const int MAXN = 100005;

int n, naso;
string out="SW";
char c;
int l[MAXN];
int p[MAXN];

void probaj (int a, int b) {
	p[0]=a; p[1]=b;
	p[n-1]=p[0]^p[1]^l[0];
	for (int i=n-2; i>=2; i--) {
		int x=i+1, y=(i+2)%n;
		p[i]=p[x]^p[y]^l[i+1];
	}
}

bool check () {
	for (int i=0; i<n; i++) {
		int x=(i+1)%n, y=(i+2)%n;
		if (p[i]^p[x]^p[y]!=l[x]) return 0;
	}
	return 1;
}

void ispis () {
	for (int i=0; i<n; i++) {
		cout << out[p[i]];
	}
}

int main () {
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> c;
		l[i]=(c=='x');
	}
	probaj(0, 0); if (!naso && check()) {ispis(); naso=1;}
	probaj(0, 1); if (!naso && check()) {ispis(); naso=1;}
	probaj(1, 0); if (!naso && check()) {ispis(); naso=1;}
	probaj(1, 1); if (!naso && check()) {ispis(); naso=1;}
	if (!naso) cout << -1;
	return 0;
}






Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    vll b(n);
    rep(i, n){
        cin >> b[i];
    }
    vll c(n-1);
    rep(i, n-1){
        cin >> c[i];
    }
    ll ans = accumulate(ALL(b), 0ll);
    rep(i, n-1){
        if(a[i+1] == a[i]+1){
            ans += c[a[i]-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int N;  cin >> N;
  vi A(N),  B(N-1);
  REP(i, N-1) cin >> B[i];
  A[0] = B.front();
  A[N-1] = B.back();
  for(int i=1; i<N-1; i++){
    A[i] = min(B[i], B[i-1]);
  }
  int ans = 0;
  REP(i, N) ans+=A[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
M, N = map(int,input().split(' '))

if M == 1 and N == 1:
    print(1)
elif M == 1:
    print(N - 2)
elif N == 1:
    print(M - 2)
else:
    print(M * N - ((M * N) - ((M - 2) * (N - 2))))


Measured memory_bytes: 2940
package main

import "fmt"

func main() {
	var s, p string
	fmt.Scan(&s, &p)
	for i := range s {
		ok := true
		for j, c := range p {
			if rune(s[(i+j)%len(s)]) != c {
				ok = false
				break
			}
		}
		if ok {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}



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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*funcs*/

/*input*/
int a,b,c;

/*main*/
int main(){
    cin>>a>>b>>c;
    if(a<c&&c<b){
        cout<<"Yes";
    }else if(b<c&&c<a){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,M,K; cin >> N >> M >> K;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      int num = i*M+j*N-2*i*j;
      if(num==K){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int MAXN = 1e5 + 10, MOD = 1e9 + 7;

inline int add(int x, int y){
	return (x + y) % MOD;
}

ll a[MAXN], dp[MAXN][2], ps[MAXN][2];

int main(){
	int n;
	ll A, B;
	cin >> n >> A >> B;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	dp[0][0] = 1;
	dp[0][1] = 1;
	ps[0][0] = 1;
	ps[0][1] = 1;
	int l1 = 0, l2 = 0;
	for(int i = 1; i < n; i++){
		int id1 = upper_bound(a, a + i - 1, a[i] - A) - a;
		int id2 = upper_bound(a, a + i - 1, a[i] - B) - a;
		if(id2 >= l2)
			dp[i][0] = add(dp[i][0], ps[id2][1]);
		if(id1 >= l1)
			dp[i][1] = add(dp[i][1], ps[id1][0]);
		//cerr << dp[i][0]  << "    " << dp[i][1] << endl;
		ps[i][0] = dp[i][0];
		ps[i][1] = dp[i][1];
		if(a[i] - a[i - 1] < A)
			l2 = i;
		else
			ps[i][1] = add(ps[i][1], ps[i - 1][1]);
		if(a[i] - a[i - 1] < B)
			l1 = i;
		else
			ps[i][0] = add(ps[i][0], ps[i - 1][0]);
		//cerr << dp[i][0] << "    " << dp[i][1] << "                " << l1 << "   " << id1 << endl;
	}
	cout << add(ps[n - 1][0], ps[n - 1][1]) << endl;
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#define ll long long
#define mp make_pair
using namespace std;
int n,m,bg,ed;
vector<int> v[100005];
int dp[100005][3];
inline void bfs()
{
	memset(dp,63,sizeof(dp));
	dp[bg][0]=0;
	queue<pair<int,int> >q;
	pair<int,int> p;
	q.push(mp(bg,0));
	while(!q.empty())
	{
		p=q.front();
		q.pop();
		int u=p.first,x=p.second,y=(x+1)%3;
		if(u==ed and x%3==0){
			cout<<x/3<<endl;
			return;
		}
		for(int i=0;i<v[u].size();++i)
		{
			int t=v[u][i];
			if(dp[t][y]>x+1){
				dp[t][y]=x+1;
				q.push(mp(t,x+1));
			}
		}
	}
	cout<<-1<<endl;
}
int main()
{
	int i,j,x,y;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;++i)
		scanf("%d%d",&x,&y),v[x].push_back(y);
	scanf("%d%d",&bg,&ed);
	bfs();
}

Measured memory_bytes: 6912
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int R = sc.nextInt(), C = sc.nextInt(), K = sc.nextInt();
        int[][] board = new int[R + 1][C + 1];
        for (int i = 0; i < K; i++) {
            board[sc.nextInt()][sc.nextInt()] = sc.nextInt();
        }

        long[][][] dp = new long[R + 1][C + 1][4];

        for (int r = 1; r <= R; r++) {
            for (int c = 1; c <= C; c++) {
                dp[r][c][0] = max(dp[r - 1][c]);
                dp[r][c][0] = max(dp[r][c][0], dp[r][c - 1][0]);
                dp[r][c][1] = max(dp[r - 1][c]) + board[r][c];
                dp[r][c][1] = max(dp[r][c][1], dp[r][c - 1][1], dp[r][c - 1][0] + board[r][c]);
                dp[r][c][2] = max(dp[r][c - 1][2], dp[r][c - 1][1] + board[r][c]);
                dp[r][c][3] = max(dp[r][c - 1][3], dp[r][c - 1][2] + board[r][c]);
            }
        }

        out.println(max(dp[R][C]));

        out.flush();
    }

    long max(long...vals) {
        long max = 0;
        for (long v : vals) {
            max = Math.max(max, v);
        }
        return max;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 812392
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    int pos = 0;
    for(int i = 0; i < n; ++i){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] != 0)   pos = i;
    }
    for(int cx = 0; cx <= 100; ++cx){
        for(int cy = 0; cy <= 100; ++cy){
            int H = h[pos] + abs(x[pos] - cx) + abs(y[pos] - cy);
            bool ok = true;
            for(int i = 0; i < n; ++i){
                if(i == pos)    continue;
                int foo = max(0, H - abs(x[i] - cx) - abs(y[i] - cy));
                if(foo != h[i]){
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    LL n;
    cin>>n;
    VL a(n),b(n);
    REP(i,n){
      cin>>a[i]>>b[i];
    }
    SORT_ASC(a);
    SORT_ASC(b);

    if(n%2==1){
      LL small=a[n/2];
      LL large=b[n/2];
      cout<< large-small+1<<endl;
    }
    else{
      LL small1=a[n/2-1];
      LL small2=a[n/2];
      LL large1=b[n/2-1];
      LL large2=b[n/2];
      cout<< (large1-small1+1) + (large2-small2) <<endl;


    }


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 6352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    char table[100100];
    int ok = 0;
    int ng = n;
    cout << 0 << endl;
    string initial;
    cin >> initial;
    if(initial == "Vacant"){
        return 0;
    }
    if(initial == "Male"){
        table[0] = 'M';
    } else {
        table[0] = 'F';
    }
    while(true){
        int checker = (ok + ng) / 2;
        cout << checker << endl;
        string in;
        cin >> in;
        if(in == "Vacant"){
            return 0;
        }
        if(in == "Male"){
            table[checker] = 'M';
        } else {
            table[checker] = 'F';
        }
        if(!((table[checker] == table[ok]) ^ ((checker - ok) % 2 == 0))){
            ok = checker;
        } else {
            ng = checker;
        }
    }
    return 0;
}

Measured memory_bytes: 852
#include<stdio.h>
main(){
#define nMAX 100000
#define qMAX 50000
  int n, q, S[nMAX], T[qMAX], i, l, r, m, key, c=0;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
  }
  
  for(i = 0; i < q; i++){
    key = T[i];
    l = 0;
    r = n;
    while(l < r){
      m = (l+r)/2;
      if(S[m] == key){
	c++;
	break;
      }
      else if(key < S[m]){
	r = m;
      }
      else{
	l = m+1;
      }
    }
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())

int main() {
  int num; cin>>num;
  vi dod(num); rep(i,num) cin>>dod.at(i);
  soao(dod);
  cout<<dod.at(num/2)-dod.at(num/2-1)<<endl;
}
  


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

vector<LL> fact, finv, inv;

void init_nCk(int N) {
  fact.resize(N + 1);
  finv.resize(N + 1);
  inv.resize(N + 1);
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= N; i++) {
    fact[i] = fact[i - 1] * i % kMod;
    inv[i] = kMod - inv[kMod % i] * (kMod / i) % kMod;
    finv[i] = finv[i - 1] * inv[i] % kMod;
  }
}

LL nCk(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (finv[k] * finv[n - k] % kMod) % kMod;
}

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

  int a = 2 * X - Y, b = 2 * Y - X;
  if (a % 3 != 0 || b % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  a /= 3; b /= 3;

  init_nCk(a + b);
  cout << nCk(a + b, a) << endl;
}


Measured memory_bytes: 15872
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int h, r;
	cin >> h >> r;
	if (h < 0) {
		if (abs(h) == r)cout << 0 << endl;
		else cout << -1 << endl;
	}
	else
		cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int main(void) {
	int a,b,c,d,n,i;
	while(scanf("%d",&n) != EOF){
	i = 0;
	for(a = 0; 10 > a; a++){
		for(b = 0; 10 > b; b++){
	for(c = 0; 10 > c; c++){
	for(d = 0; 10 > d; d++){
		if(a+b+c+d == n)i++;
	}	
	}	
	}
	}
	printf("%d\n",i);
	}
	
	return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	l := make([]int, n+1)

	for i := 1; i < n+1; i++ {
		l[i] = nextInt()
	}

	cnt := 0
	for i := 1; i < n+1; i++ {
		if i%2 == 1 && l[i]%2 == 1 {
			cnt++
		}
	}

	fmt.Println(cnt)
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char buf = 'e';
            foreach(char a in s)
            {
                if(buf == a)
                {
                    Console.WriteLine("Bad");
                    return;
                }
                else
                {
                    buf = a;
                }
            }
            Console.WriteLine("Good");

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int n;
priority_queue<double, vector<double>, greater<double>> pq;

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		double ai;
		scanf("%lf", &ai);
		pq.push(ai);
	}
	double aux = 0;
	while((int)pq.size()>1){
		double u = pq.top(); pq.pop();
		double v = pq.top(); pq.pop();
		//printf("---> %.2lf %.2lf\n", u , v);
		aux = (u+v)/2.0;
		pq.push(aux);
	}
	double ans = pq.top();
	printf("%.5lf\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//__builtin_popcount(n)
using pi = pair<int,int>;
signed main(){
	int n; cin>>n;
	vector<vector<pi>> vec(n,vector<pi>(0));
	rep(i,0,n){
		int a; cin>>a;
		rep(j,0,a){
			int x,y; cin>>x>>y;
			--x;
			vec[i].push_back(make_pair(x,y));
		}
	}
	int ans=0;
	rep(i,0,1<<n){
		bool ok=true;
		rep(j,0,n){
			if(i>>j&1){
				for(auto c:vec[j]){
					int a=c.first,b=c.second;
					if(((i>>a)&1)==b);
					else ok=false;
				}
			}
		}
		if(ok)chmax(ans,__builtin_popcount(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
/**
AHMAD;HASSAN;SAEED
*/
using namespace std;


int main()
{
    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }

    cout<<"AC x "<<mp["AC"]<<'\n';
    cout<<"WA x "<<mp["WA"]<<'\n';
    cout<<"TLE x "<<mp["TLE"]<<'\n';
    cout<<"RE x "<<mp["RE"]<<'\n';
/**
10
9
2 0 1 1 2 4 4 2 0
*/
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define loop(i,n)for(i=0;i<n;i++)
#define INF 1000000000
using ll = long long int;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;


#define MAX 100005


int main()
{
    IOS;
    //freopen("inputfile.txt","r",stdin);
 ll l,n;cin>>l>>n;
 map<ll,ll>ac,wa;
 int a=0,w=0;
 for(ll i=0;i<n;i++)
 {
     ll k;string s;
     cin>>k>>s;
     if(ac[k]==1)continue;
     else if(s=="AC")
     {
         ac[k]=1;
         a++;
         w+=wa[k];
     }
     else if(s=="WA")wa[k]++;
 }
 cout<<a<<" "<<w<<endl;
    return 0;
}


Measured memory_bytes: 16080
import java.util.*;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        int[] or = new int[n];
        int sum = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = n - 1; i >= 0; i--) {
            sum = 0;
            int m = i + 1;
            for (int j = m - 1; j < n; j += m) {
                if (or[j] == 1)
                    sum++;
            }
            if (sum % 2 != a[i]) {
                or[i] = 1;
            }
        }
        for (int i = 0; i < n; i++) {
            if (or[i] == 1)
                count++;
        }
        if (count != 0) {
            System.out.println(count);
            for (int i = 0; i < n; i++) {
                if (or[i] == 1)
                    System.out.print(i + 1 + " ");
            }
            System.out.println();
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 66072
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    string S;
    cin >> S;
    map<char, int> m, mm;
    for (auto x: S) {
        m[x]++;
    }
    int ans = 0;
    for (auto x: S) {
        m[x]--;
        mm[x]++;
        int k = 0;
        for (auto y: m) {
            if (y.second && mm[y.first]) {
                k++;
            }
        }
        ans = max(ans, k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();

            if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
                out.println("Yes");

            } else {
                out.println("No");
            }

        }

    }
}



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
typedef pair<int,int> P;
#define INF 10000000

int main()
{
  int h,w;cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  int i,j;
  rep(i,h)rep(j,w)cin>>a[i][j];
  vector<vector<int>> mins(h,vector<int>(w,INF));
  queue<P> q;
  rep(i,h)rep(j,w)
  {
    if(a[i][j]=='#')
    {
      mins[i][j]=0;
      q.push({i,j});
    }
  }
  queue<P> q2;
  vector<int> dh={0,1,0,-1};
  vector<int> dw={1,0,-1,0};
  while(!q.empty())
  {
    while(!q.empty())
    {
      P nowp=q.front();
      q.pop();
      int ni=nowp.first;
      int nj=nowp.second;
      rep(i,4)
      {
        int toi=ni+dh[i];
        int toj=nj+dw[i];
        if(toi<0||toi>=h||toj<0||toj>=w)continue;
        if(mins[toi][toj]==INF)
        {
          mins[toi][toj]=mins[ni][nj]+1;
          q2.push({toi,toj});
        }
      }
    }
    while(!q2.empty())
    {
      q.push(q2.front());
      q2.pop();
    }
  }
  int ans=0;
  rep(i,h)rep(j,w)ans=max(ans,mins[i][j]);
  cout<<ans<<endl;
} 


Measured memory_bytes: 13328
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll N;
	std::cin >> N;

	set<string> s;
	string S;
	rep(i, 0, N) {
		std::cin >> S;
		s.insert(S);
	}

	std::cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 19148