akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int MAXN = 100;
static const int INTFY = (1 << 21);

int n, M[MAXN][MAXN];

int prim()
{
	int u, minv;
	int d[MAXN], p[MAXN], color[MAXN];
	
	for(int i = 0; i < n; i++)
	{
		d[i] = INTFY;
		p[i] = -1;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	
	while(true)
	{
		minv = INTFY;
		u = -1;
		for(int i = 0; i < n; i++)
		{
			if(minv > d[i] && color[i] != BLACK)
			{
				u = i;
				minv = d[i];
			}
		}

		if(u == -1) break;
		color[u] = BLACK;

		for(int v = 0; v < n; v++)
		{
			if(color[v] != BLACK && M[u][v] != INTFY)
			{
				if(M[u][v] < d[v])
				{
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for(int i = 0; i < n; i++)
	{
		if(p[i] != -1)
			sum += M[i][p[i]];
	}
	return sum;	
}


int main ()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++) 
		{
			int e;
			cin >> e;
			M[i][j] = (e == -1)? INTFY : e; 
		}
	}
	cout << prim() << endl;
	
	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  ll na = 0;
  ll ans = 0;
  bool searchA = true;
  ll i=0;
  REP(i,s.length()){
    //cout << "i: " << i << ", na: " << na << " -> ";
    //cout << ans << " " << s.substr(i,s.length()-i) << endl;
    if(s[i]=='A') na++;
    else if(i<(ll)(s.length()-1) && s[i]=='B' && s[i+1]=='C' && na>0){
      searchA = false;
      ans += na;
      i++;
    }else{
      na = 0;
    }
    //cout << "i: " << i << ", na: " << na << "ans:" << ans<< endl;
  }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int a,b,c; cin>>a>>b>>c;
    if(a*c<=b) cout<<c<<endl;
    else cout<<b/a<<endl;
}

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

int main(){
    int x, y;
    cin >> x >> y;

    int ans = 0;
    if(x <= 3){
        ans += (4-x) * 100000;
    }

    if(y <= 3){
        ans += (4-y) * 100000;
    }

    if(x == y && x == 1){
        ans += 400000;
    }

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




Measured memory_bytes: 256
L = []
M = [[0 for i in range(3)] for j in range(3)]
for i in range(3):
  L_i = [int(s) for s in input().rstrip().split(' ')]
  L.append(L_i)
N = int(input())
for num in range(N):
  x = 0
  b_num = int(input())
  for k in range(3):
    for l in range(3):
      if L[k][l] == b_num:
        M[k][l] = 1
        x = 1
        break
    if x == 1:
      break
if M[0][0]*M[1][0]*M[2][0] + M[0][1]*M[1][1]*M[2][1] + M[0][2]*M[1][2]*M[2][2] >= 1:
  print("Yes")
elif M[0][0]*M[0][1]*M[0][2] + M[1][0]*M[1][1]*M[1][2] + M[2][0]*M[2][1]*M[2][2] >= 1:
  print("Yes")
elif M[0][0]*M[1][1]*M[2][2] + M[0][2]*M[1][1]*M[2][0] >= 1:
  print("Yes")
else:
  print("No")
  

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

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x-r<0||x+r>W||y-r<0||y+r>H){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
}

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

ll N;
int n, q[300], l = 150, r = 149;

void Dfs (ll x) {
	if (x == 1) return ;
	if (x & 1) {
		Dfs(x - 1);
		q[--l] = ++n;
	} else {
		Dfs(x >> 1);
		q[++r] = ++n;
	}
}

int main () {
	scanf("%lld", &N);
	Dfs(N + 1);
	printf("%d\n", n << 1);
	for (int i = l; i <= r; ++i) printf("%d ", q[i]);
	for (int i = 1; i <= n; ++i) printf("%d ", i);
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    if a.len()%2==1 {println!("No");exit(0)}
    for i in 0..a.len() {
        if i%2==0&&a[i]!='h'{println!("No");exit(0)}
        else if i%2==1&&a[i]!='i'{println!("No");exit(0)}
    }
    println!("Yes")
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int32_t M=1e9+7;
int32_t rev(int32_t x,int32_t m){
    if(x==1)return 1;
    return (1-(ll)rev(m%x,x)*m)/x+m;
}
struct mint{
    int32_t x;
    mint():x(0){}
    mint(int32_t xx):x(xx%M){if(x<0)x+=M;}
    mint(ll xx):x(xx%M){if(x<0)x+=M;}
    mint& operator+=(mint b){if((x+=b.x)>=M)x-=M;return *this;}
    mint operator+(mint b){mint res=*this;res+=b;return res;}
    mint& operator-=(mint b){if((x-=b.x)<0)x+=M;return *this;}
    mint operator-(mint b){mint res=*this;res-=b;return res;}
    mint& operator*=(mint b){x=(ll)x*b.x%M;return *this;}
    mint operator*(mint b){mint res=*this;res*=b;return res;}
    mint inverse(){return rev(x,M);}
    mint& operator/=(mint b){x=(ll)x*rev(b.x,M)%M;return *this;}
    mint operator/(mint b){mint res=*this;res/=b;return res;}
    mint operator^(ll w) {mint r=1,a=*this;while(w){if(w&1)r*=a;a*=a;w/=2;}return r;}
    mint operator^=(ll w){return *this=(*this)^w;}
    mint operator^(mint w){return *this^w.x;}
    mint operator^=(mint w){return *this=(*this)^w;}
    mint operator-()const{return mint()-*this;}
    explicit operator bool()const{return x;}
};
istream&operator>>(istream&is,mint&p){istream&res=is>>p.x;p.x%=M;return res;}
ostream&operator<<(ostream&os,mint p){return os<<p.x;}
template<typename T>mint operator+(T x,mint y){return mint(x)+y;}
template<typename T>mint operator-(T x,mint y){return mint(x)-y;}
template<typename T>mint operator*(T x,mint y){return mint(x)*y;}
template<typename T>mint operator/(T x,mint y){return mint(x)/y;}
template<typename T>mint operator^(T x,mint y){return mint(x)^y;}
mint abs(mint x){return x;}
const int N=1e6+6;
mint dp[N];
mint s[N];
mint gs(int i){
    if(i<0)return 0;
    return s[i];
}
mint g(int l,int r){
    return gs(r)-gs(l-1);
}
int32_t main(){
    int n,h,d;
    cin>>n>>h>>d;
    mint f=1;
    mint sf=0;
    for(int i=1;i<=n;++i){
        f*=i;
        sf+=f;
    }
    dp[0]=s[0]=f;
    for(int i=1;i<h;++i){
        dp[i]=sf*g(i-d,i-1);
        s[i]=s[i-1]+dp[i];
    }
    cout<<g(h-d,h-1)<<'\n';
    return 0;
}


Measured memory_bytes: 11472
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
MOD = 10**9+7

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return sys.stdin.readline().rstrip()
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()


def main():
  n, m = LI()

  if m%2==1:
    print(-1)
    exit()

  graph = defaultdict(set)
  grapht = defaultdict(set)
  for i in range(m):
    a, b = LI()
    a -= 1
    b -= 1
    graph[a].add(b)
    graph[b].add(a)
    grapht[a].add(b)
    grapht[b].add(a)

  graph2 = defaultdict(set)
  visited = [0 for i in range(n)]
  num = [1 for i in range(n)]

  def dfs(x):
    visited[x] = 1

    for nx in graph[x]:
      if not visited[nx]:
        dfs(nx)

    t = set()
    if num[x]==1 and len(grapht[x])%2==0:
      for e in grapht[x]:
        graph2[x].add(e)
        t.add(e)
    elif num[x]==-1 and len(grapht[x])%2==0:
      for j, e in enumerate(grapht[x]):
        if j==len(grapht[x])-1:
          graph2[e].add(x)
          num[e] *= -1
        else:
          graph2[x].add(e)
        t.add(e)
    elif num[x]==1 and len(grapht[x])%2==1:
      for j, e in enumerate(grapht[x]):
        if j==len(grapht[x])-1:
          graph2[e].add(x)
          num[e] *= -1
        else:
          graph2[x].add(e)
        t.add(e)
    elif num[x]==-1 and len(grapht[x])%2==1:
      for e in grapht[x]:
        graph2[x].add(e)
        t.add(e)

    for e in t:
      grapht[x].remove(e)
      grapht[e].remove(x)

  dfs(0)

  for i in range(n):
    for e in graph2[i]:
      print(i+1, e+1)

if __name__ == '__main__':
  main()

Measured memory_bytes: 197676
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	rep2(i, 1, n+1){
		string s = to_string(i);
		int temp = 0;
		for(auto c : s){
			temp += c - '0';
		}
		if(a <= temp && temp <= b)ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*My CSP has exploded*/
/*ABC146*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
using namespace std;

#define LL long long
#define DB double
#define MAXN 100000
#define Pr pair<int,int>
#define X first
#define Y second
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}

int n,k;
vector<Pr> G[MAXN+5];
int fc[MAXN+5],col[MAXN+5];
void dfs(int x,int f){
    int cnt=0;
    for(int i=0;i<G[x].size();i++){
        int v=G[x][i].X,id=G[x][i].Y;
        if(v==f)continue;
        cnt++;
        if(cnt==fc[x])cnt++;
        col[id]=cnt,fc[v]=cnt;
        dfs(v,x);
    }
    k=max(cnt,k);
}
int main()
{
    n=read();
    for(int i=1;i<n;i++){
        int u=read(),v=read();
        G[u].push_back(Pr(v,i));
        G[v].push_back(Pr(u,i));
    }
    dfs(1,0);
    printf("%d\n",k);
    for(int i=1;i<n;i++)
    printf("%d\n",col[i]);
}


Measured memory_bytes: 9472
#include <iostream>
using namespace std;
int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	int a_index = 0, b_index = -1, c_index = -1;
	char next = a[0];
	while( true )
	{
		if( next == 'a' ){
			a_index++;
			if( a_index == a.size() )
				break;
			next = a[a_index];
		}else if( next == 'b' ){
			b_index++;
			if( b_index == b.size() )
				break;
			next = b[b_index];
		}else{
			c_index++;
			if( c_index == c.size() )
				break;
			next = c[c_index];
		}
	}
	if( next == 'a' ){
		cout << "A";
	}else if( next == 'b' ){
		cout << "B";
	}else{
		cout << "C";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
int map[255][255];
int main()
{	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			map[i][j]=0;
		}
	for(int i=0;i<n;i++)
	{
		int cur,k,u;
		cin>>cur>>k;
		while(k--)
		{
			cin>>u;
			map[cur][u]=1;
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			if(j!=n) cout<<map[i][j]<<" ";
			else cout<<map[i][j]<<endl;
		}
	return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;

    int P, D, M;
    P = A + B;
    D = A - B;
    M = A * B;

    int print = 0;
    print = max(max(P,D),M);

    cout << print << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int n;long m;
		scanf("%d %ld",&n,&m);
		int i,tmp=m/n;
		if(m%n==0){
				printf("%d",tmp);
		}else{
				long max=0;
				for(i=1;i<=tmp;i++){
						if(m%i==0){
								if(max<i)max=i;
						}
				}
				printf("%d",max);
		}
		return 0;
}


Measured memory_bytes: 128
row0 = list(map(int,input().split()))
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))

rows = [row0,row1,row2]
rowsdiff = []
for item in rows:
  rowsdiff.append([item[1]-item[0],item[2]-item[1]])
columns = [[rows[0][i],rows[1][i],rows[2][i]] for i in range(3)]
columnsdiff = []
for item in columns:
  columnsdiff.append([item[1]-item[0],item[2]-item[1]])

Answer = 'Yes'
rowscheck = (rowsdiff[0]==rowsdiff[1])*(rowsdiff[1]==rowsdiff[2])
columnscheck = (columnsdiff[0]==columnsdiff[1])*(columnsdiff[1]==columnsdiff[2])
if rowscheck*columnscheck != 1:
  Answer = 'No'

print(Answer)

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

using namespace std;

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

  string s;
  cin >> s;
  if (s[2] == s[3] and s[4] == s[5]) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;

int main() {
    long long  n, k;
    cin >> n >>k;
    long long ans = 0;
    if(k == 0) ans = n*n;
    else {
        for (int b = k+1; b <= n; b++){
            ans += n/b*(b-k);
            ans += max(0LL, n%b-k+1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

// 累積xorは 4n 1 4n+3 0 4(n+1) 1 4(n+1)+3 0 の周期となる
lint culXOR(lint x) {
	if (x % 2 == 0) return 4 * (x / 4) + x % 4 / 2 * 3;
	else return (x + 1) % 4 / 2;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint A, B;
	cin >> A >> B;
	cout << (culXOR(A-1) ^ culXOR(B));

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;

int main(void){
    
    scanf("%d", &N);
    
    if(1 <= N && N < 105) printf("0\n");
    else if(105 <= N && N < 135) printf("1\n");
    else if(135 <= N && N < 165) printf("2\n");
    else if(165 <= N && N < 189) printf("3\n");
    else if(189 <= N && N < 195) printf("4\n");
    else printf("5\n");
    
    return 0;
}


Measured memory_bytes: 256
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




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


def II():
    return int(input())

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

#S=list(map(int,list(input())[:-1]))[::-1]
S=list(map(int,list(input())[:-1]))
#print(S)

N=len(S)
smod=[0]*N
bef=0
b=1

for i in range(len(S)):
    l=N-i-1
    bef+=(S[l]*(b))%2019
    smod[l]=bef%2019
    #smod.append(bef%2019)
    b=(b*10)%2019
    
cnt=[0]*2020
for sm in smod:
    cnt[sm]+=1

cnt[0]+=1

res=0
for sc in cnt:
    res+=sc*(sc-1)/2
    
    
print(int(res))

#print(smod)

#print(cnt[:10])

Measured memory_bytes: 88988
#include <iostream>
#include <algorithm>
using namespace std;
 
int ord2(int N) {
	int count = 0; 
	while(N % 2 == 0) {
		N /= 2;
		count++;
	}
	return count;
}
 
int main() {
	int N; 
   	cin >> N;
	int kaisuu = 30;  
	for(int i = 0; i < N; ++i) 
	{int s;
	cin >> s;
   	int n = ord2(s); 
	kaisuu = min(kaisuu, n);
	} 
	cout << kaisuu << endl; 
}

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


int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		// cout<<char();
		if(((int(s[i])+n)%91)>64)
			cout<<char(((int(s[i])+n)%91));
		else
			cout<<char(((int(s[i])+n)%91)+65);
	}
}

Measured memory_bytes: 256
/*input
TSTTSS
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	string s;
	cin>>s;
	string ans="";
	for(char c:s){
		if(c=='T'&&SZ(ans)&&ans.back()=='S'){
			ans.pop_back();
		}
		else ans.pb(c);
	}
	cout<<SZ(ans)<<'\n';
	return 0;
}


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

int main() {
	
	string s;
	string ab[10]={"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "};
	string res[8];
	int t=0;
	
	while(cin>>s){
		if(t)cout<<endl;
		++t;
		
		for(int i=0;i<8;++i)res[i]="";
		
		int l=s.length();
		
		for(int i=0;i<5-l;++i){
			s = "0" + s;
		}
		
		for(int j=0;j<5;++j){
			for(int i=0;i<8;++i){
				res[i] += ab[s[j]-'0'][i];
			}
		}
		for(int i=0;i<8;++i){
			cout<<res[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  
  vector<int> c(26);
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  
  vector<vector<int>> s(D, vector<int>(26));
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }

  vector<int> last(26,0);
  for(int i=0; i<D; i++){
    int kaisai = 0;
    int tmp = 0;
    for(int k=0; k<26; k++){ // i日目にk thの問題
      int add = s.at(i).at(k);
      last.at(k) = i+1;
      for(int j=0; j<26; j++){
        add -= c.at(j)*(1 + i - last.at(j));
      }
      last.at(k) = i-1;
      if(tmp < add){
        tmp = add;
        kaisai = k;
      }
	}
    
    last.at(kaisai) = i+1;
    if(i == D-1){
      cout << kaisai+1;
    }else{
      cout << kaisai+1 << endl;
    }
    
  }
  
  return 0; 
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,K;
    cin>>N>>K;

    vector<int> s(N,0);
    rep(k,0,K){
        int d;
        cin>>d;
        rep(i,0,d){
            int a;
            cin>>a;
            s.at(a-1)++;
        }
    }
    int ans=0;
    rep(n,0,N) if(s.at(n)==0) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
n,m = map(int,input().split())
t = [0]*m

for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,a[0]+1):
        t[a[j]-1] += 1

count = 0
for i in range(len(t)):
    if t[i] == n:
        count += 1
print(count)





Measured memory_bytes: 3060
#include <cstdio>
const int N=2000005,mo=1000000007;
typedef long long LL;
LL fac[N],inv[N],ans=0;
int U,D,L,R;
LL ksm(LL x,int y){
	LL i=1;
	for (;y;y>>=1,(x*=x)%=mo)
		if (y&1) (i*=x)%=mo;
	return i;
}
LL C(int n,int m){
	return fac[n]*inv[m]%mo*inv[n-m]%mo;
}
LL F(int a,int b,int c,int d){
	return C(c+d-a-b,c-a);
}
void calc(int x1,int y1,int x2,int y2,bool f){
	LL cnt=0;
	for (int i=L;i<=R;i++) cnt-=F(x1,y1,U-1,i)*F(U,i,x2,y2)%mo*(U-1+i);
	for (int i=L;i<=R;i++) cnt+=F(x1,y1,D,i)*F(D+1,i,x2,y2)%mo*(D+i);
	for (int i=U;i<=D;i++) cnt-=F(x1,y1,i,L-1)*F(i,L,x2,y2)%mo*(i+L-1);
	for (int i=U;i<=D;i++) cnt+=F(x1,y1,i,R)*F(i,R+1,x2,y2)%mo*(i+R);
	if (f) ans-=cnt;else ans+=cnt;
}
int main(){
	int x[6],y[6],n=N-1;
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mo;
	inv[n]=ksm(fac[n],mo-2);
	for (int i=n;i>=1;i--) inv[i-1]=inv[i]*i%mo;
	for (int i=0;i<6;i++) scanf("%d",&x[i]);
	for (int i=0;i<6;i++) scanf("%d",&y[i]);
	x[0]--;y[0]--;x[5]++;y[5]++;
	U=x[2];D=x[3];L=y[2];R=y[3];
	for (int i=0;i<2;i++)
		for (int j=0;j<2;j++)
			for (int k=0;k<2;k++)
				for (int l=0;l<2;l++)
					calc(x[i],y[j],x[4|k],y[4|l],i^j^k^l);
	printf("%lld\n",(ans%mo+mo)%mo);
}

Measured memory_bytes: 31488
#include<atcoder/all>
using namespace atcoder;

#include<bits/stdc++.h>
#include<array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

using MLL = modint998244353;
MLL RSQ_e() { return 0; }
MLL RSQ_f(MLL a, MLL b) { return a + b; }
using RSQ = segtree<MLL, RSQ_f, RSQ_e>;

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

    MLL invK = MLL(K).inv();
    vector<MLL> f(N), invf(N);
    rep(i, K) f[i] = 1;
    for (int i = K; i < N; i++) f[i] = f[i - 1] * (K - 1) * invK;
    rep(i, N) invf[i] = f[i].inv();

    RSQ Q1(N), Q2(N), Q3(N);
    MLL inv2 = MLL(2).inv();
    int I[200000]; rep(i, N) { int a; scanf("%d", &a); a--; I[a] = i; }
    MLL ans = 0;
    rep(i, N) {
        ans += Q1.prod(0, I[i]) * f[I[i]] * inv2;
        ans -= Q2.prod(I[i] + 1, N) * invf[I[i]] * inv2;
        ans += Q3.prod(I[i] + 1, N);
        Q1.set(I[i], invf[I[i]]);
        Q2.set(I[i], f[I[i]]);
        Q3.set(I[i], 1);
    }
    printf("%u\n", ans.val());

    return 0;
}

Measured memory_bytes: 12624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll N,A,B; cin>>N>>A>>B;
	ll q=N/(A+B), r=N%(A+B);
	cout<<q*A+min(r,A)<<"\n";
	return 0;
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

signed main() {
    int N, H, W;
    cin >> N >> H >> W;
    int ans = 0;
    rep(i, N){
        int a, b;
        cin >> a >> b;
        if (H <= a && W <= b) ++ans;
    }
    cout << ans << nl;
}


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

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

using namespace std;

#define MAX_N 110
#define MAX_W 10100

int n,P[MAX_N],V[MAX_N], C;
int dp[MAX_N][MAX_W];

int main() {
  cin >> n >> C;
  rep(i,n) cin >> P[i] >> V[i];
  for(int i=1;i<=n;++i) {
    for(int sum_V=0;sum_V<=C;++sum_V) {
      if( sum_V-1 >= 0 ) {
        //dp[i][sum_V] = dp[i][sum_V-1];
      }
      dp[i][sum_V] = max(dp[i][sum_V],dp[i-1][sum_V]);
      if( sum_V-V[i-1] >= 0 ) {
        dp[i][sum_V] = max(dp[i][sum_V],
                           dp[i-1][sum_V-V[i-1]]+P[i-1]);
      }
    }
  }
  cout << dp[n][C] << endl;
  return 0;
}
 

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m, x[100002];
const LL MOD = 1000000007;

void mat_prod(LL a[3][3], LL b[3][3], LL c[3][3]) { // a = b * c;
	LL d[3][3];
	inc(i, 3) {
	inc(j, 3) {
		d[i][j] = 0;
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
	inc(k, 3) {
		(d[i][j] += b[i][k] * c[k][j]) %= MOD;
	}
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = d[i][j];
	}
	}
	
	return;
}

void mat_exp(LL a[3][3], LL b[3][3], LL c) { // a = b ^ c;
	static bool flag = true;
	static LL t[30][3][3];
	if(flag) {
		inc(i, 3) {
		inc(j, 3) {
			t[0][i][j] = b[i][j];
		}
		}
		inc(i, 30 - 1) {
			mat_prod(t[i + 1], t[i], t[i]);
		}
		flag = false;
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = 0;
	}
	}
	inc(i, 3) { a[i][i] = 1; }
	inc(i, 30) {
		if(c & (1 << i)) {
			mat_prod(a, a, t[i]);
		}
	}
	
	return;
}

int main() {
	cin >> n >> m;
	inc1(i, m) { cin >> x[i]; }
	x[0] = 0;
	x[m + 1] = n + 1;
	
	LL a[3][3] = { { 2, 1, 1 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL b[3][3] = { { 1, 0, 0 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL c[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
	LL d[3][3];
	
	inc(i, m + 1) {
		if(i != 0) { mat_prod(c, b, c); }
		mat_exp(d, a, x[i + 1] - x[i] - 1);
		mat_prod(c, d, c);
	}
	
	cout << c[2][0] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
S=[0]*n
for i in range(k):
  d=int(input())
  A=list(map(int,input().split()))
  for j in range(d):
    S[A[j]-1]+=1
ans=0
for i in range(n):
  if S[i]==0:
    ans=ans+1
print(ans)

Measured memory_bytes: 67732
#include <stdio.h>

int main(void) {
	char str[11];						/*文字列変数*/	
	while(scanf("%s", str) != EOF) {
		int n[10], i, j;
		
		for(i = 0; i < 10; i++) {
			n[i] = str[i] - '0';
		}
		
		for(i = 9; i > 0; i--) {
			for(j = 0; j < i; j++) {
				n[j] = ( n[j] + n[j+1] ) % 10;
			}
		}
		
		printf("%d\n", n[0]);
	}
	
	return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
//#include "bits:stdc++.h"
#define INF 1234567890987654321
typedef long long ll;
using namespace std;
//set <char> s;
ll a, b, k, stop, arr[10001], size;
int main()
{
	//freopen("inputfile.cpp", "r", stdin);
	cin >> a >> b >> k;
if(b<a)swap(a,b);
	for(ll i = a; i < min(a+k, b+1); i++)
	{
		cout << i << '\n';
		stop = i;
	}
        size = 0;
	for(ll i = b; i > max(b-k, stop); i--)
	{
		arr[size++] = i;
	}
	sort(arr, arr+size);
	for(ll i = 0; i < size; i++)
	{
		cout << arr[i] << '\n';
	}
    //cout << arr[size-1];
}


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

int main() {
	string s; cin >> s;
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	cout << (((int)s.size() == 2) ? "Yes" : "No") << "\n";
	return 0;
}


Measured memory_bytes: 256
# count p<=x<=q and p<=y <=q
# 長方形に含まれる格子点の数
import numpy as np
N,M,Q = map(int,input().split())

cnt = np.zeros((N+1,N+1),dtype=np.int64)
for _ in range(M):
  x,y = map(int,input().split())
  cnt[x,y] += 1

cnt = cnt.cumsum(axis=0).cumsum(axis=1)

for _ in range(Q):
  p,q = map(int,input().split())
  p -= 1
  x = cnt[q,q]
  x -= cnt[q,p]
  x -= cnt[p,q]
  x += cnt[p,p]
  print(x)

Measured memory_bytes: 18352
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL MOD = 1000000007LL;
using namespace std;

int main() {
	int N;
	cin >> N;
	cout << N*(N + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>
int main(){
	int q;
	while(std::cin>>q,q!=-1){
		double x=q/2.0,a;
		while(1){
			a=x*x*x-q;
			if(fabs(a)<1e-5*q)break;
			x-=a/3/x/x;
		}
		printf("%.6f\n",x);
	}
}

Measured memory_bytes: 1192
#include<stdio.h>

int main(void)
{
	int i,j,temp;
	int mountain[10];
	int n=10;
	
	for(i=0;i<10;i++){
		scanf("%d",&mountain[i]);
	}
	
	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(mountain[j-1]>mountain[j]){
				temp=mountain[j];
				mountain[j]=mountain[j-1];
				mountain[j-1]=temp;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d\n",mountain[n-1-i]);
	}
	return 0;
}

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

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//
const ll mod = 1e9 + 7;
unordered_map<ll, ll> max_map;
ll prime[1000007];
void sieve() {
    prime[0] = prime[1] = 1;
    for (int i = 2; i < 1000007; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < 1000007; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    while (a % b) {
        ll r = a % b;
        a = b;
        b = r;
    }
    return b;
}
ll power(ll a, ll n) {
    if (n == 0)
        return 1;
    ll p = power(a, n / 2) % mod;
    p = (p * p) % mod;
    if (n & 1)
        p = (p * a) % mod;
    return p;
}
ll lcmModuloM(vl ar, ll n) {
    for (ll i = 0; i < n; i++) {
        ll num = ar[i];
        unordered_map<ll, ll> temp;

        // Temp stores mapping of prime factor to
        // its power for the current element
        while (num > 1) {
            // Factor is the smallest prime factor of num
            ll factor = prime[num];

            // Increase count of factor in temp
            temp[factor]++;

            // Reduce num by its prime factor
            num /= factor;
        }

        for (auto it : temp) {
            // Store the highest power of every prime
            // found till now in a new map max_map
            max_map[it.first] = max(max_map[it.first], it.second);
        }
    }

    ll ans = 1;

    for (auto it : max_map) {
        // LCM is product of primes to their highest powers modulo M
        ans = (ans * power(it.first, it.second)) % mod;
    }

    return ans;
}
int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];
    sieve();

    ll x = lcmModuloM(A, N);
    ll ans = 0;
    rep(i, N) ans = (ans + x * modpow(A[i], mod - 2, mod) % mod) % mod;
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const int N = 2e5;
const int mod = 2019;
int cnt[mod+10],Pow[N+100];
char str[N+100];

int main()
{
	cnt[0] = 1;
	Pow[0] = 1;
	for(int i=1;i<=N;i++){
		Pow[i] = (Pow[i-1]*10)%mod;
	}
	scanf("%s",str);
	int cur = 0;
	ll ans = 0;
	for(int sz=strlen(str),i=sz-1;i>=0;i--){
		int c = str[i]-'0';
		cur = (cur+(c*Pow[sz-1-i])%mod)%mod;
		ans += cnt[cur];
		cnt[cur]++;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 4660
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll n,k,cnt = 0;
    cin >> n >> k;
    while(n){
        cnt++;
        n /= k;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;
typedef long long ll;
const int mx=10000;
int a[mx];
int tree[mx*4];
//void init(int node, int b, int e)
//{
//    if (b == e) {
//        tree[node] = a[b];
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    init(Left, b, mid);
//    init(Right, mid + 1, e);
//    tree[node] = __gcd(tree[Left],tree[Right]);
//}
//int query(int node, int b, int e, int i, int j)
//{
//    if (i > e || j < b)
//        return 0;
//    if (b >= i && e <= j)
//        return tree[node];
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    int p1 = query(Left, b, mid, i, j);
//    int p2 = query(Right, mid + 1, e, i, j);
//    return __gcd(p1,p2);
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    update(Left, b, mid, i, newvalue);
//    update(Right, mid + 1, e, i, newvalue);
//    tree[node] = __gcd(tree[Left] , tree[Right]);
//}
map<ll,ll>ncr;
ll solve(ll n)
{
    if(ncr.count(n)==0){
        ncr[n]=(n*(n-1))/2;
    }
    return ncr[n];
}
int main()
{
    ll n;
    cin>>n;
    ll a[n+3];
    map<ll,ll>mp;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll sum=0;
    for(auto x: mp){
        sum+=solve(x.second);
    }
    for(int i=1;i<=n;i++){
        ll x=mp[a[i]];
        cout<<sum-solve(x)+solve(x-1)<<endl;
    }
}


Measured memory_bytes: 11008
import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed    (UArray)
import qualified Data.Array.Unboxed    as U
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.List

getAsInt :: IO [Int]
getAsInt =  unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getAsIntLine :: Int -> IO [[Int]]
getAsIntLine n = replicateM n getAsInt

getAsIntArray2D :: Int -> Int -> IO (UArray (Int,Int) Int)
getAsIntArray2D n m = U.listArray ((1,1),(n,m)) . concat <$> getAsIntLine n


main :: IO ()
main = do
  [n,w] <- getAsInt
  wvs <- getAsIntArray2D n 2
  let solve = solve1
      result = solve wvs n w
  print $ maximum $ map (\x -> result U.! (n,x)) [0..w]

solve1 :: UArray (Int,Int) Int -> Int -> Int -> UArray (Int,Int) Int
solve1 wvs n' w' = runSTUArray $ do
  dp <- newArray ((0,0),(n',w')) 0
  forM_ [(n_,w_) | n_ <- [1..n'], w_ <- [0..w']] $ \(n,w) -> do
    let wtmp = wvs U.! (n,1)
        vtmp = wvs U.! (n,2)
    if w - wtmp < 0
      then readArray dp (n-1,w) >>= writeArray dp (n,w)
      else do
        a <- readArray dp (n-1,w)
        b <- readArray dp (n-1,w-wtmp)
        writeArray dp (n,w) $ max a (b+vtmp)
  return dp


Measured memory_bytes: 89980
#include<bits/stdc++.h>
using namespace std;
double fx[37];
double fy[37];
double diff[39][39];
int main()
{
    long long int a,b,c,d;
    cin>>a>>b;
    c=a+b;
    if(c%2==0)
        cout<<c/2;
    else
    cout<<"IMPOSSIBLE";


}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int N, D, X; cin >> N >> D >> X;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int total = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j*A[i]+1 <= D; j++) {
      total++;
    }
  }

  cout << total+X << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool cut_word (string& str, char w )
{
	string s = str;

	if (s.find (w) != string::npos ){
		s = s.substr (0, s.find (w) );
	} // end while

	if (s != str ){
		str = s;
		return true;
	} // end if

	return false;
}


int main()
{
//	cut here before submit 
//	freopen("testcase.search2", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		string s = "";
		stringstream ss(str);
		string res = "";

		while (ss >> s ){
//			while (cut_word (s, '\'' ) ){
//				;
//			} // end while
			while (cut_word (s, ',' ) ) {
				;
			} // end while
			while (cut_word (s, '.' ) ) {
				;
			} // end while

			if (s.length() >= 3 && s.length() <= 6 ){
				res += s;
				res += ' ';
			} // end if
		} // end while
		res = res.substr (0, res.length() - 1);
		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
ll x,y,ans;
int main()
{
	scanf("%lld%lld",&x,&y);
	while(x<=y&&x>0) ans++,x<<=1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1e9+7;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

int main(){
    int N;
    cin>>N;
    vi X(N);
    F0R(i,N){
        cin>>X[i];
    }
    sort(X.begin(),X.end());
    int mini=INT_MAX;
    int ans=0;
    FOR(i,X[0],X[X.size()-1]+1){
        ans=0;
        F0R(j,N){
            ans+=((X[j]-i)*(X[j]-i));
        }
        mini=min(ans,mini);
    }
    cout<<mini<<endl;
    return 0;
}


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

const int MAXN = 1e5+5;

int ans[MAXN], a[MAXN], b[MAXN], ra, rb, n;
vector<int> ta[MAXN], tb[MAXN];
vector<int> g[MAXN];
bool vis[MAXN];

int dfs1(int v) {
    a[v] = 1;
    int z = -1;
    for (int u : ta[v]) {
        a[v] ^= 1;
        int zz = dfs1(u);
        if (z == -1)
            z = zz;
        else {
            g[z].push_back(zz);
            g[zz].push_back(z);
            z = -1;
        }
    }

    if (z == -1) {
        assert(a[v] == 1);
        return v;
    } else
        return z;
}

int dfs2(int v) {
    b[v] = 1;
    int z = -1;
    for (int u : tb[v]) {
        b[v] ^= 1;
        int zz = dfs2(u);
        if (z == -1)
            z = zz;
        else {
            g[z].push_back(zz);
            g[zz].push_back(z);
            z = -1;
        }
    }

    if (z == -1) {
        assert(b[v] == 1);
        return v;
    } else
        return z;
}

void dfs(int v) {
    if (vis[v])
        return;
    vis[v] = 1;

    for (int u : g[v]) {
        ans[u] = -ans[v];
        dfs(u);
    }
}

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

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        if (x == -1)
            ra = i;
        else
            ta[x-1].push_back(i);
    }

    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        if (x == -1)
            rb = i;
        else
            tb[x-1].push_back(i);
    }

    dfs1(ra);
    dfs2(rb);

    for (int i = 0; i < n; ++i)
        if (a[i] != b[i]) {
            cout << "IMPOSSIBLE\n";
            return 0;
        }

    cout << "POSSIBLE\n";
    for (int i = 0; i < n; ++i) {
        if (vis[i] || a[i] == 0)
            continue;
        ans[i] = 1;
        dfs(i);
    }

    for (int i = 0; i < n; ++i)
        cout << ans[i] << ' ';
    cout << endl;
}

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

#define MAX 100000
int num[MAX];

void add(int i, int x){
  num[i] += x;
}

void getSum(int s, int t){
  int sum=0;
  for(int i=s; i<=t; i++){
    sum += num[i];
  } cout << sum << endl;
}

int main(){
  int n, q;
  cin >> n >> q;
  int com[q], x[q], y[q];
  for(int i=1; i<=n; i++){ num[i] = 0; }

  for(int i=1; i<=q; i++){ cin >> com[i] >> x[i] >> y[i]; }

  for(int i=1; i<=q; i++){
    if(com[i]==0){ add(x[i], y[i]); }
    else if(com[i]==1){ getSum(x[i], y[i]); }
  }

  return 0;
}


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

#define lli long long int
#define mpr make_pair
#define pr pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

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

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res;
}

lli modInverse(lli n,lli  p)
{
	return power(n,p-2,p);
}

lli nCr(lli n,lli r,lli p)
{
	if(r==0)
	return 1;
	lli fac[n+1];
	fac[0]=1;
	for(lli i=1;i<=n;i++)
	fac[i]=fac[i-1]*i%p;
	return ((fac[n]* modInverse(fac[r], p) % p )%p* 
            modInverse(fac[n-r], p) % p) % p; 
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	lli n;
	cin>>n;
	n=n%1000;
	cout<<(1000-n)%1000<<endl;
	
	
return 0;
}


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

int main(){
  string s;
  cin>>s;
  ll num=s.size();
  if(num==26){
    for(int i=num-1;i>=0;i--){
      if(!i){
        cout<<-1<<endl;
        return 0;
      }
      if(s[i]>s[i-1]){
        num=i;
        break;
      }
    }
    for(char c=s[num-1]+1;c<='z';c++){
      bool f=1;
      for(int i=0;i<num;i++)if(s[i]==c)f=0;
      if(f){
        for(int i=0;i<num-1;i++)cout<<s[i];
        cout<<c<<endl;
        return 0;
      }
  }
}
  for(char c='a';c<='z';c++){
    bool f=1;
    for(int i=0;i<num;i++)if(s[i]==c)f=0;
    if(f){
      for(int i=0;i<num;i++)cout<<s[i];
      cout<<c<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		RankManager manager = new RankManager();
		
		while(true){
			String[] tmparray = br.readLine().split(",");
			int id = Integer.parseInt(tmparray[0]);
			int score = Integer.parseInt(tmparray[1]);
			
			if(id == 0 && score == 0){
				break;
			}
			
			manager.addTeam(id, score);
		}
		
		manager.decideRank();
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			System.out.println(manager.getRank(Integer.parseInt(str)));
		}
	}

}

class RankManager {
	ArrayList<Team> teams = new ArrayList<Team>();

	public void addTeam(int id, int score){
		teams.add(new Team(id, score));
	}

	private void sort(){
		Collections.sort(teams, new Comparator<Team>(){
			public int compare(Team t1, Team t2){
				if(t1.score < t2.score){
					return 1;
				}
				else if(t1.score > t2.score){
					return -1;
				}
				else{
					return 0;
				}
			}
		});
	}

	public void decideRank(){
		this.sort();

		int rank = 1;
		teams.get(0).rank = 1;
		int currentScore = teams.get(0).score;
		for(int i = 1; i < teams.size() ; i++){
			if(teams.get(i).score != currentScore){
				rank++;
				teams.get(i).rank = rank;
				currentScore = teams.get(i).score;
			}
			else {
				teams.get(i).rank = rank;
			}
		}
	}

	public int getRank(int id){
		for(int i = 0 ; i < teams.size(); i++){
			if(teams.get(i).ID == id){
				return teams.get(i).rank;
			}
		}
		
		return -1;
	}
}

class Team {
	int ID;
	int score;
	int rank;

	public Team(int ID, int score){
		this.ID = ID;
		this.score = score;
	}
}

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

string s;
map<char,int> m;
int cnt=0;
int main() 
{ 

	ios::sync_with_stdio(false);
    cin.tie(NULL);
    bool flag = false;
    cin>>s;
    rep(i,0,s.length()-1)
    {
    	m[s[i]]+=1;
    	if(isupper(s[i]))
    		cnt++;
    }
    if(cnt==2)
	    {
	    if(s.front()=='A')
	    {
	    	if(m['C']!=1)
	    	{
	    		cout<<"WA";
	    	}
	    	else
	    	{
	    		rep(i,2,s.length()-2)
	    		{
	    			if(s[i]=='C')
	    				flag=true;
	    		}
	    		if(flag)
	    			cout<<"AC";
	    		else
	    			cout<<"WA";
	    	}
	    }
	    else
	    	cout<<"WA";
	}
	else
		cout<<"WA";

} 


Measured memory_bytes: 3628