akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;

int main()
{
    int x;
    while(~scanf("%d", &x)) {
        int i;
        for(i = 1; ; i++) {
            if(i * i + i >= 2 * x) break;
        }
    printf("%d\n", i);
    }
    return 0;
}


Measured memory_bytes: 128
import sys
A, B, C, D = map(int, input())
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            tmp = A
            if op1 == '+':
                tmp += B
            else:
                tmp -= B
            if op2 == '+':
                tmp += C
            else:
                tmp -= C
            if op3 == '+':
                tmp += D
            else:
                tmp -= D
            if tmp == 7:
                print("{}{}{}{}{}{}{}=7".format(A,op1,B,op2,C,op3,D))
                sys.exit()
                  

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> l(n);
	int sum = 0, mx = 0;
	rep(i,n){
		cin >> l[i];
		sum += l[i];
		chmax(mx, l[i]);
	}
	if(mx < sum - mx) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define doublearray vector<vector<int>>
#define mod 998244353 
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
int binaryS(ll x, ll sb[], int m){
    int l = 0, r=m;
    int mid = (l+r)/2;
    while(l<r){
        mid = (l+r)/2;
        if(sb[mid]<x) l= mid+1;
        else if(sb[mid]>x) r = mid-1;
        else return mid;
    }
    return l;
}
int main(){
    fastio;
    int n; cin>>n;
    um mp; ll sum = 0;
    rep(i,0,n){ int x; cin>>x; sum += (ll)x; mp[x]++; }
    int q; cin>>q;
    rep(i,0,q){
        int x, y; cin>>x>>y;
        sum += (y-x)*mp[x];
        mp[y] += mp[x];
        mp[x] = 0;
        cout<<sum<<endl;
    }
    return 0;
}





Measured memory_bytes: 7116
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1'000'000'007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(x,y);
    
    
    out((((x*y)%2)?"Yes":"No"));
}


Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W >> N;
	map<pair<int, int>, int>m;
	for (int i = 0; i < N; i++) {
		cin >> K >> Q;
		for (int j = -1; j <= 1; j++) {
			for (int k = -1; k <= 1; k++) {
				if (K + j >= 2 && K + j < H&&Q + k >= 2 && Q + k < W) {
					m[{K + j, Q + k}]++;
				}
			}
		}
	}
	long long int ret[10] = {};
	ret[0] = (H - 2)*(W - 2);
	for (auto i : m) {
		ret[i.second]++;
		ret[0]--;
	}
	
	for (int i = 0; i <= 9; i++) {
		cout << ret[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 56576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
	cin >> n;
	vector<ll> a(n),b(n);
	rep(i,n)cin >> a[i];
	rep(i,n)cin >> b[i];
	bool ok = true;
	if(n == 1){
		if(a[0] != b[0])ok = false;
	}
	vector<bool> f(n,false);
	vector<ll> MIN(n,INF);
	f[0] = true;
	f[n-1] = true;
	rep(i,n-1){
		if(a[i]<a[i+1]){
			f[i+1] = true;
			if(a[i+1]>b[i+1])ok = false;
		}
		MIN[i] = min(MIN[i],a[i]);
	}
	for(int i = n-1;i>=1;i--){
		if(b[i-1]>b[i]){
			f[i-1] = true;
			if(a[i-1]<b[i-1])ok = false;
		}
		MIN[i] = min(MIN[i],b[i]);
	}
	ll ans = 1;
	rep(i,n){
		if(!f[i]){
			ans *= MIN[i];
			ans %= MOD;
		}
	}
	if(ok)cout << ans << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 2560
n=int(input())
h=list(map(int,input().split()))
H=h[::-1]
t=H[0]

for i in range(1,n):
  if H[i]>t+1:
    print("No")
    break
  
  else:
    t=min(H[i],t)

else:
  print("Yes")

Measured memory_bytes: 14396
//#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#include<iostream>
#include<string>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int sum_of_digits(int x)
{
    int ret = 0;
    while(x)
    {
        ret += x%10;
        x/=10;
    }
    return ret;
}

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    Forn(i, n)
    {
        int temp = sum_of_digits(i);
        if(a<=temp && temp<=b) ans += i;
    }
    cout << ans << endl;
}


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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    auto v = Read(n);

    ll q;
    cin >> q;

    REP(i, q) {
        ll b, m, e;
        cin >> b >> m >> e;
        rotate(v.begin() + b, v.begin() + m, v.begin() + e);
    }

    DumpColumn(v);
    return 0;
}



