akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
  int a,b;
  int c[3][3];
  int count=0;
  REP(i,3){
    REP(j,3){
       cin>>c[i][j];
    }
  }

  REP(i,2){
    REP(j,2){
       if(c[i][j+1]-c[i][j]==c[i+1][j+1]-c[i+1][j])count++;

    }
  }
  if(c[0][2]-c[0][0]==c[1][2]-c[1][0]&&c[0][2]-c[0][0]==c[2][2]-c[2][0])
   count+=2;
  if(count==6)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  //cout<<count<<endl;
}

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

typedef long long ll;
const ll MOD = 998244353LL;

vector<int> gcd(vector<int> A, vector<int> B) {
	if (B[0] == 0) {
		return A;
	}
	int N = A.size(), M = B.size();
	for (int i = 0; i <= N - M; i++) {
		if (A[i] == 1) {
			for (int j = 0; j < M; j++) {
				A[i + j] ^= B[j];
			}
		}
	}
	vector<int> R;
	bool zero = 1;
	for (int i = 0; i < N; i++) {
		if (A[i]) zero = 0;
		if (!zero) R.push_back(A[i]);
	}
	if (zero) R.push_back(0);
	return gcd(B, R);
}
int main() {
	int N; cin >> N;
	string X; cin >> X;
	vector<int> x;
	for (int i = 0; i < X.size(); i++) x.push_back(X[i] - '0');
	vector<int> g(1, 0);
	for (int i = 0; i < N; i++) {
		string A; cin >> A;
		vector<int> a;
		for (int i = 0; i < A.size(); i++) a.push_back(A[i] - '0');
		g = gcd(g, a);
	}
	if (g.size() > x.size()) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	for (int i = 0; i <= x.size() - g.size(); i++) {
		(ans *= 2) %= MOD;
		(ans += x[i]) %= MOD;
	}
	vector<int> y(x.size(), 0);
	for (int i = 0; i <= x.size() - g.size(); i++) {
		if (y[i] != x[i]) {
			for (int j = 0; j < g.size(); j++) y[i + j] ^= g[j];
		}
	}
	bool ok = 1;
	for (int i = x.size() - g.size() + 1; i < x.size(); i++) {
		if (y[i] < x[i]) break;
		if (y[i] > x[i]) {
			ok = 0;
			break;
		}
	}
	if (ok) (ans += 1) %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 53632
#!python3

import sys
from functools import reduce
from operator import or_

iim = lambda: map(int, sys.stdin.readline().rstrip().split())

X = 60 # (10**18).bit_length()
def f(a, s, n):
    if s[-1] == "1":
        return 1

    y = bin(reduce(or_, a)).count("1")
    B = [None] * X
    for i in range(n-1, -1, -1):
        ai, si = a[i], s[i]

        if si == "0":
            while True:
                x = ai.bit_length() - 1
                if B[x] == ai: break
                elif B[x] == None:
                    B[x] = ai
                    y -= 1
                    if y == 0:
                        return 0
                    break
                ai ^= B[x]
        else:
            while True:
                x = ai.bit_length() - 1
                if B[x] == ai: break
                elif B[x] == None:
                    return 1
                ai ^= B[x]
    return 0


def resolve():
    T = int(input())

    ans = []
    for i in range(T):
        N = int(input())
        A = list(iim())
        S  = input()

        ans.append(f(A, S, N))

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9644
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long k=sc.nextLong();
		if(a>=k){
			System.out.println(a-k+" "+b);
		}else{
			long p=Math.max((b-(k-a)),0);
			System.out.println(0+" "+p);
		}
	}
}


