akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  int A,B,C,D;cin>>A>>B>>C>>D;
  
  int X=(A+D-1)/D;
  int Y=(B+C-1)/B;
  
  if(X>=Y){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3604
s = input()
q = int(input())
 
head = []
tail = []
flip = 0
 
for i in range(q):
    query = input().split()
    if query[0] == "1":
        flip ^=1
    else:
        f = int(query[1]) - 1
        c = query[2]
        if (f ^ flip) == 0:
            head.append(c)
        else:
            tail.append(c)
 
if flip:
    head, tail = tail, head
    s = s[::-1]
 
head = "".join(head)
tail = "".join(tail)
 
print(head[::-1] + s + tail)

Measured memory_bytes: 10836
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    ll N;
    cin >> N;

    vector <ll> A(N);
    for(ll i = 0; i < N; i++) cin >> A[i];


    vector <ll> x(N);

    ll A_all = accumulate( all(A), 0ll );
    for(ll i = 1; i < N - 1; i += 2){
        A_all -= 2 * A[i];
    }
    x[0] = A_all;

    for(ll i = 1; i < N ; i++){
        x[i] = 2 * A[i - 1] - x[i - 1];
    }

    cout << x[0];
    for(ll i = 1; i < N; i++){
        cout << " "<< x[i] ;
    }
    cout << endl;


}

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

const int mod = 924844033;
const int MN = 2010;

int fact[MN];

int N, K;

int cc[MN][MN][4];
int dp(int idx, int k, int t) {
    if(idx == 0) return k == 0 && !(t & 2);
    int &ret = cc[idx][k][t];
    if(ret != -1) return ret;

    ret = 0;
    ret += dp(idx - 1, k, t >> 1);
    ret %= mod;
    if(k) {
        ret += dp(idx - 1, k - 1, (t >> 1) | 2);
        ret %= mod;
    }
    if(k && !(t & 1)) {
        ret += dp(idx - 1, k - 1, t >> 1);
        ret %= mod;
    }
    return ret;
}

int dp2[MN], tmp[MN];

