akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define THE using
#define DARK namespace
#define ONE std
#define dbg(x) cout << #x << " = " << x << endl

THE DARK ONE;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    freopen("out.txt", "w", stdout);
//    freopen("input.txt", "r", stdin);
    vector<int> v(3);
    for(int i = 0; i < 3; i++)
        cin >> v[i];
    sort(v.rbegin(), v.rend());
    cout << stoi(to_string(v[0]) + to_string(v[1])) + v[2] << endl;
    return 0;
}



Measured memory_bytes: 256
def examB():
    a, b = LS()
    cur = int(str(a)+str(b))
    if cur//int(cur**(1/2))==cur**(1/2):
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll N, C;
ll h[200000];
ll dp[200000];
int deq[200000];
map<int, int> mp;

ll f(ll i, ll x){
    return -2*i*x+i*i+dp[mp[i]];
}

bool check(ll n1, ll n2, ll n3){
    ll a1 = -2*n1;
    ll a2 = -2*n2;
    ll a3 = -2*n3;
    ll b1 = dp[mp[n1]]+n1*n1;
    ll b2 = dp[mp[n2]]+n2*n2;
    ll b3 = dp[mp[n3]]+n3*n3;
    return (a2-a1)*(b3-b2) >= (b2-b1)*(a3-a2);
}

int main(){
    ll N, C;
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        mp[h[i]] = i;
    }
    int s = 0, t = 2;
    deq[0] = h[0];
    dp[0] = 0;
    dp[1] = (h[1]-h[0])*(h[1]-h[0])+C;
    deq[1] = h[1];
    for(ll i = 2; i < N; i++){
        while(s+1 < t){
            // cout << s << ' ' << f(deq[s], h[i]) << ' ' << f(deq[s+1], h[i]) << endl;
            if(f(deq[s], h[i]) > f(deq[s+1], h[i])) s++;
            else break;
        }
        dp[i] = f(deq[s], h[i])+h[i]*h[i]+C;
        // cout << s << ' ' << t << endl;
        while(s+1 < t && check(deq[t-2], deq[t-1], h[i])) t--;
        deq[t++] = h[i];
    }
    // for(ll i = 0; i < N; i++){
    //     cout << dp[i] << endl;
    // }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 13568
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] l = new long[n+1];
        l[0] = 2;
      	l[1]=1;
        for(int i = 2;i<=n;i++){
            l[i]=l[i-1]+l[i-2];
        }
        System.out.println(l[n]);
}
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#pragma _attribute_((optimize("-O2")))
#pragma comment(linker, "/STACK:102400000,102400000")

#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#include <iomanip>

//#define Local

using namespace std;
long long md = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input1.txt", "r", stdin);
	//freopen("output1.txt", "w", stdout);

	int k;
	cin >> k;
	string a, b;
	cin >> a >> b;
	long long res = 1;
	//long long tmp = 1;
	int now = 0;
	for (int i = 0; i < k; i++)
	{
		//cout << a[i] << " " << b[i] << "  By ";
		if (a[i] == b[i])
		{
			if (now == 0)
				res *= 3;
			else if (now == 1)
				res *= 2;
			else
				res *= 1;
			now = 1;
		}
		else
		{
			if (now == 0)
				res *= 6;
			else if (now == 1)
				res *= 2;
			else
				res *= 3;
			now = 2;
			i++;
		}
		//cout << res / tmp << "  Now " << res << endl;
		while (res > md)
			res -= md;
		//tmp = res;
	}
	cout << res%md << endl;

#ifdef Local
	cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif

	return 0;
}

Measured memory_bytes: 256
L = int(input())
num = 2
start = 1
end = 2
path = [[1, 2, 0], [1, 2, 1]]
func = []
def plus1(s, t, n):
	global num
	path.append([s, t, n])
	num += 1

def times2(s, t, n):
	global end, num
	for edge in path:
		edge[2] *= 2
	path.append([t, t+1, 0])
	path.append([t, t+1, 1])
	end += 1
	num *= 2