Measured memory_bytes: 3232
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List


bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

solve :: Int -> [[Int]] -> String
solve _ txys = if res then "Yes" else "No"
  where
    res = foldl' (&&) True $ zipWith f ([0, 0, 0] : txys) txys
      where
        f [n1, x1, y1] [n2, x2, y2] = judge
          where
            elapsed = n2 - n1
            dist = abs (x2 - x1) + abs (y2 - y1)
            judge = dist <= elapsed && (elapsed - dist) `mod` 2 == 0

main :: IO ()
main = do
  conts <- B.getContents
  let ([n] : txys) = map bsReadInts (B.lines conts)
      answer = solve n txys
  putStrLn answer


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)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){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
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);}
signed main(){
    int n; cin >> n;
    map<int,int>mp;
    priority_queue<int,vector<int>,greater<int>>que;
    rep(i,n){
        int m; cin >> m;
        rep(_,m){
            int num; cin >> num;
            if(que.size() != i + 1){
                que.push(num);
            } else {
                if(que.size() and que.top() < num){
                    que.pop();
                    que.push(num);
                }
            }
        }
    }
    int sum = 0;
    while(que.size()) sum += que.top(),que.pop();
    cout << sum << endl;
}





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

vector<int> V[200005];
int indegree[200005];
int bio[200005];
int dp[200005];

void dfs(int a) {
    bio[a]=1;
    for (auto b : V[a]) {
        dp[b]=max(dp[b],dp[a]+1);
        indegree[b]--;
        if (!indegree[b]) {dfs(b);}
    }
}

int main() {
    int n,m,sol=0,a,b;
    cin >> n >> m;
    for (int i=0;i<m;i++) {
        cin >> a >> b;
        V[a].push_back(b);
        indegree[b]++;
    }

    for (int i=1;i<=n;i++) {
        if (indegree[i]==0 && bio[i]==0) {
            dfs(i);
        }
    }

    for (int i=1;i<=n;i++) {sol=max(sol,dp[i]);}

    cout << sol << endl;
}


Measured memory_bytes: 17280
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String a = "Sunny";
		String b = "Cloudy";
		String c = "Rainy";
		if (s.equals(a)){
			System.out.println("Cloudy");
		}
		else if (s.equals(b)){
			System.out.println("Rainy");
		}
		else if (s.equals(c)){
			System.out.println("Sunny");
		}
	}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int n,tmp;