int main() {
    fact[0] = 1;
    for(int i = 1; i < MN; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }

    cin >> N >> K;

    memset(cc, -1, sizeof(cc));

    dp2[0] = 1;
    for(int i = 0; i < K; i++) {
        int n = (N - 1 - i) / K + 1;

        for(int j = 0; j <= N; j++) {
            tmp[j] = dp2[j];
            dp2[j] = 0;
        }
        for(int j = 0; j <= n; j++) {
            for(int k = N; k >= j; k--) {
                dp2[k] += 1LL * tmp[k - j] * dp(n, j, 1) % mod;
                dp2[k] %= mod;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i <= N; i++) {
        if(i % 2) {
            ans += mod - 1LL * dp2[i] * fact[N - i] % mod;
            ans %= mod;
        }
        else {
            ans += 1LL * dp2[i] * fact[N - i] % mod;
            ans %= mod;
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 63488
#include <iostream>
#include <complex>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a) * b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a) * b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b * dot_product(p, b) / norm(b); }
int main()
{
    queue<xy_t> vertice;
    char dummy;
    xy_t first, second;
    double x, y;
    while (cin >> x >> dummy >> y)
    {
        vertice.push(xy_t(x, y));
    }
    xy_t origin = vertice.front();
    vertice.pop();
    double area = 0.0;
    while (vertice.size() != 1)
    {
        first = vertice.front()-origin;
        vertice.pop();
        second = vertice.front()-origin;
        area += cross_product(first, second);
    }
    cout << setprecision(10) << fixed;
    cout << 0.5 * abs(area) << endl;
}


Measured memory_bytes: 3152
S = str(input())
ind = [i for i in range(3) if S[i] == 'R']

if len(ind) == 3:
  ans = 3
elif len(ind) == 2:
  if ind == [0, 1]:
    ans = 2
  elif ind == [0, 2]:
    ans = 1
  elif ind == [1, 2]:
    ans = 2
else:
  ans = len(ind)
print(ans)

Measured memory_bytes: 9116
N = int(input())
a_list = list(map(int, input().split()))
a_list.reverse()

partial_sum = 0
sum_ = 0
for i in range(1, N):
  partial_sum += a_list[i-1]
  sum_ += a_list[i] * partial_sum
  
print(sum_ % (10 ** 9 + 7))

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

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var a = read();
		int n = h[0], k = h[1];

		var s = new int[n + 1];
		for (int i = 0; i < n; i++) s[i + 1] = (s[i] + a[i] - 1) % k;

		var r = 0L;
		var d = new int[0].ToDictionary(_ => _);
		for (int i = 0; i <= n; i++)
		{
			if (i >= k) d[s[i - k]]--;
			if (!d.ContainsKey(s[i])) d[s[i]] = 0;
			r += d[s[i]];
			d[s[i]]++;
		}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 43384
#include<bits/stdc++.h>
#define MAX_N 6500000
#define rank Asdfiasofsad
using namespace std;
 
struct edge{
  int c,a,b;
  bool operator < (edge x)const{return c<x.c;}
};
 
int par[MAX_N];
int rank[MAX_N];
int n,m;
edge e[50000];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
}
 
int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}
 
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
 
bool same(int x,int y){return find(x)==find(y);}
 
int cal(){
  int c=0;
  init(n);
  for(int i=0;i<m;i++){
    if(same(e[i].a,e[i].b))continue;
    unite(e[i].a,e[i].b);
    if(++c==n/2)return e[i].c;
  }
}
 
int main(){
  while(cin>>n>>m,n){
    for(int i=0;i<m;i++){
      cin>>e[i].a>>e[i].b>>e[i].c;
      e[i].a--,e[i].b--;
    }
    sort(e,e+m);
    cout<<cal()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3172
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long x[] = new long[N+1];//iが書かれたボールが何個入っているかを管理する配列(i番目がiのボール)
    int A[] = new int[N];//ボールを管理
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
      x[A[i]]++;
    }
    //選び方の総数(どれも削らない場合)を算出
    long allCnt=0;
    for(int i=1;i<=N;i++){
      if(x[i]<=1){
        //一個以下なら何もしない
        allCnt=allCnt;
      }else{
        allCnt=allCnt+(x[i]*(x[i]-1))/2;
      }
    }
    
    //あとは総数からそのボールに書かれている数字を引いた数をそれぞれ出力(具体的にはx[A[i]]個減らす)
    for(int i=0;i<N;i++){
      
      System.out.println(Math.max(0,allCnt-x[A[i]]+1));
      

    }
    
  }
  

  
}


Measured memory_bytes: 100060
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    bool ar[n][m];
    for(int i=0;i<n;i++)for(int j=0;j<m;j++){
        char x;cin>>x;
        ar[i][j]= x == '#';
    }
    
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<m);j++){
            int cnt=0;
            for(int x=0;x<n;x++){
                for(int y=0;y<m;y++){
                    if(ar[x][y]&&(i&(1<<x))&&(j&(1<<y)))cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    
    cout<<ans<<endl;





    return 0;
} 

Measured memory_bytes: 3636
from collections import deque
H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]

# d = [[2001] * W for _ in range(H)]


def bfs(q):
    res_q = deque()
    while len(q):
        x, y = q.popleft()
        for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            nx = x + dx
            ny = y + dy

            if (0 <= nx < H) and (0 <= ny < W) and grid[nx][ny] != '#':
                res_q.append((nx, ny))
                grid[nx][ny] = '#'
    return res_q


q = deque()
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            q.append((i, j))

res = 0
while len(q):
    res += 1
    q = bfs(q)

print(res - 1)


Measured memory_bytes: 117852
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const int big=1e9;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int i,j,n;cin>>n;
	vector<int>p(n+3);
	vector<int>ans(n+3);
	vector<bool>ku(n+3);
	p[0]=n+2;
	for(i=1;i<=n;i++){
		for(j=i;j>=0;j--){ans[j]=0;ku[j]=0;}
		cin>>p[i];
		for(j=i;j>=0;j--){
			if(ku[j]){ans[j]++;}else{ku[p[j]]=true;}
			ans[p[j]]+=ans[j];
		}
		cout<<ans[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3152
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
INF = float('inf')

def bellmanford(edges, s, t, se):
    N = len(edges)
    dist = [INF] * N
    dist[s] = 0
    for i in range(N):
        update = False
        for v in range(N):
            if v not in se or dist[v] == INF:
                continue
            for u, c in edges[v]:
                if u not in se:
                    continue
                d = dist[v] + c
                if d < dist[u]:
                    dist[u] = d
                    update = True
        if update == False:
            return max(0, -dist[t])
    else:
        return -1

N, M, P = map(int, input().split())
es = [[] for i in range(N)]
es_r = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    es[a-1].append((b-1, P-c))
    es_r[b-1].append(a-1)
reachable1 = [False] * N
def dfs(v):
    if reachable1[v]: return
    reachable1[v] = True
    for u, c in es[v]:
        dfs(u)
reachable2 = [False] * N
def rdfs(v):
    if reachable2[v]: return
    reachable2[v] = True
    for u in es_r[v]:
        rdfs(u)
dfs(0)
rdfs(N-1)
se = set()
for i in range(N):
    if reachable1[i] and reachable2[i]:
        se.add(i)
print(bellmanford(es, 0, N-1, se))


Measured memory_bytes: 61532
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;

int vis[100009];
typedef pair<int, int> P;


int main()
{
    int k;
    scanf("%d", &k);
    deque<P> q;
    memset(vis, 0, sizeof(vis));
    q.push_back(make_pair(1, 1));
    while(!q.empty())
    {
        P x = q.front(); q.pop_front();
        if(vis[x.first]) continue;
        vis[x.first] = 1;
        if(x.first == 0)
        {
            printf("%d\n", x.second);
            break;
        }
        q.push_front(make_pair(x.first*10 % k, x.second));
        q.push_back(make_pair((x.first+1) % k, x.second+1));
    }
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	string s;
	char first,second;
	int len;
	int i,ans=0;
	cin >> s;
	len = s.length();
	first = s[0];
	for (i = 2; i < len; i += 2) {
		if(s[i]!=first)
			ans++;
	}
	if (len > 1) {
		if (first == '0') {
			second = '1';
		}
		else {
			second = '0';
		}
		for (i = 1; i < len; i += 2) {
			if (s[i] != second)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m;
    }
}

int main() {
    vector<int> dp(10001);
    dp[0] = 0;
    int n, W, ans = 0;
    cin >> n >> W;
    vector<int> vs(n), ws(n);
    for (int i = 0; i < n; i++){
        cin >> vs[i] >> ws[i];
    }
    dp[0] = 0;
    for (int i = 1; i < 10001; i++){
        dp[i] = 1000000001;
    }
    for (int i = n - 1; i >= 0; i--){
        for (int j = 10000; j >= 0; j--){
            if (j + vs[i] > 10000){
                continue;
            }
            dp[j + vs[i]] = min(dp[j + vs[i]], dp[j] + ws[i]);
        }
    }
    for (int i = 1; i < 10001; i++){
        if (dp[i] <= W){
            ans = max(ans, i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3260
#include <iostream>

int main()
{
	int H;
	int W;
	int N;

	std::cin >> H;
	std::cin >> W;
	std::cin >> N;

	int devider = H > W ? H : W;

	int answer;
	if (N % devider == 0)
	{
		answer = N / devider;
	}
	else
	{
		answer = N / devider + 1;
	}

	std::cout << answer;

	return 0;
}


Measured memory_bytes: 3488
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

typedef pair<int, int> P;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<P> p1, p2;
    map<P, P> mp;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        p1.push_back({a, b});
    }
    p2 = p1;
    sort(p1.begin(), p1.end());
    int c = 1;
    rep(i, M) {
        if(i > 0 && p1[i].first != p1[i - 1].first) c = 1;
        mp[p1[i]] = {p1[i].first, c};
        c++;
    }
    rep(i, M) {
        printf("%06d%06d\n", mp[p2[i]].first, mp[p2[i]].second);
    }
    

    return 0;
}


Measured memory_bytes: 9332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC044
{
	class Q2
	{
		static void Main()
		{
			List<char> str = Console.ReadLine().ToList();

			for(int i = 0; i < 26; i++)
			{
				if (str.Where(x => x == 'a' + (char)i).Count() % 2 == 1)
				{
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}
}


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

int main()
{
   int n;
   cin >> n;
   vector<ll> a(n), b(n), c(n);
   rep(i,n) cin >> a[i]; 
   rep(i,n) cin >> b[i];
   rep(i,n) cin >> c[i];
   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   sort(c.begin(),c.end());
   ll ans = 0;
   rep(i,n)
   {
      auto ite_c = upper_bound(c.begin(),c.end(), b[i]);
      auto ite_a = lower_bound(a.begin(),a.end(), b[i]);
      ll asum = (ite_a - a.begin()); 
      ll csum = -(ite_c - c.end()); 
     // cout << asum << " * " << csum << endl;
      ans += asum * csum;
   }
   cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int a;
    cin >> a;
    vector <string> word;
    word.push_back("Christmas");

    if(a == 25){
        cout << word[0];
    }
    if(a < 25) {
        for (int i = 25; i > a; i--) {
            word.push_back(" Eve");

        }
        for(int j = 0; j <= 25-a; j++){
            cout << word[j];
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int32_t main() {
    int n,k,q; cin >> n >> k >> q;
    vector<int> a(q); cin >> a;
    vector<int> p(n);
    rep (i,n) p[i] = k-q;
    for (int i : a) p[i-1]++;
    rep (i,n) cout << YesNo(p[i] > 0) << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll mod=1e9;
const int inf=0x3f3f3f3f;
ll a[200005];
ll upper=1e18;
int main()
{
	ll A,B,C;
	scanf("%lld%lld%*c%lld",&A,&B,&C);
	
	cout<<A*(B*100+C)/100<<endl;
   
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s;
    ll K;
    cin >> s >> K;

    ll ans = 0;
    ll digit = s.size();
    
    vl P(digit);
    rep(i,digit){
        P[i] = s[i] - '0';
    }
    // digit, K count, bound
    vc<vvc<ll>> dp(digit+1, vvc<ll>(K+1, vc<ll>(2, 0)));
    dp[0][0][1] = 1;
    rep(d,digit){
        rep(k,K){
            if(P[d]==0){
                dp[d + 1][k][0] += dp[d][k][0];
                dp[d + 1][k + 1][0] += dp[d][k][0] * 9;

                dp[d + 1][k][1] = dp[d][k][1];

            }
            else{
                dp[d + 1][k][0] += dp[d][k][1] + dp[d][k][0];
                dp[d + 1][k + 1][0] += dp[d][k][1] * max(0ll, P[d] - 1);
                dp[d + 1][k + 1][0] += dp[d][k][0] * 9;

                dp[d + 1][k+1][1] = dp[d][k][1];
                
            }
            
            
        }
        dp[d + 1][K][0] += dp[d][K][0];
        dp[d + 1][K][1] += dp[d][K][1];
    }
    /*
    rep(i,digit+1){
        rep(j,2){
            rep(k,K+1){
                cout << dp[i][k][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
    }
    */
    cout << dp[digit][K][0] + dp[digit][K][1] << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int hp1, hp2, atk1, atk2;
    cin >> hp1 >> atk1 >> hp2 >> atk2;
    int cnt1, cnt2;
    cnt1 = hp2 / atk1 + (hp2%atk1!=0?1:0);
    cnt2 = hp1 / atk2 + (hp1%atk2!=0?1:0);
    if(cnt1>cnt2)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    int n;cin>>n;
    int words[n][28];
    //rellenar matrices
    std::fill(*words,*words + n*28,0);
    string out;
    fore(i,0,n){
        string val;cin>>val;
        int s = SZ(val);
        fore(j,0,s){
            words[i][val[j]-97]++;
        }
    }
    fore(i,0,28){
        int min = 60;
        fore(j,0,n){
            if(words[j][i]<min){
                min = words[j][i];
            }
        }
        if(min == 60)min = 0;
        fore(j,0,min){
            out += (char)(97+i);
        }
    }
    cout<<out;
	return 0;
}

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

const ld pi = acosl(-1);

int main()
{
	cout << fixed << setprecision(8);
	int a, b, x;
	cin >> a >> b >> x;
	if (x <= a * a * b / 2) {
		ld h = (ld)x * 2 / (a * b);
		cout << atan2(b, h) / pi * 180 << endl;
	}
	else {
		ld h = (ld)(a * a * b - x) * 2 / (a * a);
		cout << atan2(h, a) / pi * 180 << endl;
	}
	return 0;
}


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

const int mod=1000000007,N=3010;
int n,m,a[N],b[N],f[N][N];
char s[N];
inline void reduce(int&x){x+=x>>31&mod;}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m>>(s+1);
	for(int i=1;i<=n;++i)a[i]=i;
	for(int i=1;i<=m;++i){
		int x,y;cin>>x>>y;
		a[x]=max(a[x],y);
	}
	for(int i=1;i<=n;++i)a[i]=max(a[i-1],a[i]);
	for(int i=1;i<=n;++i)b[i]=b[i-1]+(s[i]&1);
	f[0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<i;++j)if(f[i-1][j]){
			int u=b[a[i]]-j,v=a[i]-i+1-u;
			if(v>0&&u>=0)reduce(f[i][j]+=f[i-1][j]-mod);
			if(u>0&&v>=0)reduce(f[i][j+1]+=f[i-1][j]-mod);
		}
	}
	cout<<f[n][b[n]]<<'\n';
	return 0;
}


Measured memory_bytes: 33920
n,m=map(int,input().split())
t=[[] for _ in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    t[p-1].append((y,i))
ans=[""]*m
for i,j in enumerate(t,1):
    j.sort()
    for k,(j,l) in enumerate(j,1):
        ans[l]=str(i).zfill(6)+str(k).zfill(6)
print("\n".join(ans))

Measured memory_bytes: 38376
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define edge(u) for(re int i=head[u];i;i=e[i].nxt)
#define ll long long
using namespace std;
const int N=5005;
const int mod=1e9+7;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,sz[N],cnt,head[N];
ll g[N],dp[N][N],tmp[N];
struct edge{
	int to,nxt;
}e[N<<1];
void add(int a,int b){
	e[++cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
}
void dfs(int u,int f){
	sz[u]=dp[u][1]=1;
	edge(u){
		int v=e[i].to;
		if(v==f) continue;
		dfs(v,u);
		inc(j,1,sz[u]+sz[v]) tmp[j]=0;
		inc(j,1,sz[u])
			inc(k,0,sz[v])
				(tmp[j+k]+=dp[u][j]*dp[v][k])%=mod;
		inc(j,1,sz[u]+sz[v]) dp[u][j]=tmp[j];
		sz[u]+=sz[v];
	}
	for(re int i=2;i<=sz[u];i+=2) (dp[u][0]+=mod-1LL*dp[u][i]*g[i]%mod)%=mod;
}
int main(){
	g[0]=1,n=read();
	for(re int i=2;i<=n;i+=2) g[i]=g[i-2]*(i-1)%mod;
	inc(i,2,n){
		int a=read(),b=read();
		add(a,b),add(b,a);
	}
	dfs(1,0);
	printf("%lld",(mod-dp[1][0])%mod);
}

Measured memory_bytes: 92312
#include<bits/stdc++.h>
using namespace std;
#define f(i,x,n) for(int i=x;i<n;i++)
 
int main()
{
ios::sync_with_stdio(NULL);
cin.tie(NULL);
int n,m;
cin>>n>>m;
vector<int> g[m+1];

  for(int i=0;i<m;i++)
  {
	int k; 
	cin>>k;
	  for(int j=0;j<k;j++)
	  {
		int y; 
		cin>>y;
		y--;
		g[i].push_back(y);
	  }
  } 

vector<int> p(m);
  f(i,0,m) 
	cin>>p[i];
 
int ans=0;
  for(int i=0;i<(1<<n);i++)
  {
	bool ok=true;
	  for(int j=0;j<m;j++)
	  {
		int c=0;
		  for(int id : g[j])
		  {
			if((i>>id)&1)
			  c++;
		  }
			c%=2;
			if(c!=p[j])
			  ok=false;
		}
		if(ok)
		  ++ans;
	}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
//Author : Nishit Patel
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef double db;
typedef long long ll;
#define pb push_back
#define FAST cin.sync_with_stdio(0); cin.tie(0);
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define arep(i, a, n)  for(int i = a; i <= (n); ++i)
#define drep(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x)     for(auto& a : x)
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef unordered_map<ll, ll> hash;
#define deb_1(A)                     {cerr << "[" << #A << "] : " << A << endl;}
#define deb_2(A,B)                   {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl;}
#define deb_3(A,B,C)                 {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl;}
#define deb_4(A,B,C,D)               {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl<< "[" << #D << "] : " << D << endl;}
#define deb_X(x,A,B,C,D,FUNC, ...)  FUNC  
#define deb(...)                    deb_X(,##__VA_ARGS__,\
                                          deb_4(__VA_ARGS__),\
                                          deb_3(__VA_ARGS__),\
                                          deb_2(__VA_ARGS__),\
                                          deb_1(__VA_ARGS__),\
                                         )
ll min(ll a,ll b)
{
	if(a<b) return a;
	return b;
}                              
                                        

int main() {
	FAST
	ll n,ans =0,k;
	
	cin>>n>>k;
	ll v[n];
	ll dp[n];
	rep(i,n)
	{
		cin>>v[i];
	}
	dp[0] = 0;
	dp[1] = abs(v[0] -v[1]);
	arep(i,2,n)
	{
		int minimum = INT_MAX;
		arep(j,1,k)
		{
			if(j>i)break;
			minimum = min((dp[i-j]+ abs(v[i] - v[i-j])),minimum);
		}
		 dp[i] = minimum;
	}
	cout<<dp[n-1]<<endl;	
}


Measured memory_bytes: 5144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long

using namespace std;

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

    if (a == 0) {
        cout << 0 << endl;
    } else if (b == 0) {
        cout << n << endl;
    } else {
        ll d = n / (a + b);
        ll e = n - d * (a + b);
        if (e <= a) {
            cout << d * a + e << endl;
        } else {
            cout << (d + 1) * a << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(nC2(a) + nC2(b))
}

func nC2(n int) int {
	// どうやら n! / 2!(n-2)! と同じ意味になるらしい
	// 知らんけど。(数学ってすごいね)
	return (n * (n - 1)) / 2
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC60();
}

void ABC60(void){
    string a,b,c;
    int i,j;
    cin >> a >> b >> c;
    for(i=0;a[i]!='\0';++i){}
    for(j=0;b[j]!='\0';++j){}
    if((a[i-1]==b[0])&&(b[j-1]==c[0]))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import math

def isprime(n):
    if n==1:return False
    
    for k in range(2,int(math.floor(math.sqrt(n)))+1):
        if n%k==0:
            return False
            
    return True
    
n=int(input())
a=0

for i in range(n):
    x=int(input())
    if isprime(x):
        a+=1
        
print(a)


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    if(S.length() & 1) S.pop_back();
    else{
        S.pop_back();
        S.pop_back();
    }
    while(true){
        int lenS = S.length();
        bool ok = true;
        rep(i, lenS/2){
            if(S[i] != S[i + (lenS/2)]) ok = false;
        }
        if(ok){
            cout << lenS << endl;
            return 0;
        }
        S.pop_back();
        S.pop_back();
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

using Weight=long long;
static const Weight INF=1LL<<57;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

struct Arc {
    // accessible to the reverse edge
    size_t src, dst;
    Weight capacity, cost, flow;
    size_t rev;
    Arc() {}
    Arc(size_t src, size_t dst, Weight capacity, Weight cost=0):
        src(src), dst(dst), capacity(capacity), cost(cost), flow(0), rev(-1)
    {}
    Weight residue() const {
        return capacity - flow;
    }
};

bool operator<(const Arc &e, const Arc &f) {
    if (e.cost != f.cost) {
        return e.cost > f.cost;
    } else if (e.capacity != f.capacity) {
        return e.capacity > f.capacity;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Arcs=vector<Arc>;
using Node=vector<Arc>;
using FlowNetwork=vector<Node>;

void connect(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, 0, -k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

void join(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, c, k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

pair<Weight, Weight> mincost_flow(
    FlowNetwork &g, size_t s, size_t t, Weight F=INF
) {
    size_t V=g.size();
    vector<Arc *> prev(V, NULL);

    pair<Weight, Weight> total;  // <cost, flow>
    while (F > total.second) {
        vector<Weight> d(V, INF); d[s]=0;
        for (bool updated=true; updated;) {
            updated = false;
            for (size_t v=0; v<V; ++v) {
                if (d[v] == INF) continue;

                for (Arc &e: g[v]) {
                    if (e.capacity <= 0) continue;

                    if (d[e.dst] > d[e.src] + e.cost) {
                        d[e.dst] = d[e.src] + e.cost;
                        prev[e.dst] = &e;
                        updated = true;
                    }
                }
            }
        }

        if (d[t] == INF) {
            total.first = -1;
            return total;
        }

        Weight f=F-total.second;
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src])
            f = min(f, e->capacity);

        total.second += f;
        total.first += f * d[t];
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src]) {
            e->capacity -= f;
            g[e->dst][e->rev].capacity += f;
        }
    }

    return total;
}

int main() {
    size_t V, E;
    Weight F;
    scanf("%zu %zu %lld", &V, &E, &F);

    FlowNetwork g(V);
    for (size_t i=0; i<E; ++i) {
        size_t u, v;
        Weight c, d;
        scanf("%zu %zu %lld %lld", &u, &v, &c, &d);

        connect(g, u, v, c, d);
    }

    printf("%lld\n", mincost_flow(g, 0, V-1, F).first);
    return 0;
}

Measured memory_bytes: 2876
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<bool> check(N);
  for (int i = 0; i < K;i++){
    int d;
    cin >> d;
    for (int j = 0; j < d;j++){
      int a;
      cin >> a;
      a--;
      check[a] = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if(!check[i]){
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

long long gcd(long long a, long long b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

long long lcm(long long a, long long b)
{
    return ((long long)a * b) / ((long long)gcd(a, b));
}

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

    cout << lcm(a, b) << endl;
}

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

using namespace std;

#define _int64 long long

int a[100];

int main()
{
  _int64 ans1,ans2;
  int i,j,n;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d",&a[i]);
  ans1=1;
  ans2=1;
  for (i=0;i<n;i++)
  {
    ans1*=3;
    if (a[i]%2==0) ans2*=2;
  }
  ans1-=ans2;
  printf("%lld\n",ans1);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
using pii = pair <int,int>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

int h,w;
pair <int,int> s,d;
vector <string> a;
vector <vector <pair <int,int>>> adj;
vector <int> dist;

void bfs01(int src){
	dist[src] = 0;
	queue <int> q0;
	queue <pair<int,int>>q1;
	vector <bool> vis(h * w,0);
	q0.push(src);
	int count = 0;
	int count1 = 0;
	while(!q0.empty() or !q1.empty()){
		//if(count > 785399) break;
		++count;
		//cout << q0.size() << " " << q1.size() << newl;
		while(!q0.empty()){
			//if(count >= 785394) cout << ++count1 << newl;
			int u = q0.front();
			q0.pop();
			if(vis[u]) continue;
			vis[u] = 1;
			for(auto v : adj[u]){
				if(!vis[v.first]){
					int vv = v.first;
					int dd = v.second;
					if(dd == 1) q1.push({vv,dist[u] + 1});
					else{
						q0.push(vv);
						dist[vv] = dist[u];
					}
				}
			}
		}
		if(!q1.empty()){
			auto u1 = q1.front();
			int u = u1.first;
			q1.pop();
			if(vis[u]) continue;
			vis[u] = 1;
			dist[u] = u1.second;
			for(auto v : adj[u]){
				if(!vis[v.first]){
					int vv = v.first;
					int dd = v.second;
					if(dd == 1)q1.push({vv,dist[u] + 1});
					else{
						q0.push(vv);
						dist[vv] = dist[u];
					}
				}
			}
			
		}
	}
	return;
}

void solve(){
//	for(int i = 0;i < 1000;++i){
//		for(int j = 0;j < 1000;++j){
//			int x = rand();
//			if(x & 1) cout << "#";
//			else cout << "."; 
//		}
//		cout << newl;
//	}
	cin >> h >> w;
	cin >> s.first >> s.second;
	cin >> d.first >> d.second;
	--s.first,--s.second,--d.first,--d.second;
	
	dist = vector <int>(h * w,-1);
	a = vector <string>(h);
	adj = vector <vector <pair<int,int>>>(h * w);
	
	for(int i = 0;i < h;++i) cin >> a[i];
	for(int i = 0;i < h;++i){
		for(int j = 0;j < w;++j){
			if(a[i][j]!='#'){
				if(i - 1 >= 0 and a[i - 1][j] == '.') adj[i * w + j].push_back({(i - 1) * w + (j),0});
				if(i + 1 < h and a[i + 1][j] == '.') adj[i * w + j].push_back({(i + 1) * w + (j),0});
				if(j - 1 >= 0 and a[i][j - 1] == '.') adj[i * w + j].push_back({(i ) * w + (j - 1),0});
				if(j + 1 < w and a[i][j + 1] == '.') adj[i * w + j].push_back({(i ) * w + (j + 1),0});
				for(int i1 = -2;i1 <= 2;++i1){
					for(int j1 = -2;j1 <= 2;++j1){
						if(i1 == 0 and j1 == 0) continue;
						if(i - i1 >= 0 and i - i1 < h and j - j1 >= 0 and j - j1 < w and a[i - i1][j - j1] == '.') adj[i * w + j].push_back({(i - i1) * w + j - j1,1});
					}
				}
			}
		}
	}
	bfs01(s.first * w + s.second);
	cout << dist[d.first * w + d.second] << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
		   freopen("out.txt","w",stdout);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v)                               \
  cerr << #v << ": ";                              \
  REP(__i, (v).size()) cerr << ((v)[__i]) << ", "; \
  cerr << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(), x.end()
#define MM << " " <<
int main() {
  ll x;
  cin >> x;

  ll sum = 100;

  int year = 0;
  while (sum < x) {
    sum *= 1.01;
    year++;
  }

  cout << year << endl;
}


Measured memory_bytes: 3636
a,b,c,x,y = map(int, input().split(" "))

cost1 = x * a + y * b

if x > y:
    price = a
else:
    price = b

cost2 = min(x, y) * 2 * c + (max(x, y) - min(x, y)) * price

cost3 = max(x,y) * 2 * c

print(min(cost1,cost2,cost3))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <list>
#define MODULO 1000000007 // Hitesh Vadher
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;
//#define endl '\n'

void solve()
{
    ll n {};
    cin >> n;
    
    vector <vector<ll>> a (n, vector <ll> (2,0));
    
    for(ll i = 0; i < n; i++)
    {
        cin >> a.at(i).at(0) >> a.at(i).at(1);
    }
    
    for(ll i = 2; i < n; i++)
    {
        if(a.at(i-2).at(0)==a.at(i-2).at(1) && a.at(i-1).at(0)==a.at(i-1).at(1) && a.at(i).at(0)==a.at(i).at(1))
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

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

const int maxn = 51;
const int M = 1e9+7;
int N;
ll K;

void madd(int& a, int b) {
    a = (a+b) % M;
}

struct Matrix
{
    int m[maxn][maxn];
    int n;
    Matrix(int N_) {
        n = N_;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                m[i][j] = 0;
            }
        }
    }
};

Matrix operator*(Matrix a, Matrix b) {
    int n = a.n;
    Matrix res(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < N; k++) {
                madd(res.m[i][j],(1LL*a.m[i][k]*b.m[k][j])%M);
            }
        }
    }
    return res;
}

Matrix power(Matrix a, ll p) {
    int n = a.n;
    Matrix ans(a.n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans.m[i][j] = (i==j);
        }
    }
    while (p) {
        if (p & 1) ans = ans * a;
        a = a * a;
        p >>= 1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> K;
    Matrix aa(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> aa.m[i][j];
        }
    }
    Matrix ans = power(aa,K);
    int tot = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            madd(tot,ans.m[i][j]);
        }
    }
    cout << tot << '\n';


    return 0;
}



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

int main()
{

	ll n,x=0,y=0,x1,y1,t1=0,t2,ans,d1,d2;
	cin>>n;
	bool check=1;
	while(n--)
	{
		cin>>t2>>x1>>y1;
		
		d1=x1-x;  d2=y1-y;
		if(d1<0) d1=-d1;
		if(d2<0) d2=-d2;
		
		ans=t2-t1-d1-d2;
		
		if(ans%2!=0 || ans<0) check=0;
		
		t1=t2;x=x1;y=y1;
		
	}
	if(check==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  
  int G[N][N];
  int i,j,n,u,k,v;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)G[i][j]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      G[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",G[i][j]);
    }

    printf("\n");
  }
    return 0;

  }



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

int main() {
    int N;
    cin >> N;
    vector<int>P(N);
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
    }
    // 座標を保存
    vector<int>plot(N+1);
    for (int i = 0; i < N; ++i) {
        plot[P[i]] = i;
    }
    //　2番目に大きいのがn-1から1までの場合を考える
    ll ans = 0;
    multiset<int> se{-1, -1, plot[N], N, N}; // 今見てるのより大きい数の座標
    for (int i = N-1; i > 0; --i) {
        se.insert(plot[i]);
        auto iter = se.lower_bound(plot[i]);
        auto iterR = iter;
        iterR++;
        auto iterRR = iterR;
        iterRR++;
        auto iterL = iter;
        iterL--;
        auto iterLL = iterL;
        iterLL--;
        ll temp = 0;
        temp += (*iterRR - *iterR) * (*iter - *iterL);
        temp += (*iterR - *iter) * (*iterL - *iterLL);
        ans += i * temp;
    }

    cout << ans;
    return 0;
}

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

int main() {
    int n;cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int b=0;
    for (int i=n-1;i>0;i--)
        if (a[i-1]==a[i]) {
            if (b) {
                cout<<(ll)b*a[i]<<endl;
                return 0;
            }
            b=a[i];
            i--;
        }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let t = read::<usize>();
    for _ in 0..t {
        if solve() {
            println!("0");
        } else {
            println!("1");
        }
    }
}

fn solve() -> bool {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    let s = read::<String>().chars().collect::<Vec<_>>();

    let mut bases = vec![];
    for i in (0..n).rev() {
        let mut cur = a[i];
        for &elem in bases.iter().rev() {
            cur = min(elem ^ cur, cur);
        }
        if cur == 0 {
            continue;
        }
        if s[i] == '1' {
            return false;
        } else {
            bases.push(cur);
            bases.sort();
        }
    }
    true
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a;cin >> n >> a;
	vector<ll> x(n);
	rep(i,n) cin >> x.at(i);
	ll dp[51][51][2501];
	dp[0][0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=i;++j){
			for(int k=0;k<=2500;++k){
				if(k-x[i-1]>=0 && j-1>=0){
					dp[i][j][k]=dp[i-1][j-1][k-x[i-1]]+dp[i-1][j][k];
				}
				else dp[i][j][k]=dp[i-1][j][k];
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;++i){
		ans+=dp[n][i][a*i];
	}
	cout << ans << endl;
}

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

#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    string s, t;
    cin >> s >> t;
    
    int ans = INF;
    for (int i = 0; i <= s.size() - t.size(); i++) {
        int count = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] != t[j])
                count++;
        }
        ans = min(ans, count);
    }
    cout << ans;
    return 0;
} 


Measured memory_bytes: 3632
main = do
  _ <- getLine
  s <- getLine

  let countLR (c:cs) nl nr | c == '('           = countLR cs (nl+1) nr
                           | c == ')' && nl > 0 = countLR cs (nl-1) nr
                           | otherwise          = countLR cs nl (nr+1)
      countLR []     nl nr = (nl, nr)

      (nl, nr) = countLR s 0 0

  putStr $ replicate nr '('
  putStr s
  putStrLn $ replicate nl ')'

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

int main(){
    int a,b;
    cin>>a>>b;
    int n=0;
    bool judge=false;
    while(n<1200){
        if(n*8/100==a&&n*10/100==b){
            cout<<n<<endl;
            judge=true;
            break;
        }
        n++;
    }
    if(judge==false)cout<<"-1"<<endl;
}

Measured memory_bytes: 256