while L > 2:
	if L % 2 == 1:
		func.append(plus1)
		L -= 1
	else:
		func.append(times2)
		L //= 2
func.reverse()

for f in func:
	f(start, end, num)

print(end, len(path))
for u, v, w in path:
	print(u, v, w)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    int x=gcd(a,b);
    return (a/x)*b;
}
int n,a[130];
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    int mul=1,sum=0;
    rep(i,n){
        mul=lcm(mul,a[i]);
    }
    rep(i,n){
        sum+=mul/a[i];
    }
    double ans=1.000000000*mul/sum;
    printf("%.8LF\n",ans);
    return 0;
}


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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= t * s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3640
/**
  * @file pc.cpp
  * @brief atcoder

  *

  * @author yao
  * @date 2018-10-06
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define N 128
#define ft frist
#define sd second
#define INF ((int)2e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

class point{
public:
    int x, y, h;
}a[N];
int n,l,r;

bool check(int x,int y)
{
    l = 0, r = INF;
    for(int i=0;i<n;++i)
    {
        const point &p=a[i];
        int eh = p.h + abs(x-p.x) + abs(y-p.y);
        r = std::min(r,eh);
        if(p.h) l = std::max(eh,l);
    }
    return r>=l;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].h);
    for(int i=0;i<=100;++i)for(int j=0;j<=100;++j)if(check(i,j))
        return printf("%d %d %d\n",i,j,r), 0;
    dbg_pri("err: no answer\n");
    return 0;
}


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

#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
//long long mod=1000000007;
//int count=INT_MAX;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
int isPal(string a,string b){
    int n=a.size();
    fori(0,n){
        if(a[i]!=b[i]) return 0;
        
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    //cout<<t;
    //scanf("%d",&t);
    while(t--){
        int n;
        cin>>n;
        ll a[n];
        ll sum=0;
        unordered_map<ll,ll> m;
        fori(0,n){
            cin>>a[i];
            sum+=a[i];
            if(m.find(a[i])==m.end()){
                m[a[i]]=1;
            }
            else m[a[i]]++;
        }
        int q;
        cin>>q;
        while(q--){
            ll b,c;
            cin>>b>>c;
            ll bc=b*m[b];
            ll cc=c*m[b];
            sum=sum-bc+cc;
            //m.erase(b);
            if(m.find(c)==m.end()){
                m[c]=m[b];
            }
            else m[c]+=m[b];
            m.erase(b);
            cout<<sum<<endl;
        }
    }
    
    return 0;
}

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

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

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp1 = 0, tmp2 = i;
    while (tmp2 > 0) {
      tmp1 += tmp2 % 10;
      tmp2 /= 10;
    }
    if (tmp1 >= a && tmp1 <= b) {
      ans += i;
    }
  }
  cout << ans << endl;
}

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

int main() {
    string s;
    int n, q;
    cin >> n >> q;
    cin >> s;

    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++) {
      cin >> l[i] >> r[i];
    }

    // 累積和格納用
    vector<int> sum(n+1, 0);
    for (int i = 1; i < n; i++) {
      sum[i+1] = sum[i]; // i+1 Cの右肩に乗せる
      if (s[i - 1] == 'A' && s[i] == 'C') sum[i+1]++;
    }

    for (int i = 0; i < q; i++) {
      cout << sum[r[i]] - sum[l[i]] << endl;
    }

    return 0;
}



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

using namespace std;

#define PB push_back
#define f first
#define s second

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

const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

void setIO(string name)
{
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

ll dp[MAXN], p[MAXN], q[MAXN], r[MAXN];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //setIO("");
    ll x, y;
    ll a, b, c;
    cin >> x >> y >> a >> b >> c;
    for(int i=0; i<a; i++)
    {
        cin >> p[i];
    }
    for(int i=0; i<b; i++)
    {
        cin >> q[i];
    }
    for(int i=0; i<c; i++)
    {
        cin >> r[i];
    }

    sort(p, p+a);
    sort(q, q+b);
    sort(r, r+c);
    for(int i=a-x; i<a; i++)
    {
        dp[0] += p[i];
    }
    for(int i=b-y; i<b; i++)
    {
        dp[0] += q[i];
    }

    ll lo_red = a-x;
    ll lo_green = b-y;
    for(ll i=c-1; i>=0; i--)
    {
        ll num = c-i;
        ll comp1 = r[i];
        if(lo_red >= a && lo_green >= b)
        {
            break;
        }
        ll comp2 = -1, comp3 = -1;
        if(lo_red >= a)
        {
            comp3 = q[lo_green];
        }
        else if(lo_green >= b)
        {
            comp2 = p[lo_red];
        }
        else
        {
            comp2 = p[lo_red];
            comp3 = q[lo_green];
        }
        if(comp1 < min(comp2, comp3))
        {
            break;
        }
        ll sub;
        if(comp3 == -1)
        {
            sub = comp2;
            lo_red++;
        }
        else if(comp2 == -1)
        {
            sub = comp3;
            lo_green++;
        }
        else if(comp2 > comp3)
        {
            lo_green++;
            sub = comp3;
        }
        else
        {
            lo_red++;
            sub = comp2;
        }
        dp[num] = dp[num-1] + comp1 - sub;
    }

    ll ans = dp[0];
    for(int i=1; i<=c; i++)
    {
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

int main() {
    int N, K;
    cin >> N >> K;
    ll A[N];
    rep(i, N) cin >> A[i];

    for (int i = K; i < N; i++) {
        if (A[i - K] < A[i]) {
            cout << YES << endl;
        } else {
            cout << NO << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5192
# for i in range(m):
s = input()
t = input()
n = len(s)
m = len(t)
# print(s,t,n,m)
if n+1==m:
	for i in range(n):
		# print(s[i], t[i])
		if s[i]!=t[i]:
			print("No")
			break
	else:
		print("Yes")
else:
	print("No")
	# l, r = [int(j)-1 for j in input().split()]

Measured memory_bytes: 61748
def fac(n):
    global f
    rtn = {}
    while 1 < n:
        p = n // f[n]
        if p in rtn:
            rtn[p] += 1
        else:
            rtn[p] = 1
        if f[n] == 1:
            break
        n //= p
    return rtn

def div(n):
    dic = fac(n)
    rtn = [1]
    for k, v in dic.items():
        l = len(rtn)
        for i in range(l):
            for j in range(1, v + 1):
                rtn.append(rtn[i] * k**j)
    return rtn

n, k = map(int, input().split())
m = int(1e9 + 7)
f = [1 for _ in range(100001)]
for i in range(2, 100001):
    if f[i] == 1:
        for j in range(2, 100000 // i + 1):
            if f[i * j] == 1:
                f[i * j] = j

cnt = [0 for _ in range(k + 1)]
for i in range(k, 0, -1):
    cnt[i] += pow(k // i, n, m)
    ds = div(i)
    for d in div(i)[:-1]:
        cnt[d] -= cnt[i]
        cnt[d] %= m
for i in range(2, k + 1):
    cnt[i] *= i
    cnt[i] %= m
ans = sum(cnt) % m
print(ans)

Measured memory_bytes: 76156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int n;
  ll m;
  cin >> n >> m;
  vector<ll> v(n);
  vector<ll> sum(n+1,0);

  rep(i,n){
    cin >> v[i];
    sum[i+1] = sum[i] + v[i];
  }
  map<ll,int> cnt;
  ll ans = 0LL;
  for (int i = 0; i < n+1;i++){
    ans += cnt[ (sum[i])%m ];
    cnt[ sum[i]%m ]++;
  }
  cout << ans << endl;




  return 0; 
}



Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		scanner.close();

		if (A <= 8 && B <= 8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl




int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b)cout<<0<<endl;
    else if(n==1){
        cout<<(int)(a==b)<<endl;
    }else{
        ll mi=a*(n-2);
        ll ma=b*(n-2);
        cout<<ma-mi+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int sx,sy,tx,ty;
  int res=0;
  cin >> sx >> sy >> tx >> ty;

  int x=sx, y=sy;
  int gx=tx, gy=ty;

  for(int i=0; i<4; i++){
    if(i==1) {gx=sx; gy=sy;}
    else if(i==2) {
      cout << 'L';
      x--;
      gx=tx;gy=ty+1;
    }
    else if(i==3){
      cout << 'R';
      x++;
      gx=sx; gy=sy-1;
    }
    while(y!=gy){
      if(y<gy) {
        cout << 'U';
        y++;
      }
      else if(y>gy) {
        cout << 'D';
        y--;
      }
    }
    while(x!=gx){
      if(x<gx) {
	cout << 'R';
	x++;
      }
      else if(x>gx){
	cout << 'L';
	x--;
      }
    }
    if(i==2){
      cout << 'D';
      y--;
    }
    if(i==3){
      cout << 'U';
      y++;
    }
  }

  cout << endl;
}


Measured memory_bytes: 256
n=int(input())
XY=[list(map(int,input().split())) for _ in range(n)]
ans=0
N=0
tmp=0
from itertools import permutations
from math import hypot 
for i in permutations(XY):
  N+=1
  for (x,y),(x1,y1) in zip(i,i[1:]):
    tmp+=hypot(x-x1,y-y1)

print(tmp/N)

Measured memory_bytes: 41836
package main

import "fmt"

var N int
var s string
var ans map[string]int
func main() {
	fmt.Scan(&N)
	ans = make(map[string]int)
	for i:=0; i<N; i++ {
		fmt.Scan(&s)
		ans[s]++
	}
	fmt.Println(len(ans))
}


Measured memory_bytes: 22132
#include<stdio.h>
#define MAX 1000000

int kcount(int,int);
int a[MAX],b[MAX],c[MAX];

int main(){
    int i,count=0,keta;
    
    i=1;
    while(scanf("%d %d",&a[i],&b[i]) != EOF){
        i++;
        count++;
    }
    
    for(i=1; i<=count; i++){
        c[i] = a[i] + b[i];
    }
    
    for(i=1; i<=count; i++){
    keta=kcount(c[i],0);
    if(keta == 0) c[i] = 1;
    else c[i] = keta;
    }
       
    for(i=1;  i<= count; i++){
    printf("%d\n",c[i]);
    }
    
    return 0;
}


int kcount(int c,int count){
    
    if(c==0) return count;
    else {
        c/=10;
        count++;    
        kcount(c,count);
    }
}

Measured memory_bytes: 5124
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    A = LI()
    print(A.index(0)+1)

main()


Measured memory_bytes: 9480
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(void){
  int n;
  cin >> n;
  long long a[n+1];
  for(int i=1;i<=n;++i){
    cin >> a[i];
  }

  long long S1, S2;
  long long ans[2];


/* first term is positive */
  if(a[1] > 0){
    S1 = a[1];
    ans[0] = 0;
  }
  else{
    S1 = 1;
    ans[0] = llabs(a[1]) + 1;
  }

  FOR(i, 2, n+1){
    S2 = S1 + a[i];
    if((S1 < 0 && S2 > 0) || (S1 > 0 && S2 < 0)){
      S1 = S2;
    }
    else{
      ans[0] += llabs(S2) + 1;
      if(S1 < 0) S2 = 1;
      else S2 = -1;
      S1 = S2;
    }
  }

