akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int to, from, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
//
//
//
//          ∧ ∧  ／￣￣￣￣￣￣￣￣￣￣￣￣￣
// ～′￣￣( ˚д˚)＜  Let's start coding!!
//  UU￣￣  U U  ＼
//                 ￣￣￣￣￣￣￣￣￣￣￣￣￣

string s;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> s;
  int n = s.size();
  int t = 0;
  if (n == 1) {
    cout << s << endl;
    return 0;
  }
  bool flag = false;
  rep(i, 1, n) {
    if (s[i] != '9') {
      flag = true;
      break;
    }
  }
  if (flag) cout << 9 * (n-1) + s[0] - '1' << endl;
  else cout << 9 * (n-1) + s[0] - '0' << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int e, o, ans=0, i;
    cin >> e >> o;

    for(i=1; i<e; i++) {
        ans += i;
    }
    for(i=1; i<o; i++) {
        ans += i;
    }

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


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

#define int long long

signed main(){
    int n , cur; cin >> n;
    
    int cnt = 0 , pre = LLONG_MAX;
    int ans = 1;
    for(int i = 1; i <= n; i++){
               cin >> cur;
               if(cur <= pre){
                   cnt++;
               }
               else{
                   ans = max(ans,cnt);
                   cnt = 1;
               }
               pre = cur;
    }
    ans = max(cnt , ans);
    ans--;
    cout << ans << '\n';
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.trim().split(' ')
	const a = parseInt(args[0], 10)
	const b = parseInt(args[1], 10)
	const t = parseInt(args[2], 10)
	console.log(Math.floor((t * 1000 + 500) / (a * 1000)) * b)
}

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


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

int count[3][1000];
int data[1000][3];

int main() {
	int N,i,j,k;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		for (j = 0; j < 3; j++) {
			scanf("%d", &k);
			data[i][j] = k;
			count[j][k]++;
		}
	}
	for (i = 0; i < N; i++) {
		int sum = 0;
		for (j = 0; j < 3; j++) {
			if (count[j][data[i][j]] == 1) sum += data[i][j];
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll 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;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main(){
  string s;
  cin>>s;
  int n=len(s);
  vi T(26);
  string t=tr;
  rep(i,n){
    rep(j,26){
      if(s[i]==t[j]){
        T[j]++;
      }
    }
  }
  if(n<26){
    rep(i,26){
      if(T[i]==0){
        s+=t[i];
        break;
      }
    }
    cout<<s<<endl;
    return 0;
  }
  if(n==26){
    vector<char> vec;
    for (int i = 0; i < s.size(); ++i) {
    vec.push_back(s[i]);
    }
    if (next_permutation(s.begin(), s.end())) {
                string res = "";
                for (int i = 0; i < s.size(); ++i) {
                    res += s[i];
                    if (vec[i] != s[i]) break;
                }
                cout << res << endl;
            }
            else {
                cout << -1 << endl;
            }
  }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    int i,j;
    for(i=0;i<n;i++)cin >> p.at(i);
    int t=0;
    int te=p.at(0);
    for(i=0;i<n;i++){
        te=max(te,p.at(i));
        if(te==p.at(i))t=i;
    }
    int sum=0;
    for(i=0;i<n;i++){
        if(i==t){
            sum+=p.at(i)/2;
        }
        else{
            sum+=p.at(i);
            }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n, m, p, q, r;
	static int[][] cost, time;
	public static void main(String[] args) {
		while(read()){
			//solve();
		}
	}
	
	static boolean read(){
		n = sc.nextInt();
		m = sc.nextInt();
		if(n == 0 && m == 0)return false;
		
		cost = new int[m+1][m+1];
		time = new int[m+1][m+1];
		
		for(int formatting[] : cost)Arrays.fill(formatting, 1<<29);
		for(int formatting[] : time)Arrays.fill(formatting, 1<<29);
		
		for(int i = 1; i <= n; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			cost[a][b] = cost[b][a] = sc.nextInt();
			time[a][b] = time[b][a] = sc.nextInt();
		}
		
		solve();
		
		int k = sc.nextInt();
		for(int i = 0; i < k; i++){
			p = sc.nextInt();
			q = sc.nextInt();
			r = sc.nextInt();
			res();
		}
		
		return true;
	}
	
	static void solve(){
		for(int k = 0; k <= m; k++){
			for(int i = 0; i <= m; i++){
				for(int j = 0; j <= m; j++){
					cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);
					time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]);
				}
			}
		}
	}
	
	static void res(){
		if(r == 0){
			System.out.println(cost[p][q]);
		}else{
			System.out.println(time[p][q]);
		}
	}

}