int main() {
	scanf("%d",&n),tmp=1;
	for(int i=1;i<=23;++i,tmp<<=1) if(n==tmp) return puts("No"),0;
    puts("Yes");
	for(int i=3;i<=n;i+=2)
		printf("%d %d\n",i,1),
		printf("%d %d\n",i-1,1),
		printf("%d %d\n",i,i-1+n),
		printf("%d %d\n",i-1,i+n);
	printf("%d %d\n",1+n,3+n);
	if(!(n&1)) {
		for(int i=2;i<n;++i) {
			int tmp=i^n^1;
			if(1<tmp&&tmp<n)
				printf("%d %d\n",n,i),
				printf("%d %d\n",n+n,tmp),
				exit(0);
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e5+100;
int mark[sz];
set<int> st;
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        memset(mark,0,sizeof mark);
        int ara[n];
        st.clear();
        for(i=0;i<n;i++){
            cin>>ara[i];
            st.insert(ara[i]);
            ++mark[ara[i]];
        }
        int tot=0;
        for(auto xx: st){
           tot+=((mark[xx]-1)%2);
        }
        int ans;
       if(tot & 1) ans=st.size()-1;
       else ans=st.size();
       cout<<ans<<endl;
    }





}

Measured memory_bytes: 5760
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

int main() {

	string s;
	cin >> s;

	int pCount = 0;
	for (int i = 0; i < s.size();++i) {
		if (s[i] == 'p')pCount++;
	}

	int ans = (s.size() - 2 * pCount) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""



"""
import sys


from itertools import product

def solve(N, M, lights, P):
    ans = 0
    for p in product([0, 1], repeat=N):
        on_light = 0
        for i, l in enumerate(lights, start=1):
            on = 0
            for ll in l[1:]:
                if p[ll-1]:
                    on += 1
            if on % 2 == P[i-1]:
                on_light += 1
        if on_light == M:
            ans += 1
    return ans



def main(args):
    N, M = map(int, input().split())
    lights = [[int(i) for i in input().split()] for _ in range(M)]
    P = [int(p) for p in input().split()]
    ans = solve(N, M, lights, P)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    vector<ll> w(N);
    vector<int> v(N);
    rep(i,N) cin >> w[i] >> v[i];
    
    vector<vector<ll> > dp(N+1, vector<ll>(1e6,INF_LL));
    dp[0][0] = 0;

    rep(i,N)
    {
        rep(j,1e6)
        {
            chmin(dp[i+1][j], dp[i][j]);
            if( j >= v[i] ) chmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
        }
    }

    ll ans = 0;
    rep(i,dp[N].size())
    {
        if( dp[N][i] <= W ) chmax(ans, (ll)i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 797440
#include <stdio.h>
#include <math.h>

int main(void)
{
  long int n, k, a, b;
  
  scanf("%ld %ld", &n, &k);
  
  if( n >= k ){
    a = n % k;
  } else {
    a = n;
  }
  
  b = k - a;
  
  if( b >= a ){
    printf("%ld\n", a);
  } else {
    printf("%ld\n", b);
  }

  return 0;
}

Measured memory_bytes: 128
dic = {}
for i in range(1,7):
    dic[str(i)+':'] = ''
    
for i in range(input()):
    c = float(raw_input())
    if c < 165.0:
        dic['1:'] = dic['1:']+'*'
    elif 165.0 <= c < 170.0:
        dic['2:'] = dic['2:']+'*'
    elif 170.0 <= c < 175.0:
        dic['3:'] = dic['3:']+'*'
    elif 175.0 <= c < 180.0:
        dic['4:'] = dic['4:']+'*'
    elif 180.0 <= c < 185.0:
        dic['5:'] = dic['5:']+'*'
    elif 185.0 <= c:
        dic['6:'] = dic['6:']+'*'

for k, v in sorted(dic.items(), key=lambda x: x[0]):
    print k+v

Measured memory_bytes: 4272
n,k=map(int,raw_input().split())
g=[[] for _ in xrange(10)]
for i in xrange(n):
    v,j=map(int,raw_input().split())
    g[j-1].append(v)
for i in xrange(10):
    g[i].sort()
    g[i].reverse()

books=[[0]*2005 for _ in xrange(10)]
for i in xrange(10):
    for j in xrange(1,len(g[i])+1):
        books[i][j]=books[i][j-1]+g[i][j-1]+2*(j-1)

dp=[[0]*(k+1) for _ in xrange(11)]
for i in xrange(10):
    for j in xrange(1,k+1):
        for l in xrange(j+1):
            dp[i+1][j]=max(dp[i+1][j],dp[i][j-l]+books[i][l])

print(dp[10][k])

Measured memory_bytes: 7228
def main():
    N = int(input())
    ab = [[int(i) for i in input().split()] for _ in range(N)]
    ab = sorted(ab, key=lambda x: x[0] + x[1], reverse=True)
    ans = 0
    for i in range(N):
        if i % 2 == 0:
            ans += ab[i][0]
        else:
            ans -= ab[i][1]
    print(ans)


main()


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,ans=1;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    
    rep(i,n){
        ans*=a[i];
        if(i!=n-1){
            ll b=2000000000000000000/ans;
            if(b<a[i+1]){
                ans=-1;
                break;
            }
        }
        if(ans>(ll)1000000000000000000){
            ans=-1;
            break;
        }
    }
    
    cout << ans << endl;

    return 0;
}











Measured memory_bytes: 4048
#include <iostream>

int main() {
    int width, height, x, y, r;
    std::cin >> width; std::cin >> height;
    std::cin >> x; std::cin >> y;
    std::cin >> r;
    if (x-r >= 0 and x+r <= width and y-r >= 0 and y+r <= height) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 3088
S = [int(i) for i in input()]

def solve(S):
    n = len(S)
    cum = [0]*(n+1)
    mods = [0]*n
    mods[0] = 1
    for i in range(1,n):
        mods[i] = mods[i-1]*10%2019
    for i in range(n):
        cum[i+1] = (cum[i]+S[n-1-i]*mods[i])%2019
    c = [0]*2019
    for i in range(n+1):
        c[cum[i]] += 1
    ans = 0
    for v in c:
        ans += v*(v-1)//2
    return ans
print(solve(S))

Measured memory_bytes: 24936
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  char a, b;
  cin >> a >> b;
  if (a == 'H'){
    if (b == 'H') cout << "H\n";
    else cout << "D\n";
  } else {
    if (b == 'D') cout << "H\n";
    else cout << "D\n";
  }
}

Measured memory_bytes: 256
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> x(N);

	REP(i, N) {
		cin >> x[i];
	}

	if (x[0] >= 0) {
		cout << x[K - 1] << endl;
	}
	else if (x[N - 1] < 0) {
		cout << - x[N - K] << endl;
	}
	else {
		int min_dist = 1e9;
		REP(i, N - K + 1) {
			if ((x[i] < 0) && (x[i + K - 1] >= 0)) {
				int abs_small = min(abs(x[i]), abs(x[i + K - 1]));
				int abs_big = max(abs(x[i]), abs(x[i + K - 1]));
				min_dist = min(min_dist, 2 * abs_small + abs_big);
			}
		}
		cout << min_dist << endl;
	}

	return 0;
}


Measured memory_bytes: 640
//084B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;
int main(void){
    int a,b;
    string ex;
    cin >> a >> b;
    cin >> ex;
    if(ex.size()!=a+b+1){
        cout << "No" << endl;
        return 0;
    }
    if(ex[a]!='-'){
        cout << "No" << endl;
        return 0;
    }
    if(ex.substr(0,a).find('-') !=-1){
        cout << "No" << endl;
        return 0;
    }
    if(ex.substr(a+1,b).find('-') !=-1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

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

int main() {
	//入力
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;

	int ans = INT_MAX;
	for (int ACnt = 0;ACnt <= x;++ACnt) {
		//ABの枚数
		int ABCnt = (x - ACnt) * 2;
		//Bの枚数
		int BCnt = max(0,y - ABCnt / 2);
		ans = min(ans, ACnt * a + BCnt * b + ABCnt * c);
	}
	for (int BCnt = 0;BCnt <= y;++BCnt) {
		//ABの枚数
		int ABCnt = (y - BCnt) * 2;
		//Aの枚数
		int ACnt = max(0, x - ABCnt / 2);
		ans = min(ans, ACnt * a + BCnt * b + ABCnt * c);
	}

	//答え
	std::cout << ans << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#define N 100000
using namespace std;
int main() {
  int n,m,count=1;
  long od[N];
  cin >> n >> m;
  for(int i=0;i<m;i++){
    long a,b;
    cin >> a >> b;
    od[i] = b * N + a;
  }
  sort(od,od+m);
  for(int i=0;i<m;i++){
    long mb = od[i]/N;
    long ma = od[i]%N;
    for(int j=i+1;j<m;j++){
      long b = od[j]/N;
      long a = od[j]%N;
      if(mb <= a){
        count++;
        i = j-1;
        break;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	
  int A , B;
  cin >> A >> B;
  int count = 0;
  
  for (int i = A ; i <= B ; i++) {
   	int q , r , s , t; // q = 万の位 , r = 千の位 s = 十の位 t = 一の位
   	q = i / 10000;
    r = i / 1000;
    r = r % 10;
    s = i / 10;
    s = s % 10;
    t = i % 10000;
    t = t % 10;
    
    if (q == t && r == s) count++;
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 256
A, B, M = map(int, raw_input().split())
a_s = map(int, raw_input().split())
b_s = map(int, raw_input().split())
w = [[0] * B] * A
cost = 10 ** 30
for _ in xrange(M):
    x, y, c = map(int, raw_input().split())
    cost = min(cost, a_s[x-1] + b_s[y-1] - c)
    w[x-1][y-1] = max(w[x-1][y-1], c)

a_s = sorted(enumerate(a_s), key=lambda t: t[1])
b_s = sorted(enumerate(b_s), key=lambda t: t[1])
for i, a in a_s:
    if a + b_s[0][1] >= cost:
        break
    for j, b in b_s:
        if w[i][j] > 0:
            break
        cost = min(cost, a + b)

print cost

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

#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int32_t main() {
    fastio
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int N;
    vector<int> v;
    cin >> N;
    v.assign(N, 0);
    N--;
    while(N--){
        int d;
        cin >> d;
        v[d-1]++;
    }
    for (int i = 0; i < v.size(); ++i)
        cout << v[i] << " ";

    cout << endl;

    return 0;
}

Measured memory_bytes: 3976
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        bool f=0;
        while(n)
        {
            if(n%10==7) f=1;
            n=n/10;
        }
        if(f) cout<<"Yes"<<en;
        else cout<<"No"<<en;
    }
}



Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
    int n,d;
    scanf("%d%d",&n,&d);
    int i,j,k,flag=0;
    double a[15][15],s;
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            scanf("%lf",&a[i][j]);
        }
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            s=0;
            for(k=0;k<d;k++){
                s=s+pow(fabs(a[i][k]-a[j][k]),2);
            }
            //printf("%lf\n",s);
            if((int)(sqrt(s))==sqrt(s)){
                flag++;
            }
        }
    }
    printf("%d",flag);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

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

void Main() {
  int N; cin >> N;
  if(N % 2 == 0) cout << 0.5 << endl;
  else cout << (N+1.0)/(2.0 * N) << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 8064
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10



int main() {
	string s; cin >> s;
	ll K; cin >> K;
	ll gsc = 5000000000000000;
	REP(i, s.size()) {
		ll dec = s[i] - '0';
		if (dec == 1) {
			K--;
		}
		else {
			K = 0;
		}

		if (K == 0) {
			print(dec);
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin>>S;
  if(S=="Sunny"){cout<<"Cloudy"<<endl;}
  if(S=="Cloudy"){cout<<"Rainy"<<endl;}
  if(S=="Rainy"){cout<<"Sunny"<<endl;}

  return 0;
}


Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int a,b;
	cin>>a>>b;
	if(a<=b){
		cout<<"Impossible"<<endl;
		return 0;
	}
	int n=a+b;
	vi in;
	string s;
	rep(i,n){
		if(in.size()>b)break;
		if(in.size()==0){
			in.pb(i);
			continue;
		}
		int t=in.back();
		cout<<"? "<<t<<" "<<i<<endl;
		cin>>s;
		if(s=="Y")in.pb(i);
		else in.pop_back(),b--;
	}
	
	int ok=in.back();
	string out=string(n,'0');
	rep(i,n){
		cout<<"? "<<ok<<" "<<i<<endl;
		cin>>s;
		if(s=="Y")out[i]='1';
	}
	cout<<"! "<<out<<endl;
}















Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
//int arr[100000 + 5];
int dp[3000 + 5][3000 + 5];
string s, t, lcs;
int LCS(int length1, int length2){
    for(int i = 1; i <= length2; ++i){
        for(int j = 1; j <= length1; ++j){
            if(s[j - 1] == t[i - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    return dp[length2][length1];
}

void backtrack(int i, int j){
    while (i > 0 && j > 0){
        if(s[i - 1] == t[j - 1]){
            lcs += s[i - 1];
            i--;
            j--;
        }else{
            if(dp[j - 1][i] > dp[j][i - 1])
                j--;
            else
                i--;
        }
    }
    reverse(lcs.begin(), lcs.end());
}

int main(int argc, char const *argv[])
{
    cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>s>>t;
    LCS(s.size(), t.size());
    backtrack(s.size(), t.size());
    cout<<lcs<<endl;
}


Measured memory_bytes: 35456
#include<stdio.h>


int main(){
	
	int a,t,b;
	
	scanf("%d %d %d",&a,&t,&b);
	
	if((a*t)<=b){
		printf("%d\n",a*t);
	}
	
	else{
		printf("%d\n",b);
	}
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

const ll NUM = 2019;

string S;

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

  ll ans = 0;
  vector<ll> dp(2019, 0);
  for (int i = 0; i < S.size(); i++) {
    vector<ll> next_dp(2019, 0);
    ll n = S[i] - '0';
    next_dp[n] = 1;
    for (int j = 0; j < 2019; j++) {
      if (dp[j] > 0) {
        next_dp[(j * 10 + n) % NUM] += dp[j];
      }
    }
    dp = next_dp;
    ans += dp[0];
  }

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

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
int grid[22][22], n, M = 1e9+7, dp[22][1<<22];
int solve(int ind, int women){
    if (ind==n)
        return 1;
    if (dp[ind][women]!=-1)
        return dp[ind][women];
    int ans = 0;
    for (int i=0; i<n; i++){
        if (grid[ind][i] && !((1<<i)&women)){
            ans += solve(ind+1, women|(1<<i));
            if (ans>=M)
                ans -=M;
        }
    }
    return dp[ind][women] = ans;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin >> n;
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            cin >> grid[i][j];

    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << "\n";
}

Measured memory_bytes: 364056
S = list(input())
flg = True
for i in range(0,len(S),2):
    if S[i] == 'L':
        flg = False
for j in range(1,len(S),2):
    if S[j]== 'R':
        flg = False
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
/*
g++ -std=c++11 -o2 -Wall ABC081C.cpp -o ./out/ABC081C.out
./out/ABC081C.out
*/

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

typedef long long ll;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

constexpr ll INF = 10000000000000000;

int aa[200005];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  map<int, int> m;
  int a;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    ++m[a];
  }
  int key, value;
  int index = 0;
  for (auto& kv : m) {
    key = kv.first;
    value = kv.second;
    aa[index++] = value;
  }
  int types = m.size();
  sort(aa, aa + types);
  int ans = 0;
  for (int i = 0; i < min(max(types - k, 0), types); ++i) {
      ans += aa[i];
  }
  cout << ans << "\n";
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);
  h.insert(h.begin(), 0);
  int ans = 0;
  while(1){
    bool f = false;
    vector<int> nx = h;
    rep(i, n+1){
      if(h.at(i) > 0){
        if(h.at(i-1) <= 0){
          ans++;
          f = true;
        }
        nx.at(i)--;
      }
    }
    h = nx;
    if(f == false) break;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int X,N;
  cin>>X>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  bool can=true;
  for(int i=0;i<N;i++){
    if(vec.at(i)==X){
      can=false;
      break;
    }
  }
  if(can){
    cout<<X<<endl;
    return 0;
  }
  
  int a=X-1;
  while(true){
    bool can=true;
    for(int i=0;i<N;i++){
      if(a==vec.at(i)){
        can=false;
      }
    }
    if(can) break;
    a=a-1;
  }
    
  int b=X+1;
  while(true){
    bool can=true;
    for(int i=0;i<N;i++){
      if(b==vec.at(i)){
        can=false;
      }
    }
    if(can) break;
    b=b+1;
  }
    
  if(abs(a-X)>abs(b-X)) cout<<b<<endl;
  else if(abs(a-X)<abs(b-X)) cout<<a<<endl;
  else cout<<a<<endl;

  
 
}

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

int main()
{
    ll N,X;
    cin >> N >> X;
    vector<ll> x(N);
    vector<ll> xdiff(N);

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

    x.push_back(X);
    sort(x.begin(),x.end());

    for(int i = 0; i < N; i++)
    {
        xdiff[i] = abs(x.at(i+1) - x.at(i));
    }

    if(xdiff.size() == 1)
    {
        cout << xdiff[0] << endl;
        return 0;
    }

    ll diffCommon;

    for(int i = 0; i < N-1; i++)
    {
        ll a,b,r;
        if(i == 0)
        {
            a = xdiff[i+1];
            b = xdiff[i];
            r = a % b;
            while(r > 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            diffCommon = b;
        }
        else
        {
            a = max(diffCommon,xdiff[i+1]);
            b = min(diffCommon,xdiff[i+1]);
            r = a % b;
            while(r > 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            diffCommon = b;
        }
    }

    cout << diffCommon << endl;
    return 0;
}

Measured memory_bytes: 2560
n,t = [int(x) for x in input().split()]
T = [int(x) for x in input().split()]

ans = 0

for i in range(1,n):
    if T[i] - T[i-1] > t:
        ans += t
    else:
        ans += T[i] - T[i-1]
ans += t

print(ans)

Measured memory_bytes: 25200
#include<iostream>

using namespace std;

const int MAX_N = 1000000;

/**
 * 入力
 * 1 <= N <= 10^5
 * 1 <= ai, bi, ci <= 10^4
 */
int N;
int A[MAX_N];
int B[MAX_N];
int C[MAX_N];
int P[MAX_N][3];


void solve() {

    P[0][0] = A[0];
    P[0][1] = B[0];
    P[0][2] = C[0];

    for (int i = 1; i < N; i++) {
        // A
        P[i][0] = A[i] + max(P[i-1][1], P[i-1][2]);
        // B
        P[i][1] = B[i] + max(P[i-1][0], P[i-1][2]);
        // C
        P[i][2] = C[i] + max(P[i-1][0], P[i-1][1]);
    }
    
    cout << max(P[N-1][0], max(P[N-1][1], P[N-1][2])) << endl;
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }

    solve();

}

Measured memory_bytes: 7552
def sol(n):
  if n == 0: return 2
  if n == 1: return 1
  L = [2,1] + [0]*(n-1)
  for i in range(2,n+1):
    L[i] = L[i-2] + L[i-1]
  return L[-1]

print(sol(int(input())))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

static const long double pi = 3.141592653589793;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    long double H_rad = ((long double)H/12.0 + (long double)M/60.0/12.0) * 2 * pi;
    long double M_rad = ((long double)M/60.0) * 2 * pi;
    long double rad = abs(H_rad - M_rad);

    long double ans = (long double)(A * A) + (long double)(B * B) - (long double)(2 * A * B )* cosl(rad);

    printf("%20.20Lf\n", sqrtl(ans));
}


Measured memory_bytes: 3520
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

ll n, ans, cur = 1;
char s[MAXN][16];
bool flag;

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

    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
        sort(s[i], s[i] + 10);
    }

    qsort(s, n, sizeof *s, [](const void * argv1, const void * argv2) noexcept -> int {
        char const * a = static_cast<char const*>(argv1);
        char const * b = static_cast<char const*>(argv2);

        for (int i = 0; i < 10; i++) {
            if (a[i] < b[i]) {
                return -1;
            } else if (a[i] > b[i]) {
                return 1;
            }
        }

        return 0;
    });

    for (int i = 1; i < n; i++) {
        flag = true;

        for (int k = 0; k < 10; k++) {
            if (s[i][k] != s[i - 1][k]) {
                flag = false;
                break;
            }
        }

        if (flag) {
            cur++;
        } else {
            ans += ((cur - 1) * cur) / 2;
            cur = 1;
        }
    }

    ans += ((cur - 1) * cur) / 2;

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

    return 0;
}

Measured memory_bytes: 3324
#include <iostream>

int main()
{
  int A=0,B=0,C=0;

  std::cin >> A >> B >> C;

  int yoyu = A - B;

  int ama =  C - yoyu;
  if(ama < 0)
  ama = 0;


  std::cout << ama << std::endl;
  return 0;
}


Measured memory_bytes: 256