/* first term is negative */
  if(a[1] < 0){
    S1 = a[1];
    ans[1] = 0;
  }
  else{
    S1 = -1;
    ans[1] = llabs(a[1]) + 1;
  }

  FOR(i, 2, n+1){
    S2 = S1 + a[i];
    if((S1 < 0 && S2 > 0) || (S1 > 0 && S2 < 0)){
      S1 = S2;
    }
    else{
      ans[1] += llabs(S2) + 1;
      if(S1 < 0) S2 = 1;
      else S2 = -1;
      S1 = S2;
    }
  }


    printf("%lld\n", min(ans[0], ans[1]));

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int n,m,o;
    int a[101][101],b[101][101],c[2],r[3]={0};
    int d=0,e=0,f=0,ans=0;
    int x,y,z;
    int h,i,j;
    while(1){
        scanf("%d",&n);
        if(n==0){
            break;
        }
        scanf("%d",&m);
        for(h=0;h<m;h++){
            scanf("%d,%d,%d",&x,&y,&z);
            a[x][y]=1;
            a[y][x]=1;
            b[x][y]=z;
            b[y][x]=z;
        }
        while(1){
            e=0;
            for(h=0;h<n;h++){//????¢????
                d=0;
                for(i=0;i<n;i++){
                    if(a[h][i]==1){
                        c[0]=h;
                        c[1]=i;
                        d++;
                    }
                }
                if(d==1){
                    ans=ans+b[c[0]][c[1]];
                    a[c[0]][c[1]]=0;
                    a[c[1]][c[0]]=0;
                    e++;
                }
            }
            if(e==0){//?????????
                r[0]=0;
                r[1]=0;
                r[2]=0;
                for(h=0;h<n;h++){
                    for(i=0;i<n;i++){
                        if(a[h][i]==1){
                            if(b[h][i]>=r[2]){
                                r[0]=h;
                                r[1]=i;
                                r[2]=b[h][i];
                            }
                        }
                    }
                }
                a[r[0]][r[1]]=0;
                a[r[1]][r[0]]=0;
            }
            f=0;
            for(h=0;h<n;h++){//break
                for(i=0;i<n;i++){
                    if(a[h][i]==1){
                        f++;
                    }
                }
            }
            if(f==0){
                break;
            }
        }
        ans=ans/100-n+1;
        printf("%d\n",ans);
    }
    return 0;
}

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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)