Measured memory_bytes: 0
#include <stdlib.h>
#include <stdio.h>

int main(void){
  int q;
  scanf("%d",&q);
  int A[200010];
  int pointer=0;
  int command;
  int x;
  int p;
  for(int i=0;i<q;i++){
    scanf("%d",&command);
    if(command==0){
      scanf("%d",&x);
      A[pointer]=x;
      pointer++;
    }
    if(command==1){
      scanf("%d",&p);
      printf("%d\n",A[p]);
    }
    if(command==2){
      pointer-=1;
    }
  }
  return 0;
}



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

#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"

typedef long long ll;
typedef long double ld;

const ld pi=3.1415926535897932384626433;
const int mod = 1000000007;
const ll inf=3e18;
bool check(ll i)
{
   set <char> d;
   string s=to_string(i);
   for (ll k=0;k<s.size();k++)
   {
      d.insert(s[k]);
   }
   if (d.size()==1)
      return true;
   return false;
}
int main()
{
   bolt;
   ll n;
   cin>>n;
   for (ll i=n;i<=999;i++)
   {
      if (check(i))
         return cout<<i, 0;
   }
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.array;
import std.range;
import std.regex;

void main(){
	auto a=readln.chomp.to!int;
	if(a<1200)writeln("ABC");
	else if(a>=1200&&a<2800)writeln("ARC");
	else if(a>=2800)writeln("AGC");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> x (5);
  for(int i =0; i < 5; i++){
    cin >> x[i];
  }
  for(int i = 0; i < 5; i++){
    if(x[i] == 0){
      cout << i+1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3596
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

from decimal import *
a,b = MS()
a = int(a)
b = Decimal(b)
ans = int(a*b)
print(ans)

Measured memory_bytes: 77300
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int ans[100010]={};

struct UnionFind{
    vector<int> data;
    UnionFind(int sz){
        data.assign(sz, -1);
    }
    int find(int p){
        if(data[p]<0) return p;
        return data[p]=find(data[p]);
    }
    bool unite(int X, int Y){
        X=find(X), Y=find(Y);
        if(X==Y) return false;
        if(data[X]>data[Y]) swap(X, Y);
        data[X] += data[Y];
        data[Y]=X;
        return true;
    }
    int size(int k){
        return -data[find(k)];
    }
};

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	UnionFind uf(N+1);
	for(int i=0; i<M; ++i){
		int A, B;
		cin >> A >> B;
		--ans[A];
		--ans[B];
		uf.unite(A, B);
	}
	for(int i=1; i<=N; ++i){
		ans[i] += uf.size(i)-1;
	}
	for(int i=0; i<K; ++i){
		int C, D;
		cin >> C >> D;
		if(uf.find(C)==uf.find(D)){
			--ans[C];
			--ans[D];
		}
	}
	cout << ans[1];
	for(int i=2; i<=N; ++i) cout << ' ' << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int qabc[314];
struct chck{
  int i, j, k, r;
  void nxt(void){
    scanf("%d%d%d%d",&i,&j,&k,&r); return;
  }
};
vector<chck> ns;

bool isok(chck qwe, chck rty){
  return qwe.r > rty.r;
}

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int3(a, b, c);
    if(!(a | b | c))break;
    rep(i, 300)qabc[i] = 2;

    int(n);
    ns.resize(n);
    rep(i, n)ns[i].nxt();
    sort(all(ns), isok);
    rep(i, n){
      if(ns[i].r == 1){
        qabc[ns[i].i] = 1;
        qabc[ns[i].j] = 1;
        qabc[ns[i].k] = 1;
      }else{
        if(qabc[ns[i].i] * qabc[ns[i].j] * qabc[ns[i].k] == 2){
          if(qabc[ns[i].i] == 2)qabc[ns[i].i] = 0;
          if(qabc[ns[i].j] == 2)qabc[ns[i].j] = 0;
          if(qabc[ns[i].k] == 2)qabc[ns[i].k] = 0;
        }
      }
    }
    rep(i, a + b + c)pri(qabc[i + 1]);
    ns.clear();
//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3216
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		int min = 0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			if(x[i]>k-x[i]){
				min += 2*(k-x[i]);
			}
			else{
				min += 2*x[i];
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21844
/**
 *    author:  tourist
 *    created: 18.12.2019 11:34:51       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
  }                   
  vector<int> dp(n, -1);
  function<void(int)> Dfs = [&](int v) {
    if (dp[v] != -1) {
      return;
    }
    dp[v] = 0;
    for (int u : g[v]) {
      Dfs(u);
      dp[v] = max(dp[v], dp[u] + 1);
    }
  };
  for (int i = 0; i < n; i++) {
    Dfs(i);
  }
  cout << *max_element(dp.begin(), dp.end()) << '\n';
  return 0;
}


Measured memory_bytes: 8832
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<long, long, greater<long> >::iterator;

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

	// long long?
	long long H, W, h, w;
	cin >> H >> W >> h >> w;

	cout << (H-h)*(W-w) << endl;
	return 0;

}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if (500 * i + 100 * j + 50 * k)  == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 212345;

int n, m, k;
int s[MAXN];

int main (){
	scanf("%d", &n);
	for(int a=0;a<n;a++){
        scanf("%d", s+a);
	}
    sort(s, s+n);
    int ans = 0;
    for(int a=0;a<n;a++){
        for(int b=a+1;b<n;b++){
            if(s[b] == s[a]) continue;
            for(int c=b+1;c<n;c++){
                if(s[c] == s[b]) continue;
                if(s[a] + s[b] > s[c]) {
                    ans++;
                }
            }
        }
    }
    printf("%d\n", ans);
}



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


int main() {
	
	string a,b,c;
	cin >> a >> b >> c;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	
	char turn = 'a';
	while(1){
		if (turn == 'a'){
			if(a.back() == 0){
				cout << "A" << endl;
				break;
			}
			else{
				turn = a.back();
				a.pop_back();
			}
		}
		
		else if (turn == 'b'){
			if(b.size() == 0){
				cout << "B" << endl;
				break;
			}
			else{
				turn = b.back();
				b.pop_back();
			}			
		}
		
		else if (turn == 'c'){
			if(c.size() == 0){
				cout << "C" << endl;
				break;
			}
			else{
				turn = c.back();
				c.pop_back();
			}	
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
	val(h,w,n)= readLine()!!.split(" ").map {it.toInt()}
	val ab = (1..n).map {
		val (y,x)=readLine()!!.split(" ").map {it.toLong()-1}
		return@map y*w+x
	}
	val map = mutableMapOf<Long,Int>()
	ab.forEach {
		for(dy in -1..1)for(dx in -1..1){
			val y=it/w+dy
			val x=it%w+dx
			if(1<=y&&y<=h-2 && 1<=x&&x<=w-2){
				val p=y*w+x
				if(map.containsKey(p)){
					map[p]=map[p]!!+1
				}else{
					map[p]=1
				}
			}
		}
	}
	val ans = map.toList().map{it.second}
					.groupBy {it}.mapValues {it.value.size}
	
	println( (h-2).toLong()*(w-2).toLong() - ans.toList().sumBy {it.second})
	for(i in 1..9){
		if(ans.containsKey(i)){
			println(ans[i])
		}else{
			println(0)
		}
	}
}

Measured memory_bytes: 188240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(x) scanf("%lld", &x)
#define prnt(x) printf("%lld", x)
#define nl printf("\n")
#define white 0
#define red 1
#define blue -1
ll total=0,on=1;
vector<ll>number[4];
vector<ll>spc;
vector<ll>real_m;
vector< pair <ll,ll> > vect; 
ll zanisari[1009];
ll orac[100009];
vector<ll>zog;
vector<ll>biog;
vector<ll>graph[209];
map<ll,ll>color;
map<ll,ll>vis;
ll bipertite=1;
void dfs(ll src)
{
   if(color[src]==white)
   {
     color[src]=red;	
   }
   for(ll i=0;i<graph[src].size();i++)
   {
      ll v=graph[src][i];
      if(color[v]==white)
      {
         if(color[src]==red)
          color[v]=blue;
         else if(color[src]==blue)
           color[v]=red;
             dfs(v);   	
      }
      if(color[src]==color[v]){
         bipertite=-1;
         //return;
       }
        	
   }
  // return 1;	
}
int main()
{
    
  ll a,b,c,d,e,f,g,h=0,i,j,k,l=1,p=1,q,r=-1,s,t,n,ans=1,cnt1=0,m,u,v=0,w,x;
  //const long long int fc=0,fc1=1,fc2=2;
  //sjkskjskjsklkslsklslksklsklsklskmllsk
  //scl(t);
  cin>>a>>b>>c>>d;
  h=max(a*c,max(a*d,max(b*c,b*d)));
  cout<<h;
     
      
      
      
      
      
      
  }





Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N;
	cin >> N;

	if (N % 2 == 0) {
		cout << 0.5;
	}
	else {
		cout << std::setprecision(10)<<(double)((N / 2) + 1) / N;
	}


}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


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

using namespace std;

inline int nextInt();
int N;
long long A[200000], B[200001], SUM[4];
long long ans = INT64_MAX;
void renew(int i, int j, int k) {
    SUM[0] = B[j];
    SUM[1] = B[i]-B[j];
    SUM[2] = B[k]-B[i];
    SUM[3] = B[N]-B[k];
    long long mx = 0, mn = INT64_MAX;
    for (long long S : SUM) {
        if (S > mx) mx = S;
        if (S < mn) mn = S;
    }
    ans = min(ans, mx - mn);
}
int main() {
    N = nextInt();
    for (int i = 0; i < N; ++i) A[i] = nextInt();
    for (int i = 0; i < N; ++i) {
        B[i + 1] = B[i] + A[i];
    }
    int j = 1, k = 3;
    for (int i = 2; i < N-1; ++i) {
        while (B[i]-B[j] > B[j] && j < i-1) j++;
        while (B[N]-B[k] > B[k]-B[i] && k < N-1) k++;
        renew(i, j, k);
        if (j > 1) renew(i, j-1, k);
        if (k > i+1) renew(i, j, k-1);
        if (j > 1 && k > i+1) renew(i, j-1, k-1);
    }
    printf("%lld\n", ans);
    return 0;
}

inline int nextInt() {
    int x = 0, f = 1;
    int c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

Measured memory_bytes: 3328
/**
 * @param {String} input
 */
function Main(input){
	var inputs = input.split("\n")[0].split(' ').map(function (num){return Number(num);});
    var a = inputs[0];
    var b = inputs[1];
    var c = inputs[2];
    var d = inputs[3];
    if(b < c || d < a) return 0;
    var longestSec = Math.max(b,d) - Math.min(a,c);
    return longestSec - Math.abs(a-c) - Math.abs(b-d);
}
console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, M;
  cin >> N >> M;
  vector<long> data(N, INT_MAX);
  vector<vector<long>> path(N, vector<long> ());
  long a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    path.at(a - 1).push_back(b - 1);
    path.at(b - 1).push_back(a - 1);
  }
  queue<long> que;
  que.push(0);
  long size, sub;
  while(que.size() != 0){
    size = que.size();
    for(int i = 0; i < size; i++){
      sub = que.front();
      que.pop();
      for(unsigned int j = 0; j < path.at(sub).size(); j++){
        if(data.at(path.at(sub).at(j)) == INT_MAX){
          data.at(path.at(sub).at(j)) = sub;
          que.push(path.at(sub).at(j));
        }
      }
    }
  }
  cout << "Yes" << endl;
  for(int i = 1; i < N; i++)cout << data.at(i) + 1 << endl;
  return 0;
}


Measured memory_bytes: 12856
#include <stdio.h>
#define M 1000000007
typedef long long LL;

int read()
{
	char c;
	while((c = getchar()) < 48 || c > 57);
	int x = c - 48;
	while((c = getchar()) > 47 && c < 58) x = x * 10 + c - 48;
	return x;
}

int main()
{		
	int n, s, i, x;
	LL ss = 0;
	
	n = read();
	s = read();
	for(i = 1; i < n; i++){
		x = read();
		ss += (LL)x * (LL)s % M;
		s += x;
		if(s >= M) s -= M;
	}
	printf("%lld\n", ss % M);
				
	return 0;
}

Measured memory_bytes: 1604
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

struct Info{
	Info(){ left = height = 0;}
	Info(int arg_left,int arg_height){
		left = arg_left;
		height = arg_height;
	}
	int left,height;
};

int main(){

	int H,W,max_s,tmp,tmp_h;

	scanf("%d %d",&H,&W);

	int** table = new int*[H+1];
	for(int i = 0; i < H+1; i++){
		table[i] = new int[W+1];
	}

	for(int i = 0; i < W+1; i++)table[0][i] = 0;
	for(int i = 0; i < H+1; i++)table[i][W] = 0;

	stack<Info> S;
	Info work;

	max_s = 0;

	for(int i = 1;i <= H; i++){
		for(int k = 0; k < W; k++){
			scanf("%d",&table[i][k]);
			if(table[i][k] == 0){
				table[i][k] = table[i-1][k] + 1;
			}else{
				table[i][k] = 0;
			}
		}

		tmp_h = table[i][0];
		S.push(Info(0,tmp_h));

		for(int k = 1; k < W+1; k++){
			if(table[i][k] > tmp_h){
				S.push(Info(k,table[i][k]));
				tmp_h = table[i][k];
			}else if(table[i][k] == tmp_h){

			}else{
				while(S.empty() == false && S.top().height >= table[i][k]){
					work = S.top();
					S.pop();
					tmp = (k - work.left)*work.height;
					max_s = (max_s >= tmp)?max_s:tmp;
				}
				tmp_h = table[i][k];
				S.push(Info(work.left,table[i][k]));
			}
		}
	}

	printf("%d\n",max_s);

	return 0;
}

Measured memory_bytes: 10328
N = int(input())

Heights = [int(n) for n in input().split()]
Costs = [-1 for n in range(N)]

for i in range(N):
    if i == 0:
        Costs[i] = 0
    elif i == 1:
        Costs[i] = abs(Heights[1] - Heights[0])
    else:
        Costs[i] = min(Costs[i-1] + abs(Heights[i] - Heights[i-1]), Costs[i-2] + abs(Heights[i] - Heights[i-2]))

print(Costs[-1])


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

vector<int> l[200005];
vector<pair<int,int>> r[200005];
ll dp[200005], st[800005], lp[1600005];

void prop(int p, bool leaf) {
	if(lp[p]) {
		st[p] += lp[p];
		// if(!leaf) {
			lp[2*p] += lp[p];
			lp[2*p+1] += lp[p];
		// }
		lp[p] = 0;
	}
}

void add(int L, int R, int i, int j, ll num, int p) {
	if(R < i or L > j) return;
	if(L >= i and R <= j) {
		lp[p] += num;
		prop(p, L == R);
		return ;
	}

	int M = (L+R)/2;
	prop(2*p, L == M);
	prop(2*p+1, M+1 == R);

	add(L, M, i, j, num, 2*p);
	add(M+1, R, i, j, num, 2*p+1);

	st[p] = max(st[2*p], st[2*p+1]);
}

ll query(int L, int R, int i, int j, int p) {
	if(R < i or L > j) return -1e18;
	if(L >= i and R <= j) return st[p];

	int M = (L+R)/2;

	prop(2*p, L == M);
	prop(2*p+1, M+1 == R);

	return max(query(L, M, i, j, 2*p), query(M+1, R, i, j, 2*p+1));
}

int main() {
	int n,a,b,c,m;
	scanf("%d %d", &n, &m);

	for(int i = 0; i < m; i++) {
		scanf("%d%d%d", &a, &b, &c);
		l[a].push_back(c);
		r[b+1].push_back(mp(a,c));
	}

	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int x : l[i])
			add(0, n, 0, i-1, x, 1);
		for(auto& x : r[i])
			add(0, n, 0, x.ff-1, -x.ss, 1);


		dp[i] = query(0, n, 0, i-1, 1);
		add(0, n, i, i, dp[i], 1);

		ans = max(ans, dp[i]);
	}

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

    return 0;
}


Measured memory_bytes: 40448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k;
ll *id;
    ll *size;
    void init(ll n)
    {
        id=new ll[n];
        size=new ll[n];
        for(int i=0;i<n;i++)
        {
            id[i]=i;
            size[i]=1;
        }
    }

    ll root(ll i)
    {
        ll j=i;
        while(id[j]!=j)
            j=id[id[j]];
        while(i!=j)
        {
            ll newp=id[i];
            id[i]=j;
            i=newp;
        }
        return j;
    }
    void unions(ll p,ll q)
    {
        ll i=root(p);
         ll j=root(q);
        if(i==j)
             return;
         if(size[i]>size[j])
         {
             id[j]=i;
             size[i]+=size[j];
         }
         else
         {
            id[i]=j;
             size[j]+=size[i];
         }
    }
int main()
{
    cin>>n>>m>>k;
    set<ll> a[n],b[n];
    init(n);
    for(int i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        x--;y--;
        a[x].insert(y);a[y].insert(x);
        unions(x,y);
    }
    for(int i=0;i<k;i++)
    {
        ll x,y;
        cin>>x>>y;x--;y--;
        b[x].insert(y);b[y].insert(x);
    }
    for(int i=0;i<n;i++)
    {
        ll cnt=size[root(i)]-1;
        cnt-=a[i].size();
        auto it=b[i].begin();
        while(it!=b[i].end())
        {
            ll p=(*it);
            if(root(p)==root(i))
                cnt--;
                it++;
        }
        cout<<cnt<<" ";
    }
}


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

int main() {
 
	int n;
	
	cin >> n;
   int a[n];
   int b[n];
   for (int i = 0; i < n; ++i) {
      cin >> a[i];
   }
   int ans = 0;
   int count = 1;
   for (int i = 0; i < n; ++i) {
      if (count != a[i]) {
         ans++;
      } else {
         b[count - 1] = a[i];
         count++;
      }
   }
   if (ans == n) {
      cout << -1 << endl;
   } else {
      cout << ans << endl;
   }
   return 0;
}



Measured memory_bytes: 1792
N = int(input())
cnt_list = [[0 for _ in range(9)] for _ in range(9)]

for A in range(1, N+1):
    A_high = A//pow(10, len(str(A))-1)
    A_low = A%10
    if A_low != 0:
        cnt_list[A_high-1][A_low-1] += 1

cnt = 0
for i in range(9):
    for j in range(9):
        cnt += cnt_list[i][j] * cnt_list[j][i]
print(cnt)

Measured memory_bytes: 40936
a,b=map(int,input().split())
sum_price = 0
if a == 1:
    sum_price += 300000
elif a == 2:
    sum_price += 200000
elif a == 3:
    sum_price += 100000

if b == 1:
    sum_price += 300000
elif b == 2:
    sum_price += 200000
elif b == 3:
    sum_price += 100000

if a == 1 and b == 1:
    sum_price += 400000

print(sum_price)


Measured memory_bytes: 38384
import sys
import heapq as hq
from operator import itemgetter

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, Q = map(int, rl().split())
    event = []
    for _ in range(N):
        s, t, x = map(int, rl().split())
        event.append((t - x, 0, x))
        event.append((s - x, 1, x))
    for _ in range(Q):
        d = int(rl())
        event.append((d, 2, -1))
    event.sort(key=itemgetter(0, 1))
    
    pos_set = set()
    pos_hq = []
    ans = []
    for _, com, pos in event:
        if com == 0:
            pos_set.remove(pos)
        elif com == 1:
            pos_set.add(pos)
            hq.heappush(pos_hq, pos)
        else:
            while pos_hq:
                if pos_hq[0] not in pos_set:
                    hq.heappop(pos_hq)
                else:
                    break
            ans.append(pos_hq[0] if pos_hq else -1)
    print(*ans, sep='\n')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 124064
/*input
2
5 1 1
100 1 1
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long t,q,m,k,h,ans=0,sum=0,p,x,y,xold=0,yold=0,tlast=0;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>t>>x>>y;
		int moves = abs(x-xold) + abs(y-yold);
		if(moves>t-tlast || (t-tlast - moves)%2)
			return cout<<"No",0;
		tlast = t, xold = x, yold = y;
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60



/*
// mod付きpower
// べき乗
long long modpow(long long x, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = (res * x) % modulo; // 最下位ビットが立っているときにx^(2^i)をかける
		x = x * x % modulo;
		n >>= 1;
	}
	return res;
}
*/

const int MAX = 210000;

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 % modulo;
		inv[i] = modulo - inv[modulo%i] * (modulo / i) % modulo;
		finv[i] = finv[i-1] * inv[i] % modulo;
	}
}

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] % modulo) % modulo;
}

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

	ll ans = 1;

	for (int i = 2; i <= M; i++) {
		int  cnt = 0;
		while (M%i == 0) {
			M /= i;
			cnt++;
		}
		if (cnt != 0) {
			ans = (ans * COM(N - 1 + cnt, cnt)) % modulo;
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5120
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		X, _ := strconv.Atoi(buf[0])
		Y, _ := strconv.Atoi(buf[1])
		if X == 0 && Y == 0 {
			break
		}
		tbl := make([][]int, Y+2)
		field := make([][]int, Y+2)
		for i := range field {
			field[i] = make([]int, X+2)
			tbl[i] = make([]int, X+2)
			for j := range field[i] {
				field[i][j] = 2
				tbl[i][j] = 0
			}
		}
		buf_ := make([][]string, Y)
		for i := range buf_ {
			scanner.Scan()
			buf_[i] = strings.Split(scanner.Text(), " ")
		}
		for i := 1; i <= Y; i++ {
			for j := 1; j <= X; j++ {
				field[i][j], _ = strconv.Atoi(buf_[i-1][j-1])
				switch field[i][j] {
				case 0:
					if i == 1 {
						tbl[i][j] = 1 // スタートy=1
					} else {
						if field[i-1][j-1] != 2 {
							tbl[i][j] += tbl[i-1][j-1] // 左上からやってくる
						}
						if field[i-1][j] != 2 {
							tbl[i][j] += tbl[i-1][j] // 真上からやってくる
						}
						if field[i-1][j+1] != 2 {
							tbl[i][j] += tbl[i-1][j+1] // 右上からやってくる
						}
						if field[i-2][j] == 2 {
							tbl[i][j] += tbl[i-2][j] // ジャンプしてくる
						}
					}
				case 1:
					tbl[i][j] = 0 // 障害物あり
				case 2:
					if field[i-1][j] != 2 {
						tbl[i][j] += tbl[i-1][j] // 真上からくる
					}
					if field[i-2][j] == 2 {
						tbl[i][j] += tbl[i-2][j] // ジャンプ台からジャンプしてくる
					}
				}
			}
		}
		sum := 0
		for i := 1; i <= X; i++ {
			sum += tbl[Y][i] // とびこさないでゴール
			if field[Y-1][i] == 2 {
				sum += tbl[Y-1][i] // 飛び越してゴール
			}
		}
		fmt.Println(sum)
	}
}



Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

