akhauriyash/Code-Regression huggingface dataset:
from functools import reduce

EPSILON = 1e-5
d = 0
Vs = []

times = lambda x,y: x*y

def interpolate(x, e):
    return sum(
        reduce(
            times, [(x-j)/(i-j) for j in range(len(Vs)) if j not in [i,x,e]]
            )*v for i,v in enumerate(Vs) if i not in [x,e])

def outlier(e):
    for i,v in enumerate(Vs):
        if i==e: continue
        if abs(interpolate(i,e) - v) < EPSILON: return False
    return True

def solve():
    for i in range(d+3):
        if not outlier(i): return i
    return -1

while True:
    d = int(input())
    if d==0: break
    Vs = [float(input()) for i in range(d+3)]
    print(solve())


Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

int main(){
  int a,b,c; cin>>a>>b>>c;
  if(a+b>=c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define PB push_back
#define FOR(i, a, b) for (int i {a}; i < b; i++) // a = i's initial value, b = limit

int main(){
    int n{}, m{};
    cin >> n >> m;
    FOR(i, 0, m){
        int k{};
        cin >> k;
        n -= k;
    }
    if (n < 0){
        cout << -1;
    }else
        cout << n;

    return 0;
}

Measured memory_bytes: 3592
N = int(input())
A, B, C = [], [], []
for n in range(N):
    a, b, c = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
a, b, c = 0, 0, 0
for n in range(N):
    a, b, c = A[n] + max(b, c), B[n] + max(c, a), C[n] + max(a, b)
print(max(a, b, c))


Measured memory_bytes: 65624
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
#define mod  1000000007
#define mp make_pair
#define pb push_back
#define sd second
#define mod  1000000007
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++) 
ll i,j,k;
void solve(){
 ll h,a; cin >>h >> a;
  cout << ((h % a == 0) ? (h/a) : ((h/a) +1))<< endl;



     return ; 
} 
    signed main(){
   
    //CASET
    solve();
    
   
    return 0;
  }

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    int ans = 1;
    for(int i=0;i<N;i++)
    {
        ans *= 3;
    }
    int mai = 1;
    for(int i=0;i<N;i++)
    {
        if(A.at(i)%2==0)
        {
            mai *= 2;
        }
    }

    cout << ans - mai << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;
static const i64 INF = 1000010000;
static const i64 MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

//-----end of template-----//

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int ans = INF;
    REP(i, s.length() - 2){
        ans = min(ans, abs(753 - stoi(s.substr(i, 3))));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 22;

int i,j,n,dp[1<<N];
vi woman[N];

void solve()
{
    cin>>n;
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=n;++j)
        {
            int x;
            cin>>x;
            if(x)
            {
                woman[j].pb(i-1);
            }
        }
    }
    dp[0]=1;
    for(i=1;i<=n;++i)
    {
        for(j=0;j<(1<<n)-1;++j)
        {
            for(int k:woman[i])
            {
                if(__builtin_popcount(j)==i-1)
                {
                    int mask=j;
                    if(mask&(1<<k))
                        continue;
                    dp[mask|(1<<k)]+=dp[mask];
                    dp[mask|(1<<k)]%=mod;
                }
            }
        }
    }
    cout<<dp[(1<<n)-1];
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11776
l=[list(map(int,input().split())) for _ in range(2)]
managementlist=[]
for i in range(l[0][0]):
    managementlist.append(0)
for j in range(l[0][0]-1):
    managementlist[l[1][j]-1]+=1
for k in range(l[0][0]):
    print(managementlist[k])

Measured memory_bytes: 32300
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int binary_search(vector<int> a,int key){
  int high = a.size()-1;
  int low = 0;

  while(high > low){
    int mid = (high + low) / 2;
    if(key < a[mid]){
      high = mid - 1;
    }else if(key > a[mid]){
      low = mid + 1;
    }else{
      return mid;
    }
  }
  return -1;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,m;cin>>n>>m;
  vector<pair<int,int> > a(n),b(m);
  rep(i,n)cin>>a[i].fi>>a[i].se;
  rep(i,m)cin>>b[i].fi>>b[i].se;
  

  rep(i,n){
    int ans;
    int min = 1000000000;
    rep(j,m){
      int value = abs(a[i].fi - b[j].fi) + abs(a[i].se - b[j].se);
      if(min > value){
        min = value;
        ans = j+1;
      }
    }
    print(ans);
  }

  return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int X, Y, Z; std::cin >> X >> Y >> Z;

  int ans = 1;
  X -= Z;
  std::cout << ans + X/(Y+Z) - 1 << std::endl;
  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[55];
int main()
{
  ll n, k, ans = 0;
  scanf("%lld%lld", &n, &k);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", &a[i]);
  }
  sortdown(a, n);
  for (int i = 0; i < k; i++)
  {
    ans += a[i];
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
import math
katsu = 0

if N <= K-1: 
  for i in range(1, N+1):
    katsu += 0.5 ** ((math.log2((K-1) / i) // 1)+1) 
  print(katsu/N)
  exit()
else: 
  for i in range(1, K):
    katsu += 0.5 ** ((math.log2((K-1) / i) // 1)+1) 
  for i in range(K, N+1):
    katsu += 1
  
  print(katsu/N)
  exit()
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll z = *x;
  *x = *y;
  *y = z;
}
void print(vector<ll> vec){
  ll length = (ll)vec.size();
  rep(i,length){
    if(i != 0){cout << " ";}
    cout << vec[i];
  }
  cout << endl;
}

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> p(n);
  ll sortnum = 1;
  ll sortcou = 0;
  rep(i,n){
    cin >> p[i];
  }
  rep(i,n-1){
    if(p[i+1] > p[i]){
      sortnum++;
    }else{
      sortnum=1;
    }
    if(sortnum == k){
      sortcou++;
    }
  }
  set<ll> s;
  ll sum = 0;
  rep(i,k){
    s.insert(p[i]);
  }
  sum++;
  rep(i,n-k){
    s.erase(p[i]);
    auto itr1 = s.begin();
    auto itr2 = s.end();
    itr2--;
    //cout << p[i] << *itr1 << *itr2 << p[i+k] << endl;
    if(p[i] < *itr1 && *itr2 < p[i+k]){
      //sum++;
    }else{
      sum++;
    }
    s.insert(p[i+k]);
  }
  if(sortcou >= 1){
    sum -= (sortcou-1);
  }
  cout << sum << endl;
}

Measured memory_bytes: 11136
import sys
import itertools
import bisect
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
l = na()

l.sort()

ct = 0
for i in range(n):
    for j in range(i+1, n):
        tmp = l[i] + l[j]
        ct += bisect.bisect_left(l, tmp) - (j + 1)
print(ct)







Measured memory_bytes: 3188
from math import atan, degrees

def main():
    a,b,x = map(int, input().split())
    if x == a**2 * b:
        print(0.0)
        exit()

    t = atan(a**3 / (2 * a**2 * b - 2 * x))
    s = atan(2 * x / (a * b**2))

    if x >= a**2 * b / 2:
        print(90.0 - degrees(t))
    else:
        print(90.0 - degrees(s))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007ll
using namespace std;
ll bigmod(ll b, ll p)
{
    if(!p)return 1ll;
    ll ret= bigmod(b, p/2);
    ret= (ret*ret)%mod;
    if(p&1ll)ret= (ret*b)%mod;
    return ret;
}
int main()
{
    ll n;
    scanf("%lld", &n);
    printf("%lld\n", ((bigmod(10, n)+bigmod(8, n)-2*bigmod(9, n))%mod+mod)%mod);
    return 0;
}


Measured memory_bytes: 3792
N = int(input())
from itertools import product
ans = 0
for n in range(3,10):
    for ptn in product('753', repeat=n):
        if '7' not in ptn: continue
        if '5' not in ptn: continue
        if '3' not in ptn: continue
        v = int(''.join(ptn))
        if v <= N:
            ans += 1
print(ans)


Measured memory_bytes: 43884
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


/*
a+b=kx
b+c=ky
c+a=kz
より、
a=k(x-y+z)/2
b=k(x+y-z)/2
c=k(-x+y+z)/2
a,b,cはいずれもk/2の倍数。k/2の倍数ならなんでもいいという訳ではなく、
全ての数の偶奇が一致していなければならない

kが奇数の時、a,b,cが全てkの倍数。この時xyzは存在する
kが偶数の時、a,b,cが全てkの倍数であるか、kの倍数でないのなら全てkl+k/2である必要がある
それらの個数をp,qとすると、
奇数なら
3つかぶる->p
2つかぶる->p*(p-1)*3
かぶらない->p*(p-1)*(p-2)
偶数なら、これに加えてqで同じものを加算する必要がある

*/

ll cal(ll p){
    return p+p*(p-1)*3+p*(p-1)*(p-2);
}

void solve(){
    ll n,k;
    cin >> n >> k;
    ll p=n/k;
    ll q;
    if(k!=1) q=((n/(k/2))+1)/2;
    if(k%2==1){
        cout << cal(p) << endl;
    }
    else {
        cout << cal(p)+cal(q) << endl;
    }
}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int demeat,sec,hutuusec,kaitousec,purpose,ans=0;
	int i=0,x=1;
	cin>>demeat>>purpose>>sec>>kaitousec>>hutuusec;

	if(demeat<0){
		ans+=kaitousec;
		for(i=demeat;i<0;i++){
			ans+=sec;
		}
		for(i=0;i<purpose;i++){
			ans+=hutuusec;
		}
	}
	else if(demeat>0){
	for(int j=demeat;j<purpose;j++){
		ans+=hutuusec;
		}
	}


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

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    double a,b,x; cin >> a >> b >> x;
    
    double rad; //ラジアン
    double H; //高さ
    if (a*a*b/2<=x){
        H=2*(a*a*b-x)/(a*a);
        rad=atan2(H,a);
    }else{
        H=(2*x)/(a*b);
        rad=atan2(b,H);
    }
    double PI = acos(-1);
    double ANS=rad*180/PI;
    cout << fixed << setprecision(10) << ANS << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

vector<ll> x(100001, 0);
void solve(long long N, std::vector<long long> A, long long Q, std::vector<long long> B, std::vector<long long> C){
  ll sum = 0;

  rep(i,N) {
    x[A[i]]++;
    sum+=A[i];
  }
  rep(i,Q) {
    ll y = C[i]-B[i];
    sum+=y*x[B[i]];
    std::cout << sum << std::endl;
    x[C[i]]+=x[B[i]];
    x[B[i]] = 0;
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> B(Q);
  std::vector<long long> C(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&B[i]);
    scanf("%lld",&C[i]);
  }
  solve(N, std::move(A), Q, std::move(B), std::move(C));
  return 0;
}



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

using namespace std;

int main(){
    map<string, int> Day = {{"SUN",7},{"MON",6},{"TUE",5},{"WED",4},{"THU",3},{"FRI",2},{"SAT",1}};
    string S;
    cin >> S;
    cout << Day[S] << endl;
    return 0;
}

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

using Graph = vector<vector<int>>;

Graph graph(200100);
vector<int> score(200100, 0);

void dfs(int cur, int prev) {
  score[cur] += score[prev];
  // 各頂点にスコアを加算する
  for (auto next : graph.at(cur)) {
    if (next == prev) continue;
    dfs(next, cur);
  }
}

int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);

  for (int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    // 辺の情報から無向グラフを作成
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }

  for (int i = 0; i < Q; i++) {
    int p, x;
    scanf("%d%d", &p, &x);
    score.at(p) += x;
  }

  dfs(1, 0);

  for (int i = 1; i <= N; i++) {
    printf("%d ", score.at(i));
  }
  return 0;
}


Measured memory_bytes: 23424
import sys

n=int(input())
s=str(input())
list=[]
for i in range(1,n):
	a=s[0:i]
	b=s[i:]
	count=0
	for j in range(97,97+26):
		if (chr(j) in a)and(chr(j) in b):
			count+=1
	list.append(count)
print(max(list))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> VI;
typedef vector <VI> VVI;

int m, n;
VVI S;

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

int answer = 0, now = 0;
int search( int x, int y )
{
	now++;
	answer = max( answer, now );
	S[y][x] = 0;
	for ( int i = 0; i < 4; i++ )
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if ( S[ny][nx] == 1 )
		{
			search( nx, ny );
		}
	}
	S[y][x] = 1;
	now--;
}

int main( void )
{
	while ( cin >> m >> n && m && n )
	{
		answer = now = 0;
		// m*n
		S = VVI( n+2, VI( m+2, 0 ) );
		for ( int i = 1; i <= n; i++ ) for ( int j = 1; j <= m; j++ ) cin >> S[i][j];

		for ( int i = 1; i <= n; i++ ) for ( int j = 1; j <= m; j++ )
		{
			if ( S[i][j] == 1 )
			{
				search( j, i );
			}
		}

		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	fio;
	ll x;
	cin >> x;
	ll p = 100;
	ll time = 0;
	while (p < x)
	{
		p += 0.01 * p;
		time++;
	}
	cout << time << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main() {
	scanf("%1d%1d%1d%1d",&a,&b,&c,&d);
	if(a + b + c + d == 7)
		printf("%d+%d+%d+%d=7\n",a,b,c,d);
	else if(a + b + c - d == 7)
		printf("%d+%d+%d-%d=7\n",a,b,c,d);
	else if(a + b - c + d == 7)
		printf("%d+%d-%d+%d=7\n",a,b,c,d);
	else if(a - b + c + d == 7)
		printf("%d-%d+%d+%d=7\n",a,b,c,d);
	else if(a - b - c + d == 7)
		printf("%d-%d-%d+%d=7\n",a,b,c,d);
	else if(a + b - c - d == 7)
		printf("%d+%d-%d-%d=7\n",a,b,c,d);
	else if(a - b + c - d == 7)
		printf("%d-%d+%d-%d=7\n",a,b,c,d);
	else
		printf("%d-%d-%d-%d=7\n",a,b,c,d);
	return 0;
}

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

int main() {
  string base = "MARCH";
  int64_t N;
  cin >> N;
  map<char,int64_t> count;
  rep(i,N) {
    string S;
    cin >> S;
    char c = S.at(0);
    if ( base.find(c) != string::npos) {
      if ( count.count(c) ) {
        count[c]++;
      }
      else {
        count[c] = 1;
      }
    }
  }
  int64_t answer = 0;
  int base_n = base.size();
  for(int i = 0; i < base_n; i++) {
    char c0 = base.at(i);
    if ( count.count(c0) == false ) {
      continue;
    }
    for(int j = i+1; j < base_n; j++) {
      char c1 = base.at(j);
      if ( count.count(c1) == false ) {
        continue;
      }
      for(int k = j+1; k < base_n; k++) {
        char c2 = base.at(k);
        if ( count.count(c2) == false ) {
          continue;
        }
        answer += count[c0] * count[c1] * count[c2];
      }
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  
  cin >> n >> a >> b;
  
  if(a * n > b){
    cout << b << endl;
  }else{
    cout << a * n << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int n,k,d[110],A[110][110];
  cin >> n >> k;

  for(int i = 0; i < k; i++) {
    cin >> d[i];
    for(int j = 0; j < d[i]; j++)
      cin >> A[i][j];
  }
  
  int sum = 0;
  for(int m = 1; m <= n; m++) {
    for(int i = 0; i < k; i++) {
      for(int j = 0; j < d[i]; j++) {
        if(m == A[i][j]) goto Loop1;
      }
    }
    sum++;
    Loop1: ;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long N, long long M, std::vector<long long> A){

}

int main(){
	double R;
	cin >> R;
	cout << R * 6.28318530717958623200 << endl;
    return 0;
}


Measured memory_bytes: 3256
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int f=a/100;
		int l=a%100;
		String ans="NA";
		if((l>=1&&l<=12)&&(f>=1&&f<=12))
			ans="AMBIGUOUS";
		else if(l>=1&&l<=12)
			ans="YYMM";
		else if(f>=1&&f<=12)
			ans="MMYY";
		System.out.println(ans);

	}
}

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

int main(){
    int n, m; cin >> n >> m;
    priority_queue<int64_t, vector<int64_t>, greater<>> q;
    vector<pair<int64_t, int>> b(m); int64_t ans = 0;
    for (auto i = 0; i < n; i++) { int a; cin >> a; q.push(a); ans += a; }
    for (auto i = 0; i < m; i++) cin >> b[i].second >> b[i].first;
    sort(b.begin(), b.end(), greater<>());
    for (auto & elm : b) {
        for (auto i = 0; i < elm.second; i++) {
            auto p = q.top(); q.pop();
            if(p < elm.first) { ans = ans - p + elm.first; p = elm.first; q.push(p); }
            else break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5876
using System;
using System.Linq;

namespace A___Buttons
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = A_B[0], B = A_B[1];
            var res = 0;

            for (int i = 0; i < 2; i++)
            {
                if (A > B)
                {
                    res += A;
                    A--;
                }
                else
                {
                    res += B;
                    B--;
                }
            }

            Console.WriteLine(res);
        }
    }
}


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

int main(){
    double N, K, ans = 0;
    cin >> N >> K;
    for(double n = 1; n <= N; ++n){
        double buf = 0, tmp = n;
        while(tmp < K){
            tmp *= 2;
            ++buf;
        }
        ans += 1/N * pow(1./2., buf);
    }
    cout << setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 4292
N, T = map(int, input().split())
A = []
for _ in range(N):
  a, b = map(int,input().split())
  A.append((a, b))
A.sort(key=lambda x: x[0])

newdp = [0 for _ in range(T)]
ans = 0
from collections import deque
A = deque(A)
visited = [0]
while A:
  olddp = tuple(newdp)
  newdp = list(newdp)
  X = A.popleft()
  a = X[0]
  b = X[1]
  for v in visited:
    if v + a > T-1:
      ans = max(ans, olddp[v]+b)
    else:

      if newdp[v+a] == 0:
        visited.append(v+a)
      newdp[v+a] = max(olddp[v] + b, newdp[v+a])


if ans == 0:
  print(max(olddp))
else:
  print(ans)

Measured memory_bytes: 77700
N = int(input())
T = [int(input()) for _ in range(N)]

def gcm(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    else:
        return gcm(a%b, b)

def lcm(a, b):
    return a // gcm(a, b) * b

ans = 1
for i in T:
    ans = lcm(ans, i)
print(ans)

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;
const ll MOD = 1000000007;

int main() {
  string o, e;
  cin >> o >> e;
  REP(i, o.length()) {
    cout << o[i];
    if (i < e.length()) cout << e[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
double hp,a;
int main(){
    cin>>hp>>a;
    double b=hp/a;
    int t=ceil(b);
    printf("%d\n",t);
	return 0;
}


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

using ll=long long int;

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

	cout << max(max(a + a - 1, b + b - 1), a + b) << endl;

	return 0;
}




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

long long int c[4005][4005];
long long int mod = 1000000007;

void init()
{
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
      c[i+1][j] %= mod;
      c[i+1][j+1] %= mod;
    }
  }
}

long long int comb(int left, int right)
{
  if (left < right) {
    return 0;
  }
  return c[left][right];
}


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

  int blue = k;
  int red = n - k;

  init();

  for (int i = 1; i <= k; i++) {
    long long int redPattern;
    long long int bluePattern;

    redPattern = comb(red + 1, i) % mod;
    bluePattern = comb(blue - 1, i - 1) % mod;
    
    cout << (redPattern * bluePattern) % mod << endl;
  }
}


Measured memory_bytes: 123648
#include <stdio.h>
#include <iostream>
#include <set>
#include <vector>
#include <map>
using namespace std;

int diviser(int x, int y) {
  if (x % y == 0) {
    return y;
  } else {
    return diviser(y, x % y);
  }
}

int main() {

  vector<int> vc;
  std::map<int, int> mp; 
  set<int> st;

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

  cout << diviser(x, y) << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<ll> h(n);
	ll ans = 0;
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
		ans += h[i];
	}
	
	if( n <= k ) {
		cout << 0 << endl;
		return 0;
	}
	
	sort(h.begin(), h.end(), greater<int>());
	
	for(int i = 0; i < k; ++i) {
		ans -= h[i];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

signed main() {
  int N; cin >> N;
  vector<int> vs(N);
  rep(i,N) cin >> vs[i];
  sort(all(vs));
  double ans = vs[0];
  for(int i=1; i<N; i++) {
    ans = (ans + vs[i]) / 2.0;
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

while(1){
  
  int H,W;
  
  scanf("%d %d",&H,&W);
  
  if(H==0){break;}
  
  for(int i=0; i<H; i++){
  for(int j=0; j<W; j++){
    if(i==0||i==H-1){
       printf("%c",'#');
    }  
    else{
      if(j==0||j==W-1){
        printf("%c",'#');
        }
      else{
        printf("%c",'.');
        }
    }
   
    }
    printf("\n");
    }
    
    printf("\n");
   
}
   

}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
#define fir first
#define sec second

const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

//http://drken1215.hatenablog.com/entry/2019/05/13/114600 写経

ll rec(int n, ll x) {
	if (n == 0) return 1;
	ll len = (1LL<<(n + 1)) - 3;
	ll num = (1LL<<n) - 1;
	if (x == 1) return 0;
	else if (x <= len + 1) return rec(n - 1, x - 1);
	else if (x == len + 2) return num + 1;
	else if (x <= (len + 1) * 2) return num + 1 + rec(n - 1, x - len - 2);
	else return num * 2 + 1;
}

int main(void){
	int N; ll X;
	cin>>N>>X;

	cout<< rec(N, X) <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int N,K;
    cin>>N>>K;
    vi a(N);
    cin>>a;
    sort(ALL(a));

    int left=0;
    int right=N-1;
    int rightmost=-1;
    while(left<=right) {
        int mid=(left+right)/2;

        vector<vector<bool>> dp(5555,vector<bool>(5555,false));
        dp[0][0]=true;
        REP(i,N) {
            REP(sum,K+1) {
                if(dp[i][sum]) {
                    if(i!=mid && sum+a[i]<=K) dp[i+1][sum+a[i]]=true;
                    dp[i+1][sum]=true;
                }
            }
        }

        bool exist=false;
        REP(sum,K) {
            if(dp[N][sum]) {
                if(K-a[mid]<=sum) {
                    exist=true;
                    break;
                }
            }
        }
        dump(mid,exist);
        if(exist) {
            right=mid-1;
        }
        else {
            left=mid+1;
            chmax(rightmost,mid);
        }
    }
    cout<<rightmost+1<<endl;
    return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
#include <iterator>
#include <tuple>
using namespace std;
using ll = long long;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  ll ans = pow(3, n);
  ll sum = 1;
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    if (a % 2 == 0)
      sum *= 2;
  }
  ans -= sum;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;




int main() {
	string s;
	cin >> s;

	int cnt = 0;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'R') {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}


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

struct TNode
{
public:
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
	TNode(int Value)
	{
		Id = Value;
		Parent = NULL;
		LChild = NULL;
		RChild = NULL;
	}
};

struct TTree
{
private:
	TNode* Root;
	void Delete(const TNode* Node)
	{
		if(Node == NULL) return;
		Delete(Node->LChild);
		Delete(Node->RChild);
		delete Node;
	}
	void InorderOutput(const TNode* Node)
	{
		if(Node == NULL) return;
		InorderOutput(Node->LChild);
		cout << ' ' << Node->Id;
		InorderOutput(Node->RChild);
	}
	void PreorderOutput(const TNode* Node)
	{
	    if(Node == NULL) return;
	    cout << ' ' << Node->Id;
	    PreorderOutput(Node->LChild);
	    PreorderOutput(Node->RChild);
	}
	void Insert(TNode* z)
	{
	    assert(z != NULL);
		TNode* y = NULL;
		TNode* x = Root;
		while(x != NULL){
			y = x;
			if(z->Id < x->Id){
				x = x->LChild;
			}else{
				x = x->RChild;
			}
		}
		z->Parent = y;
		if(y == NULL){
			Root = z;
		}else if(z->Id < y->Id){
			y->LChild = z;
		}else{
			y->RChild = z;
		}
	}
public:
	TTree()
	{
		Root = NULL;
	}
	~TTree()
	{
		Delete(Root);
	}
	void Insert(int Id)
	{
		TNode* Node;
		Node = new TNode(Id);
		Insert(Node);
	}
	void Print()
	{
		InorderOutput(Root);
		cout << endl;
		PreorderOutput(Root);
		cout << endl;
	}
};

int main()
{
	int n;
	cin >> n;
	TTree Tree;
	for(int i = 0; i < n; i++){
		string Command;
		cin >> Command;
		if(Command == "insert"){
			int Id;
			cin >> Id;
			Tree.Insert(Id);
		}else{
			Tree.Print();
		}
	}
    return 0;
}

Measured memory_bytes: 26568
import java.util.Scanner;

public class Main
{

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

		long r = Long.parseLong(sc.next());
		long d = Long.parseLong(sc.next());
		long x = Long.parseLong(sc.next());

		for (int i = 2001; i <= 2010; i++) {
			x = r * x - d;
			System.out.println(x);
		}



		sc.close();
	}
}

Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
S = input()

n = len(S)

sum_formula = 0
# bit全探索
for bit in range(2 ** (n-1)):
    nums = []
    # 何ビットシフトさせるか
    num = S[0]
    for shift in range(n-1):
        if not ((bit >> shift)&1):
            num = num + S[shift+1]
        else:
            nums.append(int(num))
            num = S[shift+1]
    nums.append(int(num))
    sum_formula += sum(nums)

print(sum_formula)


# 再帰関数
def calc_all_formula(S, i, lists):
    '''
    listsの要素: ([数字list], temp_str)
    '''
    new_lists = []
    # i - i+1番目の間に+が入る
    new_lists.extend(
        [(lst[0]+[int(lst[1])], S[i+1]) for lst in lists]
    )
    new_lists.extend(
        [(lst[0], lst[1]+S[i+1]) for lst in lists]
    )

    # base case
    if i == len(S)-2:
        new_lists = [
            lst[0]+[int(lst[1])] for lst in new_lists
        ]
        return new_lists
    
    return calc_all_formula(S, i+1, new_lists)

# base_cand = [([], S[0])]

# if len(S) >= 2:
#     sum_formula = sum([sum(lst) for lst in calc_all_formula(S, 0, base_cand)])
#     print(sum_formula)
# else:
#     print(int(S))

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>

#define rep(i, n) for (int i = 0; i < n; i++) 
#define rrep(i, n) for(int i = n-1; i>=0; i--)
#define range(i, n, m) for (int i = n; i < m; i++) 
#define rrange(i, n, m) for (int i = n - 1; i => m; i--) 
#define MOD 1000000007;

typedef long long int ll;
typedef unsigned long long int ull;


using namespace std;

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

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

	ll N;
	cin >> N;

	vector<ll> X(N), Y(N), H(N);

	rep(i, N) {
		cin >> X[i] >> Y[i] >> H[i];
	}

	rep(x, 101) {
		rep(y, 101) {
			bool flg = true;
			ll retH = 0;

			rep(i, N) {
				if (H[i] == 0)continue;
				if (retH == 0) retH = H[i] + abs(X[i] - x) + abs(Y[i] - y);
			}

			rep(i,N){
				if (H[i] != max(retH - abs(X[i] - x) - abs(Y[i] - y) , 0ll)) {
					flg = false;
					break;
				}
			}

			if (flg && retH != 0) {
				cout << dec << x << " " << dec << y << " " << dec << retH;
				return 0;

			}

		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
    string s;
    cin >> s;
    vector<int> a(4);
    rep(i,4) a.at(i) = (int)s.at(i) - '0';

    
    rep(i,8){
        int sum = 0;
        string ans;
        sum += a.at(0);  
        ans += char(a.at(0)+'0'); 
        rep(j,3){
            if(i&(1<<j)){
                sum += a.at(j+1);
                ans += '+';
                ans += char(a.at(j+1)+'0');
            }
            else{
                sum -= a.at(j+1);
                ans += '-';
                ans += char(a.at(j+1)+'0');
            }
        }
        if(sum==7){
            ans += "=7";
            cout<<ans<<endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

#define int long long

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	solve();
	return 0;
}

int n, m;
const int maxn = 1e5 + 55;
int s[maxn] = {0};

void solve() {
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int a, b; cin >> a >> b;
		s[a] += 1;
		s[b + 1] -= 1;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		s[i] += s[i - 1];
		if (s[i] == m) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 1024
from operator import itemgetter

#入力
W,H,N = [int(x)for x in input().split()]

xlow=0
ylow=0
xhigh=W
yhigh=H

for i in range(N):
    x,y,a=[int(x)for x in input().split()]
    if(a==1):
        if(xlow < x):
            xlow=x
    elif(a==2):
        if(xhigh > x):
            xhigh=x
    elif (a == 3):
        if (ylow < y):
            ylow = y
    elif (a == 4):
        if (yhigh > y):
            yhigh = y


#print(xhigh,xlow,yhigh,ylow)
if(xlow < xhigh and ylow<yhigh):
    print((xhigh - xlow)*(yhigh - ylow))
else:
    print(0)

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

using namespace std;

const long double eps = 1e-9;

const int MaxN = 16;
const int INF = 1e9;

int n, m;

int sum[1 << MaxN];
int a[MaxN][MaxN];

int dp[1 << MaxN][MaxN];

inline int getDif(int mask1, int mask2)
{
    return sum[mask1 | mask2] - sum[mask1] - sum[mask2];
}

inline void up(int & x, int y)
{
    if(y < x)
        x = y;
}

int main()
{
//    freopen("input.txt", "r", stdin);
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int x, y, z;
        cin >> x >> y >> z;
        --x, --y;
        a[x][y] = a[y][x] = z;
    }
    for(int mask = 0; mask < (1 << n); ++mask)
        for(int bit = 0; bit < n; ++bit)
            if(mask & (1 << bit))
                for(int otherBit = bit + 1; otherBit < n; ++otherBit)
                    if(mask & (1 << otherBit))
                        sum[mask] += a[bit][otherBit];

    for(int mask = 0; mask < (1 << n); ++mask)
        for(int i = 0; i < n; ++i)
            dp[mask][i] = INF;

    dp[1][0] = 0;

    for(int mask = 1; mask < (1 << n); ++mask)
        for(int bit = 0; bit < n; ++bit)
            if(mask & (1 << bit) && dp[mask][bit] != INF)
            {
                for(int otherBit = 0; otherBit < n; ++otherBit)
                    if(!(mask & (1 << otherBit)) && a[bit][otherBit])
                        up(dp[mask | (1 << otherBit)][otherBit], dp[mask][bit] + getDif(mask - (1 << bit), (1 << otherBit)));

                int otherMask = (1 << n) - 1 - mask;
                for(int subMask = otherMask; subMask; --subMask, subMask &= otherMask)
                    up(dp[mask | subMask][bit], dp[mask][bit] + getDif(mask - (1 << bit), subMask));


            }

    cout << dp[(1 << n) - 1][n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 4480
import sys

def binarySearch(t,w):
    left = max(w)
    right = sum(w)
    while left < right:
        middle = (left + right) // 2
        if hantei(t,w,middle):
            right = middle 
        else:
            left = middle + 1
    return left
            
def hantei(t,w,p):
    track_on = 0
    daisu = 1
    for j in range(len(w)):     
        track_on += w[j]
        if track_on > p:
            daisu += 1
            track_on = w[j]
            if daisu > t:
                return False
    return True


nimotsu, track = map(int,input().split())
weight = list(map(int,sys.stdin.readlines()))



print(binarySearch(track,weight))

Measured memory_bytes: 17796
//Warmdust Code
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define db double
#define ll long long
#define inf 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=10005;

int main(){
	FAST_IO;
	int a,b;
	cin >> a >> b;
	if(a==1){
		cout << b << endl;
		return 0;
	}
	for(int i=-a+1;i<a-1;i++){
		cout << b+i << " " ;
	}
	cout << b+a-1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
const int maxn=100+10;
const int maxv=10000+10;
const int INF=1<<21;
int n;
int E;
typedef struct
{
    int from,to,cost;
}Edge;

Edge e[maxv];
int d[maxn];
void bellman_ford(int s)
{
    fill(d,d+n,INF);
    d[s]=0;
    while(true)
    {
        bool bUpdate=false;
        for(int i=0;i<E;i++)
        {
            Edge es=e[i];
            if(d[es.from]!=INF&&d[es.to]>d[es.from]+es.cost)
            {
                d[es.to]=d[es.from]+es.cost;
                bUpdate=true;

            }
        }
        if(!bUpdate) break;

    }
    for(int i=0;i<n;i++)
    printf("%d %d\n",i,d[i]);
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int id,c;
    E=0;
    for(int i=0; i<n; i++)
    {
        scanf("%d%d",&id,&c);
        while(c--)
        {
            scanf("%d%d",&e[E].to,&e[E].cost);
            e[E].from=id;
            E++;
        }
    }
    bellman_ford(0);

    return 0;
}

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

void solve(long long N, std::vector<std::string> S) {
    ll a = 0, b = 0, c = 0, d = 0;
    rep(i, N) {
        if (S[i] == "AC") {
            a++;
        } else if (S[i] == "WA") {
            b++;
        } else if (S[i] == "TLE") {
            c++;
        } else if (S[i] == "RE") {
            d++;
        }
    }
    cout << "AC x " << a << endl << "WA x " << b << endl << "TLE x " << c << endl << "RE x " << d << endl;
}

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


Measured memory_bytes: 6428
#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;

int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    long long ans;
    if(a+b>=c){
        ans=b+c;
    }else{
        ans=a+2*b+1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

div = 0
sum = 0
l = [a, b, c, d, e]

for i in range(len(l)):
    if(l[i] % 10 != 0):
        sum += (l[i]//10+1)*10
        if((l[i]//10+1)*10 - l[i] > div):
            div = (l[i]//10+1)*10 - l[i]
    else:
        sum += l[i]
        
print(sum-div)

Measured memory_bytes: 3064
INF = 10**9

if __name__ == '__main__':
    n = int(raw_input())

    # dp[i][j]: minimal cost of M[i]...M[j]
    # for example, the minimal cost of M[1]M[2]M[3]M[4] is the smallest of the 3 cases below:
    # (M[1])(M[2]M[3]M[4])
    # (M[1]M[2])(M[3]M[4])
    # (M[1]M[2]M[3])(M[4])
    # where M[i] represents a (p[i-1] x p[i]) matrix, 1<=i<=n
    # clearly the cost of multiplying only one matrix (M[i]) is zero, so dp[i][i] = 0
    dp = [[0 for j in range(n+1)] for i in range(n+1)]  # 1-origin
    p = [0 for i in range(n+1)]  # 0-origin
    for i in range(1, n+1):
        p[i-1], p[i] = map(int, raw_input().split())

    # set basis case
    for i in range(1, n+1):
        dp[i][i] = 0

    # l: multiply l consecutive matrices
    for l in range(2, n+1):
        # each group of l matrices are M[i]...M[j], where j-i+1=l, j=l+i-1
        # j<=n, l+i-1<=n, i<=n-l+1
        for i in range(1, n-l+1+1):
            j = l+i-1
            minv = INF
            for k in range(i, j):
                # divide into M[i]...M[k], which is a (p[i-1] x p[k]) matrix
                # and M[k+1]...M[j], which is a (p[k] x p[j]) matrix
                # so multiply the two costs p[i-1]*p[k]*p[j]
                minv = min(minv, dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j])
            dp[i][j] = minv
    print dp[1][n]


Measured memory_bytes: 4864
"use strict";

function Main(input) {
  input = input.split(" ");
  var A = parseInt(input[0], 10);
  var B = parseInt(input[1], 10);
  var C = parseInt(input[2], 10);

  if (A < C && C < B) {
    console.log("Yes");
    return;
  } else if (B < C && C < A) {
    console.log("Yes");
    return;
  }

  console.log("No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int k,s;
    cin>>k>>s;
    int res = 0;
    for (int i = 0; i <=k; ++i)
    {
        for (int j = 0; j <=k; ++j)
        {
            if (0<=s-i-j && s-i-j<=k) res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,ans=0,cnt=0,tmp;
string s;
int main(){
  cin >> n;
  if(n==1){
    cout << "Hello World\n";
  }else{
    cin >>  m >> k;
    cout << m+k << endl;
  }
  return 0;
}

Measured memory_bytes: 256