int main() {
  int N;
  cin >> N;
  set<string> a;
  REP(i,N) {
    string s; cin>>s;
    a.insert(s);
  }
  cout << (a.size() == 4 ? "Four" : "Three") << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<array>
#include<vector>
struct trie{
	struct node{
		array<int,26>next;
		int cnt;
		bool id;
		node():cnt(0),id(false){next.fill(-1);}
	};
	vector<node>v;
	trie(){v.push_back(node());}
	bool add(const string&s)
	{
		int p=0;
		for(int i=0;i<s.size();i++)
		{
			v[p].cnt++;
			int j=s[i]-'a';
			if(v[p].next[j]<0)
			{
				v[p].next[j]=v.size();
				v.push_back(node());
			}
			p=v[p].next[j];
		}
		v[p].cnt++;
		v[p].id=true;
		return true;
	}
};
int N,Q;
string s[1<<17];
const int B=500;
int table[B][B];
main()
{
	cin>>N;
	trie P;
	for(int i=0;i<N;i++)
	{
		cin>>s[i];
		P.add(s[i]);
	}
	if(N<B)
	{
		for(int i=0;i<N;i++)for(int j=i+1;j<N;j++)
		{
			int k=0;
			while(k<s[i].size()&&k<s[j].size()&&s[i][k]==s[j][k])k++;
			table[i][j]=table[j][i]=k;
		}
	}
	cin>>Q;
	for(;Q--;)
	{
		int k;string p;cin>>k>>p;
		k--;
		int ans=0,id=0;
		if(N<B)
		{
			for(int i=0;i<N;i++)if(i!=k)
			{
				int t=table[i][k];
				if(t>=s[i].size())ans++;
				else if(t<s[k].size())
				{
					char x=s[i][t],y=s[k][t];
					int j=0;
					while(p[j]!=x&&p[j]!=y)j++;
					if(p[j]==x)ans++;
				}
			}
		}
		else
		{
			for(int i=0;i<s[k].size();i++)
			{
				if(P.v[id].cnt==1)break;
				int j=0;
				while(s[k][i]!=p[j])
				{
					if(P.v[id].next[p[j]-'a']>=0)
					{
						ans+=P.v[P.v[id].next[p[j]-'a']].cnt;
					}
					j++;
				}
				if(P.v[id].id)ans++;
				id=P.v[id].next[p[j]-'a'];
			}
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 62444
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
     
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}
 
    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]
 
        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
    def get_nums(self):   
        return {self.u,self.w,self.s,self.e,self.n,self.w,self.d}

def mk_dice():
    u,s,e,w,n,d=map(int,input().split())
    return Dice(u,w,s,e,n,d)
 
import random
q=int(input())
dice_col=[]
ans=True
for j in range(q):
    dice_b=mk_dice()
    for dice in dice_col:
        if(dice.get_nums()==dice_b.get_nums()):
            for i in range (1000):
                dice.rot(random.randint(0,2))
                if(dice.u==dice_b.u and dice.d==dice_b.d and dice.w==dice_b.w and dice.s==dice_b.s and dice.e==dice_b.e and dice.n==dice_b.n):
                    ans=False
        if ~ans:
            break
    dice_col.append(dice_b)
 
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 11816
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int people[100] = {0};
int main(){
    int N,K;
    cin >> N >> K;
    for(int i = 0;i<K;i++){
        int amount,A;
        cin >>amount;
        for(int j =0;j<amount;j++){
            cin >> A;
            people[A] = 1;
        }
    }
    int count = 0;
    for(int i =1;i<=N;i++){
        if(people[i] != 1){
            count++;
        }
    }
    cout <<count;
}

Measured memory_bytes: 3196
h,n = map(int,input().split())
now = [10**10 for _ in range(h+1)]
now[0] = 0
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(1,h+1):
    if i - a < 0:
      now[i] = min(now[i],b)
    else:
      now[i] = min(now[i],now[i-a]+b)
print(now[-1])

Measured memory_bytes: 45828
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a-1)/b+1;}
//Read:
//Use __builtin_popcountll for ll