int main(){
  // 入力
  long int S, W;
  cin >> S >> W;

  string result = "safe"; 
  
  if (W >= S) {
    result = "unsafe";
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <stdio.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)

typedef long long ll;
const int maxn = 2e5+10;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
using namespace std;

inline ll qpow(ll a,ll n) { ll res = 1 ; for(;n;n>>=1) {if( n&1 )res = (res*a)%mod; a = (a*a)%mod ; }return res;}
ll fac = 1,inv[maxn+10],a[maxn+10];
int main(int argc, char const *argv[])
{
	ll n,ans  = 0;
	scanf("%lld",&n);
	rep(i,1,n) { fac = (fac*i)%mod;	inv[i] = qpow(1ll*i,mod-2); } 
	rep(i,1,n) { inv[i] += (inv[i-1])%mod; scanf("%lld",&a[i]);}
	rep(i,1,n) { ans = (ans + (a[i]*(inv[i]+inv[n-i+1]-1)%mod)%mod)%mod; }
	printf("%lld\n", (fac*ans)%mod );
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

int main(){
    int  n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    ll w = 0, r = 0;
    rep(i,n){
        if(s[i] == 'R')r++;
        else w++;
    }
    rep(i,r){
        if(s[i] == 'W')ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using int64 = long long;

int64 f(int64 b, int64 n)
{
    if (n < b) return n;
    else return n % b + f(b, n / b);
}

int main()
{
    int64 n, s;
    cin >> n >> s;

    int64 ans = (n == s) ? (n + 1) : -1;
    for (int64 b = 2; b <= min(1000000LL, n); b++)
    {
        if (f(b, n) == s and (ans < 0 or b < ans))
        {
            ans = b;
            break;
        }
    }

    // xy
    for (int64 x = 1; x <= min(1000000LL, s); x++)
    {
        int64 y = s - x;
        // x*b+y==nを満たすbがあるかどうか
        if (n - y < 0 or (n - y) % x != 0)
        {
            continue;
        }
        int64 b = (n - y) / x;
        if (b > x and b > y and (ans < 0 or b < ans))
        {
            ans = b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int mod = 1e9 + 7;
const int INF = 1e9;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> k(m), p(m);
    vector<vector<int> > s(m);
    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            int tmp; cin >> tmp;
            s[i].push_back(tmp-1);
        }
    }
    rep(i,m)cin >> p[i];
    int ans = 0;
    rep(swi,1<<n){
        int light = 0;
        //cout << bitset<3>(swi) << " ";
        //cout << "cnt: ";
        rep(i,m){
            int cnt = 0;
            rep(j,k[i])if(swi >> s[i][j] & 1)cnt++;
            if(cnt % 2 == p[i])light++;
            //cout << cnt << " ";
        }
        if(light == m)ans++;
        //cout << "light " << light << endl;
    }
    cout << ans << endl;
    return 0;
}

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

int main()  {
    vector<int> v(3);
    for(int i=0;i<3;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    if(v[0]==5 && v[1]==5 && v[2]==7)
        cout<<"YES";
    else
        cout<<"NO";
    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3636
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=1e5+3;
int n,k,ans;
int a[3];string s;
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	map<char,int> m;
	m['r']=2;m['s']=0;m['p']=1;
	cin>>n>>k>>a[0]>>a[1]>>a[2];
	cin>>s;
	vector<bool> ok(n,1);
	for(int i=0;i<n;i++)
	{
		if(i-k>=0)
		{
			if(s[i]==s[i-k] and !ok[i-k])continue;
		}
		ans+=a[m[s[i]]];ok[i]=0;
	}
	cout<<ans;

	
	

	
}

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

using namespace std;

const int MAX = 1e5 + 10;
int dp[MAX << 1];

int main() {
    for (int i = 0; i < (MAX << 1); i++) {
        dp[i] = i;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        {
            int foo = 6;
            int bar = foo;
            while (i + bar < MAX) {
                dp[i + bar] = min(dp[i + bar], dp[i] + 1);
                bar *= foo;
            }
        }
        {
            int foo = 9;
            int bar = foo;
            while (i + bar < MAX) {
                dp[i + bar] = min(dp[i + bar], dp[i] + 1);
                bar *= foo;
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

  int n,i;

  for(;;){
    scanf("%d",&n);
    if(n==0)break;

    int m=0,point=0,state=0;
    char s[n][2];

    for(i=0;i<n;i++)scanf("%s",s[i]);

    for(i=0;i<n;i++){

      if(state==0){
	if(s[i][1]=='d')point--;
	if(s[i][1]=='u'){
	  point++;
	  if(point==2){
	  m++;
	  state=1;
	  point=0;
	  }
	}
      }

      else if(state==1){
	if(s[i][1]=='u')point--;
	if(s[i][1]=='d'){
	  point++;
	  if(point==2){
	  m++;
	  state=0;
	  point=0;
	  }
	}
      }
    }
    
    printf("%d\n",m);
  }

  return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	long N;
	cin >>N;
	/*
	vector<long> A(N, 0);
	for (long i=0; i<N; i++)
		cin >>A.at(i);
	*/
	vector<vector<long>> C0;
	C0.push_back({0, 0, 0, 1});
	vector<vector<long>> C1;
	for (long i=0; i<N; i++) {
		C1.erase(C1.begin(), C1.end());
		// long AA=A.at(i);
		long AA;
		cin >>AA;
		for (long j=0; j<C0.size(); j++) {
			long c1=C0.at(j).at(0);
			long c2=C0.at(j).at(1);
			long c3=C0.at(j).at(2);
			long cn=C0.at(j).at(3);
			if (AA==c1)
				C1.push_back({c1+1, c2, c3, cn});
			if (AA==c2)
				C1.push_back({c1, c2+1, c3, cn});
			if (AA==c3)
				C1.push_back({c1, c2, c3+1, cn});
		}
		if (0==C1.size()) {
			cout <<0 <<endl;
			return 0;
		}
		sort(C1.begin(), C1.end());
		C0.erase(C0.begin(), C0.end());
		C0.push_back(C1.at(0));
		for (long k=1; k<C1.size(); k++) {
			if(
					(C1.at(k).at(0)==C0.back().at(0))
					&&(C1.at(k).at(1)==C0.back().at(1))
					&&(C1.at(k).at(2)==C0.back().at(2))) {
				C0.back().at(3) +=C1.at(k).at(3);
				C0.back().at(3) %=MOD;
			} else {
				C0.push_back(C1.at(k));
			}
		}
	}
	long S=0;
	for (long i=0; i<C0.size(); i++) {
		S +=C0.at(i).at(3);
		S %=MOD;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,t,s=0,ans;
    scanf("%d%d",&n,&t);
    int a[t];
    for(int i=0;i<t;i++)
    {
        scanf("%d",&a[i]);
        s+=a[i];
    }
    ans=n-s;
    if(ans>=0)
        printf("%d\n",ans);
    else
        printf("-1\n");
    return 0;

}


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

int main(){
    string a,b;
    cin >> a >> b;
    int ans =0;
    for(int i = 0; i < a.size();++i){
        if(a[i] != b[i]) ++ans;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3848
import heapq as hq
N, M = map(int, input().split())
A = list(map(int,input().split()))
A = [(-i,1) for i in A]
hq.heapify(A)
for i in range(M):
    B, C = map(int, input().split())
    hq.heappush(A,(-C,B))
sum_A = 0
for i in range(N):
    add_num = hq.heappop(A)
    sum_A += add_num[0]*-1
    if add_num[1] > 1:
        hq.heappush(A,(add_num[0],add_num[1]-1))
print(sum_A)
    
    


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n;
    ll sum = 1;
    cin >> n;
    REP(i, n) {
        sum *= ll(i);
        sum %= 1000000007;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>
#include <sstream>      // std::ostringstream
#include <bitset>
#include <iomanip>
#include <functional>
#include <set>


#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;
const long long INF = 1LL << 60;

#define OUTPUT_DEBUG_LOG

template <typename T>
void DisplayAnswer(const T& v) {
	cout << v << endl;
}
template <typename T>
void DisplayAnswers(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << endl;
	}
}

template <typename T>
void DisplayAnswerOneLine(const vector<T>& vs) {
	for (const auto& v : vs) {
		cout << v << ' ';
	}
	cout << endl;
}


std::vector<std::string> split(const std::string &str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



template<class T>
void chmin(T& a, T b) {
	if (a > b) {
		a = b;
	}
}


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}


void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}



struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

void FuncA() {
	ll m;
	cin >> m;

	while (m > 0) {
		m -= 1000;
	}
	DisplayAnswer(-m);
}

int main(void) {

	FuncA();

	return 0;
}


Measured memory_bytes: 3636