Measured memory_bytes: 21844
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (a % b == 0)
		return b;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	ll n,ans=0;
	cin >> n;
	for (ll i = 1; i*i<=n; i++)
	{
		if (n % i == 0)
		{
			ll t = n / i;
			t--;
			if (i < t)
				ans = ans + t;
		}
	}
	cout << ans;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return(0);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, AB):
    c = Counter()
    for a, b in AB:
        c[a] += 1
        c[b] += 1
    for v in c.values():
        if v % 2 != 0:
            return 'NO'
    return 'YES'


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    print(slv(N, M, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 89556
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

bool judge(int p){
    if(p==2)return true;
    if(p<2 | p%2==0)return false;
    int i = 3;
    int sqrtx = sqrt(p);
    while(i<=sqrtx){
        if(p%i == 0){
            return false;
        }else{
            i = i + 2;
        }
    }
    return true;
}
int main(){
    int n = 0; int cnt =0;
    scanf("%d",&n);
    int input;
    bool frag;
    for(int i = 0; i < n; i++){
        scanf("%d",&input);
        if(input){
            frag = judge(input);
            if(frag)cnt++;
        }
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 2692
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
p = readl()
count = 0
for i in p:
    while(i % 2 == 0):
        i //= 2
        count += 1
print(count)


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

int main() {
  int N, A[100005];

  cin >> N;
  rep(i, N) cin >> A[i + 1];
  A[0] = A[N + 1] = 0;

  int total = 0;
  rep(i, N) {
    total += abs(A[i + 1] - A[i]);
  }
  total += abs(A[N]);

  rep(i, N) {
    int prev = abs(A[i + 1] - A[i]) + abs(A[i + 2] - A[i + 1]);
    int now = abs(A[i + 2] - A[i]);
    int ans = total - prev +  now;
    cout << ans << endl;
  }

  return 0;

}

Measured memory_bytes: 1664
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    char s[101],t[101];
    int k=0,indic,a=0;
    cin>>s>>t;
    for(int i=0; i<strlen(s); i++){
        k=0;
        if(t[i]==s[0]){
            for(int j=i; j<strlen(s)+i; j++){
                if(j>=strlen(s)){
                    indic=j-strlen(s);
                }
                else
                    indic=j;
                if(t[indic]==s[k]){
                    if(j==strlen(s)+i-1){
                        a=1;
                        break;
                    }
                    k++;
                }
                else
                    break;
            }
        }
        if(a==1){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int x; cin >> x;
    int ans;
    ans = x / 11;
    ans *= 2;
    x %= 11;
    if(x > 6) ans += 2;
    else if(0 < x && x < 7) ans ++;

    cout << ans  << endl;
}

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

using namespace std;

#define    fastio        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    f             first
#define    s             second
#define    ub            upper_bound
#define    lb            lower_bound
#define    pb            push_back
#define    mset(x,val)   memset(x,val,sizeof(x))
#define    all(x)        (x).begin(),(x).end()
#define    foo(i,a,b)    for(long long i=(a);i<=(b);i++)
#define    rep(i,a,b)    for(long long i=(a);i>=(b);i--)
#define    FOR(i,v)      for(auto &(i):(v))

using  ll    =   long long;
using  ld    =   long double;
using  vl    =   vector<ll>;
using  pll   =   pair<ll, ll>;
using  vll   =   vector<pll>;
using  MAP   =   map<ll, ll>;
using  sl    =   set<ll>;
using  sll   =   set<pll>;
using  MAPs  =   map<ll, sl>;
using  MAPv  =   map<ll, vl>;


const ll inf = LLONG_MAX;
const ll mod = 1e9 + 7;
const ll N   = 2e5 + 5;//change it if u have to

int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
int n, k, a[N];

/***************************************** FUNCTION IMPLEMENTATIONS **************************************/
int f(int x) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += (a[i]) / x - 1;
        if (a[i] % x) cnt++;
    }

    return cnt <= k;
}

/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];

    int lo = 1, hi = 1e9, mid;
    while (lo < hi) {
        mid = lo + (hi - lo) / 2;
        if (f(mid)) hi = mid;
        else lo = mid + 1;
    }

    cout << (ll)floor(lo) << "\n";
}

int main() {
    fastio;
    int t = 1;

    // cin>>t;
    while (t -- > 0) {
        MAIN();
    }

// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif

}


Measured memory_bytes: 4372
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	map<string, char>mp;
	mp["101"] = ' ';
	mp["000000"] = '\'';
	mp["000011"] = ',';
	mp["10010001"] = '-';
	mp["010001"] = '.';
	mp["000001"] = '?';
	mp["100101"] = 'A';
	mp["10011010"] = 'B';
	mp["0101"] = 'C';
	mp["0001"] = 'D';
	mp["110"] = 'E';
	mp["01001"] = 'F';
	mp["10011011"] = 'G';
	mp["010000"] = 'H';
	mp["0111"] = 'I';
	mp["10011000"] = 'J';
	mp["0110"] = 'K';
	mp["00100"] = 'L';
	mp["10011001"] = 'M';
	mp["10011110"] = 'N';
	mp["00101"] = 'O';
	mp["111"] = 'P';
	mp["10011111"] = 'Q';
	mp["1000"] = 'R';
	mp["00110"] = 'S';
	mp["00111"] = 'T';
	mp["10011100"] = 'U';
	mp["10011101"] = 'V';
	mp["000010"] = 'W';
	mp["10010010"] = 'X';
	mp["10010011"] = 'Y';
	mp["10010000"] = 'Z';
	string inpt;
	while (getline(cin, inpt)) {
		string code;
		REPC(i, inpt) {
			if ('A' <= i && i <= 'Z')code += bitset<5>(i - 'A').to_string();
			else if (i == ' ')code += "11010";
			else if (i == '.')code += "11011";
			else if (i == ',')code += "11100";
			else if (i == '-')code += "11101";
			else if (i == '\'')code += "11110";
			else if (i == '?')code += "11111";
		}
		string ans;
		ll head = 0;
		REP1(i, code.length()) {
			string sub = code.substr(head, i - head);
			if (mp.count(sub) == 1) {
				ans += mp[sub];
				head = i;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define modd 998244353
using namespace std;
typedef long long int ll;
int main()
{
    ll n,s=3000,dwe;
    cin>>n>>dwe;
    ll a[n+1];
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    ll dp[n+1][s+1][2];
    for(ll i=0;i<=s;i++)
    {
        dp[1][i][1]=0;
        dp[1][i][0]=0;
    }
    dp[1][a[1]][0] = dp[1][a[1]][1] = 1LL;
    for(ll i=2;i<=n;i++)
    {
        for(ll j=0;j<a[i];j++)
        {
            dp[i][j][0]=0;
            dp[i][j][1]=dp[i-1][j][1];
        }
        dp[i][a[i]][0]=i;
        dp[i][a[i]][1] = (dp[i][a[i]][0] + dp[i-1][a[i]][1])%modd;
        for(ll j=a[i]+1;j<=s;j++)
        {
            dp[i][j][0] = dp[i-1][j-a[i]][1];
            dp[i][j][1] = (dp[i-1][j][1] + dp[i][j][0])%modd;
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans = (ans + (n-i+1LL)*dp[i][dwe][0])%modd;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 140928
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();

		int sum = r * 100 + g * 10 + b;

		System.out.println(sum % 4 == 0 ? "YES" : "NO");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 300005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int h, w;
    cin >> h >> w;
    int wall[10][10];
    for( int i = 0; i < 10; ++i ) {
        for( int j = 0; j < 10; ++j ) cin >> wall[i][j];

    }

    for( int k = 0; k < 10; ++k ) {
        for( int i = 0; i < 10; ++i ) {
            for( int j = 0; j < 10; ++j ) {
                if( wall[i][j] > wall[i][k] + wall[k][j] ) {
                    wall[i][j] = wall[i][k] + wall[k][j];

                }
            }
        }
    }

    int res = 0;
    for( int i = 0; i < h; ++i ) {
        for( int j = 0; j < w; ++j ) {
            int a;
            cin >> a;
            if( a != -1 ) {
                res += wall[a][1];

            }
        }
    }
    cout << res << endl;
    return 0;
}



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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    for(int i=1; i<=min(a,b); i++){
        if(a%i == 0 && b%i == 0) v.push_back(i);
    }
    cout << v[v.size() - k] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int binary(vector<int> &k,int left,int right,int key){
  if(k[0]>=key)return 0;
  int mid=(left+right)/2;
  if(left==mid){
    if(k[left]<key)return right;
    else return mid;
  }
  if(k[mid-1]<key)return binary(k,mid,right,key);
  else return binary(k,left,mid,key);
}
int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  vector<int> k(1,a[0]);
  vector<int> u(1,0);
  rep(i,n){
    if(i==0)continue;
    if(a[i]>k[k.size()-1]){
      u.push_back(i);
      k.push_back(a[i]);
    }
  }
  vector<int> b(k.size(),0);
  vector<ll> ans(k.size(),0);
  rep(i,n){
    int e=binary(k,0,k.size(),a[i]);
    if(e!=0){
      b[e-1]++;
      ans[e]+=(ll)a[i]-k[e-1];
    }
    else ans[0]+=a[i];
  }
  rep(i,k.size()-1){
    b[k.size()-2-i]+=b[k.size()-1-i];
  }
  rep(i,k.size()-1){
    if(i!=0)ans[i]+=(ll)b[i]*(ll)(k[i]-k[i-1]);
    else ans[i]+=(ll)b[i]*(ll)k[0];
  }
  vector<ll> o(n,0);
  rep(i,k.size())o[u[i]]+=ans[i];
  rep(i,n)cout << o[i] << endl;
}


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

typedef long long ll;

const int N = 1e5 + 7;
vector<int> child[N];
int dp[N];

bool cmp(int a, int b)
{
	return dp[a] > dp[b];
}

void dfs(int v)
{
	dp[v] = 0;
	for (auto u : child[v])
		dfs(u);
	sort(child[v].begin(), child[v].end(), cmp);
	for (int i=0; i<(int)child[v].size(); i++)
		dp[v] = max(dp[v], dp[child[v][i]] + i + 1);
}

int main()
{
	ios::sync_with_stdio(false);


	int n; cin >> n;
	for (int i=1; i<n; i++)
	{
		int p;
		cin >> p;
		child[--p].push_back(i);
	}
	dfs(0);
	cout << dp[0] << "\n";

	return 0;
}

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

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

class Person {
public:

  int index;
  int honests;
  int unkinds;

  bool match(Person other) {
    if (unkinds & (1 << other.index)) {
      return false;
    }

    if (other.unkinds & (1 << index)) {
      return false;
    }

    return !((honests & other.unkinds) || (unkinds & other.honests));
  }
};

int bitcount(int n) {
  int count = 0;
  while(n) {
    if (n & 1) count++;
    n /= 2;
  }
  return count;
}

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

  vector<Person> persons(n);
  Rep(i, n) {
    Person p = Person();
    p.index = i;

    int a;
    cin >> a;
    Rep(j, a) {
      int x, y;
      cin >> x >> y;
      (y ? p.honests : p.unkinds) |= (1 << (x - 1));
    }

    persons[i] = p;
  }

  int assumption = 0;
  Rep(i, n) {
    assumption |= (1 << i);
  }

  int answer = 0;
  int answer_assumption = 0;
  while (assumption) {
    int current;

    vector<Person> believables;
    Rep(i, n) {
      if (assumption & (1 << i)) {
        if (!persons[i].match(persons[i])) {
          goto NEXT_ASSUMPTION;
        }

        if (assumption & persons[i].unkinds) {
          goto NEXT_ASSUMPTION;
        }
        if ((~assumption) & persons[i].honests) {
          goto NEXT_ASSUMPTION;
        }

        believables.push_back(persons[i]);
      }
    }

    Rep(i, believables.size()) {
      For(j, i, believables.size()) {
        if (!believables[i].match(believables[j])) {
          goto NEXT_ASSUMPTION;
        }
      }
    }
    
    current = bitcount(assumption);
    if (current > answer) {
      answer = current;
      answer_assumption = assumption;
    }

NEXT_ASSUMPTION:
    assumption--;
  }

  // cout << answer_assumption << endl;
  cout << answer << endl;

  return 0;
}


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

vector< vector< long long int > > v;
bool f[5001] = {};

void kansu( long long int n ) {

  if ( f[n] == true ) return;

  f[n] = true;

  for ( long long int i = 0; i < v[n].size(); i++ ) {
    kansu( v[n][i] );
  }

  cout << n << endl;

  return;

}

int main() {

  long long int n, m;
  cin >> n >> m;

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

    vector< long long int > l;
    v.push_back( l );

  }

  for ( long long int i = 0; i < m; i++ ) {

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

    v[y].push_back( x );

  }

  for ( long long int i = 1; i <= n; i++ ) {
    kansu( i );
  }

  return 0;

}

Measured memory_bytes: 1224
S = list(input())
K = int(input())

if len(S) >= K :
    T = S[0:K]
else :
    T = S[0:len(S)]
point = T.count("1")
if point >= K :
    print(1)
else :
    for j in range(len(S)) :
        if S[j] != "1" :
            print(S[j])
            break

            
            
            

Measured memory_bytes: 3060
N, W = map(int, input().split())  # N<=100, W<=10**9
w, v = [0] * N, [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())  # すべての i=2,3,…,N について、w1 ≦ wi ≦ w1+3

#

def kaihou():
    monos_by_omosa = [[] for _ in range(4)]
    w0 = w[0]
    for i in range(N):
        monos_by_omosa[w[i] - w0].append(v[i])
    for i in range(4):
        monos_by_omosa[i].sort()
        monos_by_omosa[i].reverse()
    # print(monos_by_omosa)
    ans = 0
    for i in range(N + 1):
        if i > len(monos_by_omosa[0]):
            break
        w0i = (w0) * i
        if w0i > W:
            break

        for j in range(N + 1 - i):
            if j > len(monos_by_omosa[1]):
                break
            w1j = (w0 + 1) * j
            if w0i + w1j > W:
                break

            for k in range(N + 1 - i - j):
                if k > len(monos_by_omosa[2]):
                    break
                w2k  = (w0 + 2) * k
                if w0i + w1j + w2k > W:
                    break

                for l in range(N + 1 - i - j - k):
                    if l > len(monos_by_omosa[3]):
                        break
                    w3l = (w0 + 3) * l
                    if w0i + w1j + w2k + w3l > W:
                        break

                    val = sum(monos_by_omosa[0][:i])
                    val += sum(monos_by_omosa[1][:j])
                    val += sum(monos_by_omosa[2][:k])
                    val += sum(monos_by_omosa[3][:l])
                    ans = max(ans, val)
    return ans

print(kaihou())



Measured memory_bytes: 54616
#include<iostream>

using namespace std;

int main(){
    int K[] = {1,5,10,50,100,500};
    int sum =0;
    for(int i =0;i<6;i++){
        int a;
        cin>>a;
        sum += K[i]*a;
    }
    cout<<(sum>=1000)<<endl;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    
    char str1[101],str2[101],n[201];
 
    scanf("%s",str1);
    scanf("%s",str2);
    strcpy(n, str1);  //nにコピー
    strcat(n, str1);  //nに連結
    
    if(strstr(n, str2) != NULL){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    int ans = 10000000;
    for (int p = 1; p <= 100; p++) {
        int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += pow(X[i] - p, 2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int s[50][50], h, w;
    char c;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c;
            s[i][j] = (c == '#' ? -1 : 0);
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int count = 0;
            if(s[i][j] != -1){
                for(int k = i - 1; k <= i + 1; k++){
                    if(0 <= k && k < h){
                        for(int l = j - 1; l <= j + 1; l++){
                            if(0 <= l && l < w){
                                if(s[k][l] == -1) count += 1;
                            }
                        }
                    }
                }
                s[i][j] = count;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == -1) cout << '#' << flush;
            else cout << s[i][j] << flush;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> graph) {
    if (graph.size() == n + 1) {
        int sum = 0;
        REP(i, q)
            if (graph[b[i]] - graph[a[i]] == c[i])
                sum += d[i];
        ans = max(ans, sum);
        return ;
    }
    graph.push_back(graph.back());
    while (graph.back() <= m) {
        dfs(graph);
        graph.back()++;
    }
}

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

    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    dfs(vector<int>(1, 1));

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void)
{
	int n,k;
	int i = 0;
	int j = 0;
	int table[1000000], value[1000000];
	int newvalue;
	
	scanf("%d",&n);
	scanf("%d",&k);

	while(i < n)
	{
		scanf("%d",&table[i]);
		value[i] = 10000000000;
		i++;
	}

	value[0] = 0;
	
	i = 1;
	while(i != n){
		j = i - 1;
		while(j >= i-k && j >= 0)
		{
			newvalue = value[j] + abs(table[i] - table[j]);
			if(value[i] > newvalue){
				value[i] = newvalue;
			}
			j--;
		}
		i++;
	}

	printf("%d",value[n-1]);
	return 0;
}

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

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

int main(){
	ll n, W, maxVal = 1, ans = 0;	cin>>n>>W;	ll w[n], v[n];
	for(ll i = 0; i < n; i++)	cin>>w[i]>>v[i];
	for(auto x : v)	maxVal += x;
	ll dp[2][maxVal];
	for(ll i = 1; i < maxVal; i++)	dp[0][i] = INT_MAX;	dp[0][0] = 0;
	for(ll i = 1; i <= n; i++){
		for(ll j = 0; j < maxVal; j++){
			dp[i&1][j] = dp[!(i&1)][j];
			if(j >= v[i-1])	dp[i&1][j] = min(dp[i&1][j], w[i-1] + dp[!(i&1)][j-v[i-1]]);
		}
	}
	for(ll i = 0; i < maxVal; i++)	if(dp[n&1][i] && dp[n&1][i] <= W)	ans = i;
	cout<<ans;
}

// Time: O(N*sum of values)
// Space: O(sum of values)


Measured memory_bytes: 5164
# coding: utf-8
# hello worldと表示する
o=0
zen = input()
#print(zen)
card = list(map(int,input().split()))
card1 = sorted(card)
#print(sorted(card1))
#print(int(int(zen)/2))
if int(zen)%2 == 0:
    for i in range(int(int(zen)/2)):
        o += int(card1[int(zen)-int(i)*2-1])-int(card1[int(zen)-int(i)*2-2])#        print(o)
#        print(o)    
#        print(card1[int(zen)-int(i)*2-2])
else:
    for i in range(int((int(zen)-1)/2)):
        o += int(card1[int(zen)-int(i)*2-1])-int(card1[int(zen)-int(i)*2-2])#        print(o)
    o += int(card1[0]) 
print(o)    

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

const double adjust = 0.006;

int main() {
	int n, t, a; cin >> n >> t >> a;
	vector<int>h(n); for (auto&& x : h)cin >> x;

	double ans = 0, tmp, pre = 1e9;
	for (int i = 0; i < n; i++) {
		tmp = t - h[i] * adjust;
		if (fabs(a - pre) > fabs(a - tmp)) {
			pre = tmp;
			ans = i + 1;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
main(){
int W,H,x,y,r;
scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
printf("Yes\n");
}
else printf("No\n");
   
  return 0;
}

Measured memory_bytes: 584
fun main(args: Array<String>) = p36()

fun p36() {
    data class Item(val value: Int, val weight: Int)
    val (n, w) = readLine()!!.split(' ').map { it.toInt() }
    val items = Array(n) {
        val (value, weight) = readLine()!!.split(' ').map { it.toInt() }
        Item(value, weight)
    }

    // [choose from (0..it) items][weight sum is lower than it]
    val dp = Array(n + 1) { IntArray(w + 1) }

    for ((index, item) in items.withIndex()) {
        for (wi in 0..w) {
            val (value, weight) = item

            // not choose item
            dp[index + 1][wi] = Math.max(dp[index + 1][wi], dp[index][wi])

            // choose item
            val weightSum = wi + weight
            if (weightSum <= w) {
                dp[index + 1][weightSum] = Math.max(dp[index + 1][weightSum], dp[index + 1][wi] + value)
            }
        }
    }

    val answer = dp.last().last()

    println(answer)
}



Measured memory_bytes: 37036
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll N, K;
    cin >> N >> K;
    ll ret = 0;
    if (K==0) {
        cout << N*N << endl;
        return 0;
    }
    for(ll b = 1; b <= N; b++)
    {
        if(b <= K)
            continue;
        ret += ((N-K)/b+1) * (b-K);
        ll over = max(ll(0), ll((N-K)/b * b + b-1 - N));
        ret -= over;
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;

    cin>>n;

    int array[n];

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

    int dp[n];

    dp[0]=0;
    dp[1]=abs(array[1]-array[0]);

    for(int i=2;i<n;i++)
    {
        dp[i]= min(dp[i-1]+abs(array[i]-array[i-1]), dp[i-2]+abs(array[i]-array[i-2]));
    }

    cout<<dp[n-1];
    
    return 0;
}

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    int N; cin >> N;

    bool isFour = false;

    for (int i = 0; i < N; ++i) {
        string S; cin >> S;

        if (S == "Y") {
            isFour = true;
        }
    }

    if (isFour) {
        puts("Four");
    } else {
        puts("Three");
    }
}


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

int main()
{
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for (int i = 2; i <= n; i++) {
        F[i] = F[i - 1] + F[i - 2];
    }
    
    cout << F[n] << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int x[] = {0, 1, 2, 0, 1, 2, 0, 1, 2};
int n, dp[2][9][9][2];
string s;

int main(){
	while(cin >> s, s != "#"){
		n = s.size();
		int cur = 0, next = 1;
		rep(i, 9) rep(j, 9) rep(k, 2) dp[0][i][j][k] = inf;
		dp[0][s[0] - '1'][4][0] = 0;
		dp[0][4][s[0] - '1'][1] = 0;
		
		rep(it, n - 1){
			rep(i, 9) rep(j, 9) rep(k, 2) dp[next][i][j][k] = inf;
			rep(j, 9) rep(k, 9) rep(l, 2) if(dp[cur][j][k][l] < inf){
				
				int nl = s[it + 1] - '1', nr = k;
				if(nl == 4 || nr == 4 || x[nl] <= x[nr])
				dp[next][nl][nr][0] = min(dp[next][nl][nr][0], dp[cur][j][k][l] + (l == 0));
				
				nl = j; nr = s[it + 1] - '1';
				if(nl == 4 || nr == 4 || x[nl] <= x[nr])
				dp[next][nl][nr][1] = min(dp[next][nl][nr][1], dp[cur][j][k][l] + (l == 1));
			}
			swap(cur, next);
		}
		int ans = inf;
		rep(i, 9) rep(j, 9) rep(k, 2) ans = min(ans, dp[cur][i][j][k]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
int b[2100000];
int c[210000] = {};
int rui[210000];
set<int> ch;



signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>s;
  n = s.size();
  res = 1;
  rep(i,1,n){
    if (s[i] == s[i-1])res+=1;
    else{
      a.pb(res);
      res= 1;
    }
  }
  a.pb(res);
//  cout<<a<<endl;
  int SUM = -1;
  rep(i,0,a.size()/2){
    int x = a[i*2];
    int y = a[i*2+1];
    tmp = (x+y)/2;
    if ((x+y)%2==0){x=y=tmp;}
    else if (x>y){
      if(x%2==0){x=tmp;y=tmp+1;}
      else{y=tmp;x=tmp+1;}
    }
    else {
      if(y%2==0){y=tmp;x=tmp+1;}
      else{x=tmp;y=tmp+1;}
    }    
    
    c[SUM+a[i*2]] = x;
    c[SUM+a[i*2]+1] = y;
    SUM += x+y;
  }
  rep(i,0,n){cout<<c[i]<<" ";}
  cout<<endl;
}


Measured memory_bytes: 54468
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

// 1からnumまでのxor累積
ll factorialXOR(ll num)
{
	if (num <= 0)
		return 0;

	if (num <= 3)
	{
		ll ans = 1;
		for (int i = 2; i <= num; i++)
		{
			ans = ans ^ i;
		}
		return ans;
	}

	ll maxBy4 = 0;
	if (num % 4 == 0)
		maxBy4 = num - 1;
	if (num % 4 == 1)
		maxBy4 = num - 2;
	if (num % 4 == 2)
		maxBy4 = num - 3;
	if (num % 4 == 3)
		maxBy4 = num;

	ll ans = 0;
	while (maxBy4 < num)
	{
		maxBy4++;
		ans = ans ^ maxBy4;
	}

	return ans;
}

ll f(ll a, ll b)
{
	return factorialXOR(a - 1) ^ factorialXOR(b);
}

int main()
{
	ll a, b;
	cin >> a >> b;
	cout << f(a, b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll N, K;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}
vector<ll> pathes[105000];
ll ans = 1;

void dfs(int now, int from) {
    ll NG = 1;
    ll children = 0;
    for(int i = 0; i < pathes[now].size(); i++) {
        int to = pathes[now][i];
        if(to == from) {
            NG++;
            continue;
        } else {
            dfs(to, now);
            children++;
        }
    }
    ans *= combination(K - NG, children);
    ans %= mod;
    ans *= Factorial[children];
    ans %= mod;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    cin >> N >> K;
    for(int i = 0; i < N-1; i++) {
        ll a, b;
        cin >> a >> b;
        pathes[a].push_back(b);
        pathes[b].push_back(a);
    }
    ans = K;
    dfs(1, -1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 246144
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
#define pb push_back
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int a[n],m[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	m[0]=0;
	m[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		m[i]=min(m[i-1]+abs(a[i]-a[i-1]),m[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<m[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
//   freopen("input.txt","r",stdin);
//   freopen("output.txt","w",stdout);

  ll m,n;
  cin>>m>>n;
  ll dp[m][n];

  string h[m];
  for(ll i=0;i<m;i++)
  cin>>h[i];
  int f=0;
 for(ll i=0;i<n;i++)
 {
     if(h[0][i]=='#')
     {
         dp[0][i]=0;
         f=1;
         continue;
     }
     if(f==0)
     dp[0][i]=1;
     else
     dp[0][i]=0;
 }
 
 f=0;
  for(ll i=0;i<m;i++)
 {
     if(h[i][0]=='#')
     {
         dp[i][0]=0;
         f=1;
         continue;
     }
     if(f==0)
     dp[i][0]=1;
     else
     dp[i][0]=0;
 }
  for(ll i=1;i<m;i++)
  {
    for(ll j=1;j<n;j++)
    {
      if(h[i][j]=='#')
        dp[i][j]=0;
      else
        dp[i][j]=((dp[i-1][j])%mod+(dp[i][j-1])%mod)%mod;
    }
  }

  
  cout<<dp[m-1][n-1];


}

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

using namespace std;

int N, M;
int v[10][10];
int p[10], bulb[10];

int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cin >> N >> M; 
 for(int i=0; i<M; ++i){
   int x; cin >> x;
   for(int j=0; j<x; ++j){
     int s; cin >> s;
     v[i][s-1] = 1;
   }
 }
 for(int i=0; i<M; ++i)
   cin >> p[i];
 int res = 0;
 for(int b=0; b<(1<<N); ++b){
   memset(bulb, 0, sizeof(bulb));
   vector<int> subset;
   for(int i=0; i<N; ++i){
     if(b&(1<<i)){
       subset.push_back(i);
     }
   }
   for(int i=0; i<(int)subset.size(); ++i) 
     for(int j=0; j<M; ++j){
       if(v[j][subset[i]])
           ++bulb[j];
   }
   int pp = 0;
   for(int j=0; j<M; ++j){
     if(bulb[j]%2 == p[j]){
       ++pp;
     }
   }
   if(pp == M)
     ++res;
 }
 cout << res << "\n";
 return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
    int a;
    int max;
    int min;
    int b_max;
    int b_min;
    int c;
    int dif;
    cin >> a;
    if (a < 2) {
        cout << "error" << endl;
        return 1;
    }
    //int b;
    //b = a - 1;
    //vector<int> v(a);
    cin >> c;
    max = 0;
    min = c;
    dif = max - min;
    FOR(i, 1, a){
        cin >> c;
        if (max < c) {
            max = c;
            //cout << "max is " << max << endl;
        }
        if (min > c) {
            if (i != a - 1) {
                if (dif < max - min) {
                    dif = max - min;
                }
                min = c;
                max = 0;
                //cout << "min is " << min << endl;
                //cout << "max is " << max << endl;
            } 
        }
    }
    int ans;
    ans = max - min;
    if (ans > dif) {
        cout << ans << endl;        
    }
    else {
        cout << dif << endl;
    }
}

Measured memory_bytes: 1164
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const X = args[0][0]
	const Y = args[0][1]
	if (X < Y) console.log('<')
	else if (X > Y) console.log('>')
	else console.log('=')
}

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


Measured memory_bytes: 15692
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;

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

int gcd(int x, int y) {
	if (x < y) return gcd_rec(y, x);
	else return gcd_rec(x, y);
}

int main(int argc, char **argv)
{
	int a, b;

	scanf("%d %d", &a, &b);
	printf("%d\n", gcd(a, b));

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(){
 int x;
 cin >> x;
 for(int k = 1; k <= 360 ; k++){
    int ang = k * x;
    if( ang % 360 == 0){
        cout << k << endl;
         return 0;
    }
 }
 return 0;
}
 

Measured memory_bytes: 3604
N, K = map(int, input().split())

H = [int(input()) for n in range(N)]

H.sort(reverse=False)

min_h = 1000000000
for i in range(N - K + 1):
    min_h = min(min_h, H[i + K - 1] - H[i])

print(min_h)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, y);
    rep(i, n+1) {
        for (int j = 0; i + j < n+1; j++) {
            int tmp = n - i - j;
            if (i * 10000 + j * 5000 + tmp * 1000 == y) {
                cout << i << " " << j << " " << tmp << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;


    return 0;
}





Measured memory_bytes: 256
nii=lambda:map(int,input().split())
lnii=lambda:list(map(int,input().split()))

x,n=nii()
p=lnii()

dist=1000
ans=[]
aa=[]
for i in range(-10,110):
  if i not in p:
    ans.append(abs(x-i))
    aa.append(i)
min_inx=ans.index(min(ans))
print(aa[min_inx])

Measured memory_bytes: 9144
while true
    h = gets.to_i
    exit if h==0
    as = h.times.map{gets.split.map(&:to_i)}
    score = 0
    while true
        streak = false
        h.times do |i|
            erased = false
            5.downto(3) do |l|
                if !erased
                    j=0
                    as[i].each_cons(l) do |es|
                        if es.uniq.size==1 && es[0]!=false
                            score+=es[0]*l
                            l.times do |k|
                                as[i][j+k] = false
                            end
                            erased = true
                            streak = true
                            break
                        end
                        j+=1
                    end
                end
            end
        end
        if !streak
            puts score
            break
        end
        
        5.times do |i|
            h.times do |j|
                if as[j][i]==false
                    j.downto(1) do |k|
                        as[k][i]=as[k-1][i]
                    end
                    as[0][i] = false
                end
            end
        end
    end
end


Measured memory_bytes: 6912
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
cost = 0
for i in range(N+1):
    cost += abs(A[i+1]-A[i])
for i in range(1,N+1):
    if A[i-1] <= A[i] <= A[i+1] or A[i+1] <= A[i] <= A[i-1]:
        sub = 0
    elif A[i-1] <= A[i+1] <= A[i]:
        sub = 2*(A[i]-A[i+1])
    elif A[i] <= A[i-1] <= A[i+1]:
        sub = 2*(A[i-1]-A[i])
    elif A[i+1] <= A[i-1] <= A[i]:
        sub = 2*(A[i] -A[i-1])
    elif A[i] <= A[i+1]<= A[i-1]:
        sub = 2*(A[i+1]-A[i])
    print(cost - sub)

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


int main(){
	int n, tmp, prev = 0, cnt = 0;
	cin >> n;
	priority_queue<int> que;
	rep(i,n){
	    cin >> tmp;
	    que.push(tmp);
	}

	rep(i,n){
	    if(prev == que.top()){
            prev = que.top();
            que.pop();
	    }
	    else{
            prev = que.top();
            que.pop();
            cnt++;
	    }
	}
	cout << cnt << endl;

}


Measured memory_bytes: 256