signed main(){
    int n;cin>>n;
    vi v(n);cin>>v;
    sort(all(v));
    int ans=1;
    for(int i:v){
        if(i>0 && ans>(int)1e18/i){
            cout<<-1;
            return 0;
        }
        ans*=i;
    }
    cout<<ans;
}


Measured memory_bytes: 4048
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
int main() {
	string s;
	cin >> s;
	for (int i = 0;i < s.length() - 8;++i) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

namespace A___Airplane
{
    class Program
    {
        static void Main(string[] args)
        {
            var PQR = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();

            Console.WriteLine(PQR.Take(2).Sum());
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>

#define REP(i, a, b) for(i = a; i<b; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

bool Solution(int data)
{
	int i;

	if (data < 2) 
	{
		return false;
	}
	else if (data == 2) 
	{
		return true;
	}

	if(data % 2 == 0) 
	{
		return false;
	}

	for (i = 3; i * i <= data; i += 2) 
	{
		if (data % i == 0) 
		{
			return false;
		}
	}

	return true;

}

int main()
{
	int n, m, i; 
	int count = 0;
	
	cin >> n;
	
	rep(i, n) 
	{
		cin >> m;
		if (Solution(m)) 
		{
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cctype>
#include<cstring>
using namespace std;

int main() {
  char c;
  int arr[26] = {};
  while( cin >> c ) {
    if(isalpha(c)) arr[tolower(c) - 'a']++; 
  }

  char alpha[27] = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < 26; i++) {
    cout << alpha[i] << " : ";
    cout << arr[i] << endl;
  }

  return 0;
}



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

ll dp[109][100009];
int wt[109];
ll v[109];
ll knapSack(int n,int w){

    if(n<0) return 0;
    else if(wt[n]>w) knapSack(n-1,w);
    else if(dp[n][w]!= -1) return dp[n][w];
    else{

        dp[n][w] = max(v[n]+knapSack(n-1,w-wt[n]),knapSack(n-1,w));
        return dp[n][w];
    }

}


int main(){
    //freopen("input","r",stdin);
    memset(dp,-1,sizeof(dp));
    int n,w;
    cin >> n >> w;
    for(int i=0;i<n;i++) cin >> wt[i] >> v[i];
    cout << knapSack(n-1,w) << endl;



return 0;
}



Measured memory_bytes: 85504
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n , m ,ans ,dx[]={-1,1,0,0},dy[]={0,0,1,-1};
char a[1009][1009];
vector<pair<int,int> > v ,vv;
bool valid (int i ,int j)
{
    if(i<1||i>n||j<1||j>m)
        return false ;
    return true ;
}
void solve(int i ,int j)
{
    int cnt=0;
    for(int k=0;k<4;k++)
    {
        int newx=i+dx[k] , newy=j+dy[k] ;
        if(a[newx][newy]=='.'&&valid(newx,newy))
        cnt++ , vv.push_back({newx,newy}) , a[newx][newy]='#';
    }
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            scanf(" %c",&a[i][j]);
            if(a[i][j]=='#')
            v.push_back({i,j});
        }
    while(!v.empty())
    {
       for(auto i :v)
       {
        int x=i.first , y=i.second;
            solve(x,y);
       }
       v=vv;
       vv.clear();
       ans++;
    }
    cout<<ans-1;

    return 0;
}


Measured memory_bytes: 14952
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000000;
int exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1){
        if(exp(x,y-1)==-1)return -1;
        if(x*exp(x,y-1)>big)return -1;
        return (exp(x,y-1)*x);
    }
    ll t=exp(x,y/2);
    if(t==-1||t*t>big)return -1;
    return (t*t);
}

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


ll in(ll x){
    return exp(x,big-2);
}

int half(int k,vector<int> &eat,int l,int r,bool aaa){//[l,r)
    if(aaa){
        ll j=1;
        while(j<=r-1){
            if(eat[j]>k)return half(k,eat,j/2-1,j,false);
            j*=1;
        }
        return half(k,eat,j/2-1,r,false);
    }
    if(r-l==1)return r;
    int m=(l+r)/2;
    if(eat[m]>k){
        return half(k,eat,l,m,false);
    }else{
        return half(k,eat,m,r,false);
    }
}

int find(int k,vector<int> &eat,int chi){
    if(eat[chi-1]<k)return -1;
    if(eat[0]>k)return 0;
    int s=half(k,eat,0,chi,true);
    return s;
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    char s;cin >> s ;
    if(s-'a'>=0&&s-'a'<26)cout << 'a';
    else cout << 'A' ;
    cout << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define rall(a)		(a).rbegin(), (a).rend()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int mod = 1000000007;
const int INF = 1e9;

vector<bool> era;

void initera(int n){
	era.resize(n, true);

	era[0] = false; era[1] = true;
	for (int i = 2; i < n; i++){
		if (era[i])for (int j = i * 2; j < n; j += i)
			era[j] = false;
	}
}

int main()
{
	initera(1299709+10);
	int n;
	while (cin >> n && n){
		int k = 0;
		int a, b;
		for (a = n; !era[a]; a--);
		for (b = n; !era[b]; b++);
		cout << b - a << endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

string s;
int g[2];
vector<int> V[2];

bool ok() {
	REP(i,2) {
		bitset<40000> bt;
		bt.set(20000);
		for(int e:V[i]) bt=(bt>>e)|(bt<<e);
		if(!bt[g[i]]) return false;
	}
	return true;
}

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

	cin>>s>>g[0]>>g[1];
	int now=0,i=0,cnt=0;
	while(i<s.size()&&s[i]=='F') i++,g[0]--;
	i++;
	g[0]+=20000,g[1]+=20000;
	while (i<s.size()) {
		cnt=0;
		while(i<s.size()&&s[i]=='F') cnt++,i++;
		now^=1,i++;
		if(cnt==0) continue;
		V[now].pb(cnt);
	}

	if(ok()) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define pi 3.14159265359
int INF = 1000000000;

int main() {
  string S; cin >> S;
  bool e_flag = true, o_flag = true;
  rep(i, S.size()) {
    if (i % 2 == 0) {
      if (S[i] == 'L') e_flag = false;
    }
    if (i % 2 == 1) {
      if (S[i] == 'R') o_flag = false;
    }
  }
  if (e_flag && o_flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    ll n,a,b,c;
    cin>>n;
    ll arr[n][3];
    for(ll i=0;i<n;i++)
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    
    ll dp[n][3];
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    
    for(ll i=1;i<n;i++){
        dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    
    ll ans = max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4992
a = input().split(" ")
N = int(a[0])
M = int(a[1])
ans1 = 10
ans2 = 10
ans3 = 10
x = 0
for i in range(M):
    b = input().split(" ")
    c = int(b[0])
    d = int(b[1])
    if c == 1:
        if ans1 == 10:
            if d == 0:
                if N == 1:
                    ans1 = 0
                else:
                    x = 1
            else:
                ans1 = d
        elif ans1 != d:
            x = 1
    elif c == 2:
        if ans2 == 10:
            ans2 = d
        elif ans2 != d:
            x = 1
    else:
        if ans3 == 10:
            ans3 = d
        elif ans3 != d:
            x = 1
if ans1 == 10:
    if N == 1:
        ans1 = 0
    else:
        ans1 = 1
if ans2 == 10:
    ans2 = 0
if ans3 == 10:
    ans3 = 0

if x == 1:
    print(-1)
else:
    if N == 1:
        print(ans1)
    elif N == 2:
        if ans1 == 0:
            print(-1)
        else:
            print(str(ans1) + str(ans2))
    else:
        if ans1 == 0:
            print(-1)
        else:
            print(str(ans1) + str(ans2) + str(ans3))

Measured memory_bytes: 3064
N=2**20-1
R=range
(n,q),c,*z=[[*map(int,t.split())]for t in open(0)]
t,*o=B=[0]*N
A=[[n]for _ in B]
for i in R(n):A[c[~i]]+=~i+n,
def P(a,x):
	i=a[-1]+1
	while i<N:B[i]+=x;i+=i&-i
for i in A:P(i,1)
for x in sorted(i|z[i][0]<<40|z[i][1]<<20for i in R(q)):
	l,r,i=(x>>40)-1,x>>20&N,x&N
	while t<l:b=A[c[t]];P(b,-1);b.pop();P(b,1);t+=1
	while r:o[i]+=B[r];r-=r&-r
	while l:o[i]-=B[l];l-=l&-l
print(*o[:q])

Measured memory_bytes: 303472
import itertools

H, W, K = map(int, input().split())
S = [input() for i in range(H)]
ans = 0
for si in itertools.product([0, 1], repeat=H):
    for sj in itertools.product([0, 1], repeat=W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if si[i] or sj[j]:
                    continue
                if S[i][j] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)


Measured memory_bytes: 9116
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N;

signed main(){

    in(N);
    out(N*800-N/15*200);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=ans*a;
        }
        b>>=1;
        a=a*a;
    }
    return ans;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    printf("%d\n",(1900*m+100*(n-m))*power(2,m));
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

cnt = Counter(D)
for t in T :
  if cnt[t] == 0 :
    print('NO')
    break
  else :
    cnt[t] -= 1
else :
  print('YES')

Measured memory_bytes: 127700
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
char c[9][9];
int OK=0;int h,w;
void Dfs(int x,int y){
	if(x==h&&y==w) {
		OK=1;
		return;
	}
	if(x+1<=h&&c[x+1][y]=='#'){
		c[x+1][y]='.';
		Dfs(x+1,y);
	}
	else{
		if(y+1<=w&&c[x][y+1]=='#'){
			c[x][y+1]='.';
			Dfs(x,y+1); 
		}
		else return;
	}
}
int main(){
	cin>>h>>w;
	rb(i,1,h)
		rb(j,1,w) cin>>c[i][j];
	if(c[1][1]!='#'||c[h][w]!='#'){
		puts("Impossible");
		return 0;
	}
	c[1][1]='.';
	Dfs(1,1);
	rb(i,1,h)
		rb(j,1,w){
			if(c[i][j]=='#'){
				puts("Impossible");
		return 0;
			}
		}
	if(OK) puts("Possible");
	else puts("Impossible");
	return 0;
}


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

using namespace std;

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

	while(min(a,c)>0){
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;
			break;
		}

		a-=d;
		if(a<=0){
			cout<<"No"<<endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n+1];
    rep1(i,n) cin >> a[i];
    for(int i = k+1; i <=n;i++){
        if(a[i-k] < a[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3584