akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

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

  int N;
  cin >> N;
  priority_queue<int> a , cur;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    a.push(x);
  }

  int x = a.top();
  a.pop();
  int y = a.top();
  a.pop();
  map<int, int> L , R;
  L[y] = x , R[y] = x;
  int ans = x;
  cur.push(y);
  while(!a.empty()) {
    int T = cur.top();
    cur.pop();
    if(a.size() >= 2) {
      int p1 = a.top(); a.pop();
      int p2 = a.top(); a.pop();
      ans += 2 * T ;
      L[p1] = L[T];
      R[p1] = T;
      L[p2] = T;
      R[p2] = R[T];
      cur.push(p1);
      cur.push(p2);
    }
    else {
      ans += T;
      break;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 30224
mod = 998244353

n, m, k = map(int, input().split())

frac = [0] * (n + 1)
frac[0] = frac[1] = 1

for i in range(1, n):
    frac[i + 1] = frac[i] * (i + 1)
    frac[i + 1] %= mod

inv_frac = [0] * (n + 1)
inv_frac[n] = pow(frac[n], mod - 2, mod)

for i in range(n - 1, -1, -1):
    inv_frac[i] = (i + 1) * inv_frac[i + 1]
    inv_frac[i] %= mod

ans = 0

for i in range(k + 1):
    ans += m * pow(m - 1, n - 1 - i,
                   mod) * frac[n - 1] * inv_frac[i] * inv_frac[n - 1 - i]
    ans %= mod

print(ans)

Measured memory_bytes: 74004
## C - Next Prime　https://atcoder.jp/contests/abc149/tasks/abc149_c>
Number=int(input())
flg =0

if Number ==2: #2だったらflg＝1にして終了したい
    flg=1
    print(Number)
elif Number%2==0:
    Number+=1

Odd_Number_List =[i for i in range(3,Number,2)]

while flg==0:
    Amari_List = list(map(lambda x:Number%x,Odd_Number_List))
    if Amari_List.count(0)==0:
        flg=1
        print(Number)
        
    else:
        Odd_Number_List.append(Number)
        Number+=2
    



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

int main(){
  long long A,B;
  cin >> A >> B;
  for(long long i=1;i<=1000;i++){
    if(i*8/100==A && i*10/100==B){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/numeric>
/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/
using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\out.txt", "w", stdout) ;
    int a, b; cin>>a>>b;
    cout<<a*b;
	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int t,d,l;
  
  scanf("%d%d%d",&t,&d,&l);

  if(t == 0) return false;

  int ans = 0;
  int sec = 0;
  
  for(int i=0;i<t;i++){
    int x;

    scanf("%d",&x);

    if(t-1 == i) continue;
    
    sec--;
    if(x >= l){
      sec = d;
    }

    if(sec > 0) ans++;
  }

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

  return true;
}

int main(){
  while(solve());
  
  return 0;
}

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

int main (){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<d+1){
        cout<<"Yes"<<endl;
    }
    else if(abs(a-b)<d+1&&abs(b-c)<d+1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (unless)

import Data.List (sort, sortBy, group)
import Data.Function (on)

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve <$> map read <$> words <$> getLine >>= print
    main

solve :: [Int] -> Int
solve xs = f xs
  where l5 = take 5 xs
        d = head $ head $ sortBy g $ group $ sort $ zipWith (-) (tail l5) l5
        g us vs | length us == length vs = compare (head vs) (head us)
                | otherwise = compare (length vs) (length us)
        f (x:y:z:zs) | y - x == d && z - y == d = f (y:z:zs)
                     | y - x == d = z
                     | z - y == d = x
                     | otherwise = y



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

using namespace std;

typedef vector<int> vec;

class Seg
{
public:
    int n;
    vec data;
    vec lazy;
    const int INF=1e9+10;

    Seg(int _n)
    {
        data.resize(4*_n);
        lazy.resize(4*_n);
        for(n=1;n<_n;n<<=1);
    }

    void Down(int p,int l,int r)
    {
        data[p]+=lazy[p];
        if(l+1<r)
        {
            lazy[p*2+1]+=lazy[p];
            lazy[p*2+2]+=lazy[p];
        }
        lazy[p]=0;
    }

    int add(int p,int l,int r,int x,int a,int b)
    {
        if(a>=r||b<=l) return data[p]+lazy[p];
        else if(a<=l&&r<=b)
        {
            lazy[p]+=x;
            return data[p]+lazy[p];
        }else
        {
            Down(p,l,r);
            int mid=(l+r)/2;
            return data[p]=min(add(p*2+1,l,mid,x,a,b),add(p*2+2,mid,r,x,a,b));
        }
    }

    int query(int p,int l,int r,int a,int b)
    {
        if(a>=r||b<=l) return INF;
        else if(a<=l&&r<=b)
        {
            return data[p]+lazy[p];
        }else
        {
            Down(p,l,r);
            int mid=(l+r)/2;
            return min(query(p*2+1,l,mid,a,b),query(p*2+2,mid,r,a,b));
        }
    }
};

int main()
{
    int n,q;

    while(scanf("%d %d",&n,&q)!=EOF)
    {
        Seg seg(n);
        while(q--)
        {
            int op,a,b,c;
            scanf("%d",&op);

            if(op)
            {
                scanf("%d %d",&a,&b);
                printf("%d\n",seg.query(0,0,seg.n,a,b+1));
            }else
            {
                scanf("%d %d %d",&a,&b,&c);
                seg.add(0,0,seg.n,c,a,b+1);
            }
        }
    }

    return 0;
}



Measured memory_bytes: 6008
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    string s1=s,s2=s,s3=s;
    s1=s1.erase((n-1)/2);
    s2=s2.substr((n+1)/2);
    string s4=s1,s5=s2;
    reverse(s3.begin(), s3.end());
    reverse(s4.begin(), s4.end());
    reverse(s5.begin(), s5.end());
    if(s==s3&&s1==s4&&s2==s5){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
	int r, g, b, n, cnt;
	cnt = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (((n - i*r - g*j) % b == 0) and (n - i*r - g*j >= 0)) cnt += 1;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)    cin>>a.at(i);

    int ans=true;
    rep(i,n) {
        if(a[i]%2==0) {
            if(a[i]%3==0||a[i]%5==0) ;
            else ans=false;
        }
    }

    if(ans) cout<<"APPROVED"<<endl;
    else    cout<<"DENIED"<<endl;
 
 return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

ok = True
for i in range(N-1,0,-1):
  l = H[i-1]
  r = H[i]
  
  if l <= r:
    continue
  else:
    l -= 1
    if l <= r:
      H[i-1] -= 1
      continue
    else:
      ok = False
      break

  
if ok:
  print('Yes')
else:
  print('No')


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

int main() {
	string s;
	int k;
	cin >> k >> s;
	int len = s.size();
	int lim = min(len, k);
	for (int i = 0; i < lim; i++) {
		cout << s[i];
	}
	if (len > k)
		cout << "...";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[][] dp, field;
	static int H, W;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		H = sc.nextInt(); W = sc.nextInt();
		dp = new int[H][W]; field = new int[H][W];
		for(int i = 0; i < H; i++){
			String line = sc.next();
			for(int j = 0; j < W; j++){
				field[i][j] = line.charAt(j) - '0';
			}
		}
		return true;
	}
	static void solve(){
		dp[0][0] = 0;
		for(int i = 1; i < H; i++){
			dp[i][0] = field[i][0] + dp[ i - 1 ][0];
		}
		for(int j = 1; j < W; j++){
			dp[0][j] = field[0][j] + dp[0][ j - 1 ];
		}
		for(int i = 1; i < H; i++){
			for(int j = 1; j < W; j++){
				dp[i][j] = field[i][j] + Math.min(dp[i - 1][j], dp[i][j - 1]);
			}
		}
		System.out.println(dp[H-1][W-1]);
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

int N,M;
string a[5000];
int x[5000];
int p[5000];
map<string,int> change;

int find(int x){
  if(x==p[x])return x;
  else return p[x]=find(p[x]);  
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++)cin>>a[i]>>x[i],p[i]=i,change[a[i]]=i;
  cin>>M;
  string S,T;
  for(int i=0;i<M;i++){
    cin>>S>>T;
    int s=find(change[S]);
    int t=find(change[T]);
    x[s]=min(x[s],x[t]);
    p[t]=s;
  }
  int ans=0;
  for(int i=0;i<N;i++)ans+=x[find(i)];
  cout<<ans<<endl;
  return 0;
}

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

signed main() {
  ll n, m; std::cin >> n >> m;
  if (n % 2 == 1) {
    for (int i = 0; i < m; i++) std::cout << i+1 << " " << n-i << std::endl;
  } else {
    std::vector<int> res(m);
    for (int i = 0; i < (m+1)/2; i++) res[i] = n-i;
    for (int i = (m+1)/2; i < m; i++) res[i] = n-i-1;
    for (int i = 0; i < m; i++) std::cout << i+1 << " " << res[i] << std::endl;
  }
}


Measured memory_bytes: 3632
import collections
N = int(input())
A = sorted([int(i) for i in input().split()])
maxA = A[-1]

if N == 1:
    print(1)
    exit()

C = collections.Counter(A)
cand = set(A)

ans = 0
for i in range(N):
    if C[A[i]] >= 2:
        cand -= set([A[i]*j for j in range(1, maxA//A[i]+1)])
        continue

    if A[i] in cand:
        ans += 1
        cand -= set([A[i]*j for j in range(1, maxA//A[i]+1)])
print(ans)


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

int main(){
    long long n;
    char alpha[27] = "abcdefghijklmnopqrstuvwxyz";
    cin >> n;
    vector<char> ans;
    bool f = true;
    while(n > 0){
        n--;
        long long j = n % 26;
        n /= 26;
        ans.emplace_back(alpha[j]);
    }
    reverse(ans.begin(), ans.end());
    for(auto a : ans) cout << a;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int N = 0;
vector<int> vec;
 
int tree(int A1[], int A2[], int index1, int index2, int cnt){
    if(index1==N-1 && index2==1){
        vec.push_back(cnt);
        return 0;
    }
    if(index1<N-1 && index2==0) tree(A1, A2, index1+1, index2, cnt+A1[index1+1]);
    if(index1<N-1 && index2==1) tree(A1, A2, index1+1, index2, cnt+A2[index1+1]);
    if(index2 == 0 ) tree(A1, A2, index1, index2+1, cnt+A2[index1]);

    return 0;
}


int main(){
    int n;
    cin>>n;
    N = n;
    int A1[n], A2[n];
    rep(i, n) cin >> A1[i];
    rep(i, n) cin >> A2[i];
    tree(A1, A2, 0, 0, A1[0]);
    int ma = 0;
    rep(i, vec.size())
        ma = max(vec[i], ma);
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 256
using System.Linq;

namespace ABC
{
    using static System.Console;
    using static System.Math;
    public class Program
    {
        private const int MOD = 1000000007;
        static void Main(string[] args)
        {
            WriteLine(Solve());
        }

        public static string Solve()
        {
            return ReadLine().Split().Select(int.Parse).ToArray().OrderBy(x => x).Take(2).Sum().ToString();
        }
    }
}


Measured memory_bytes: 13396
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let a: Vec<u64> = (0..5).map(|_| read()).collect();
    let (i, _) = (&a).into_iter().enumerate().find(|(_, c)| **c == 0).unwrap();
    println!("{}", i + 1);
}


Measured memory_bytes: 2040
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int a[5005];int n,k;
bitset<5005>s;
bool c(int mid){
    s=0;s[0]=1;
    rep(i,0,n){
        if(i==mid)continue;
        else s|=(s<<a[i]);
    }
    if(a[mid]>k)return 1;
    rep(i,k-a[mid],k){
        if(s[i])return 1;
    }
    return 0;
}
signed main(){
    cin>>n>>k;
    rep(i,0,n)cin>>a[i];
    int l=0,r=n;
    sort(a,a+n);
    rep(i,0,32){
        bool h=0;
        int mid=(l+r)/2;
        if(l==mid)h=1;
        if(c(mid))r=mid;
        else l=mid;
        if(h)break;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

n,m=map(int,input().split())
s=[]
for _ in range(m):
    k,*si=map(lambda x:int(x)-1,input().split())
    s.append(si)
p=list(map(int,input().split()))

ans=0
for bit in itertools.product((0,1),repeat=n):
    for i in range(m):
        count = sum(bit[id] for id in s[i])
        if count%2!=p[i]:
            break
    else:
        ans+=1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <sstream>
#include<ctime>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define mii map<int,int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rep(i,l,r) for(int i=l;i<r;i++) 
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mod 998244353 
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 0x3f3f3f3f
ll MOD(ll a, ll b)
{
    if(a>b)
    return a-b;
    else
    return b-a;
}
ll power(ll x,ll y, ll p)
{
    ll res = 1;      
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%p;
        y = y>>1; 
        x = (x*x)%p;  
    }
    return res;
}
ll logg(ll a)
{
    ll x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
 
}
int main()
{
    fastio;
    int n;
    cin>>n;
    vi A(n);
    rep(i,0,n)
        cin>>A[i];
    sort(all(A));
    ll sum=0;
    rep(i,0,n)
    {
        rep(j,i+1,n)
        {
            int a=A[i]+A[j];
            int t=lower_bound(A.begin()+j+1,A.end(),a)-A.begin()-j-1;
            sum+=t;
        }
    }
    cout<<sum;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      h: usize,
      w: usize,
    }

    println!("{}", (n-h+1)*(n-w+1));
}


Measured memory_bytes: 4352
using System;

namespace AOJ.ITP
{
    public class StructuredProgramming
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            string output = "";
            // 3の倍数または"3"が含まれる数字を出力
            for (int i = 1; i <= n; i++)
            {
                if (i % 3 == 0) { output += " " + i; }
                else
                {
                    string tmp = i.ToString();
                    if (tmp.IndexOf("3") >= 0) { output += " " + i; }
                }
            }

            Console.WriteLine(output);
        }
    }
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

struct Edge{
  int to, cap, cost, rev;
  Edge(int to_=0, int cap_ = 0, int cost_ = 0, int rev_ = 0)
	:to(to_), cap(cap_), cost(cost_), rev(rev_){}
};

const int MAX_V = 400;
int V = MAX_V;
vector<Edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V]; //??´??????????????¨???

void add_edge(int from, int to, int cap, int cost){
  G[from].push_back(Edge(to, cap, cost, G[to].size()));
  G[to].push_back(Edge(from, 0, -cost, G[from].size()-1));
}
int min_cost_flow(int s, int t, int f){
  int res = 0;
  while(f > 0){
	fill(dist, dist+V, INF);
	dist[s] = 0;
	bool update = true;
	while(update){
	  update = false;
	  for(int v=0;v<V;++v){
		if(dist[v] == INF) continue;
		for(int i=0;i<G[v].size();++i){
		  Edge& e = G[v][i];
		  if(e.cap > 0 && dist[v] + e.cost < dist[e.to]){
			dist[e.to] = dist[v] + e.cost;
			prevv[e.to] = v;
			preve[e.to] = i;
			update = true;
		  }
		}
	  }
	}

	if(dist[t] == INF) return -1;

	int d = f;
	for(int v=t;v!=s;v=prevv[v])
	  d = min(d, G[prevv[v]][preve[v]].cap);

	f -= d;
	res += d * dist[t];
	for(int v=t;v!=s;v=prevv[v]){
	  Edge& e = G[prevv[v]][preve[v]];
	  e.cap -= d;
	  G[v][e.rev].cap += d;
	}
  }
  
  return res;
}

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

  int N, M, K;
  cin >> N >> M >> K;

  int A = N + M + 1;
  int S = A + 1;
  int T = S + 1;
  int TT = T + 1;
  REP(i,N){
	int a; cin >> a;
	add_edge(i, A, 1, -a);
  }
  REP(j,M){
	REP(i,N){
	  int b; cin >> b;
	  add_edge(i, N+j, 1, -b);
	}
  }
  REP(j,M){
	int t; cin >> t;
	add_edge(N+j, T, t, 0);
  }
  add_edge(T, TT, N-K, 0);
  add_edge(A, TT, N, 0);
  REP(i,N)
	add_edge(S, i, 1, 0);

  cout << -min_cost_flow(S, TT, N) << endl;
  
  return 0;
}

Measured memory_bytes: 3468
#include <cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int t,a,b,c,x,y,ans=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    if(x<y) {t=x;x=y;y=t;t=a;a=b;b=t;}
    if(c*2<a+b)
    {ans+=y*2*c;
        x=x-y;y=0;
        if(2*c<a) ans+=x*2*c;
        else ans+=x*a;
    }
    else {
        ans+=a*x+b*y;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.TreeSet;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next(), T = sc.next();
		TreeSet<String> ans = new TreeSet<String>();

		for(int i = 0; i + T.length() <= S.length(); i++) {
			// (i, i + T) をかんがえる
			boolean CANMAKE = true;  // kawaii ha tsukureru
			for(int j = 0; j < T.length(); j++) {
				if(S.charAt(i + j) != '?' && S.charAt(i + j) != T.charAt(j)) CANMAKE = false;
			}
			if(CANMAKE) {
				String str = "";
				for(int k = 0; k < S.length(); k++) {
					if(i <= k && k <= i + T.length() - 1) {
						str += T.charAt(k - i);
					}else {
						str += (S.charAt(k) == '?') ? "a" : S.charAt(k);
					}
				}
				ans.add(str);
			}
		}
		if(ans.isEmpty() || (S.length() < T.length())) System.out.println("UNRESTORABLE");
		else System.out.println(ans.pollFirst());
	}
}


Measured memory_bytes: 23892
import java.io.*;
import java.util.*;

 
public class Main{
	class Pair{
		int idx;
		int cnt;
		public Pair(int idx, int cnt){
			this.idx = idx;
			this.cnt = cnt;
		}
	}
	public void solve(){
		int N = nextInt();
		int K = nextInt();
		int[] P = new int[26];
		for(int i = 0; i < N; i++){
			String str = next();
			P[str.charAt(0) - 'A']++;
		}
		PriorityQueue<Pair> queue = new PriorityQueue<>((a, b) -> Integer.compare(b.cnt, a.cnt));
		for(int i = 0; i < 26; i++){
			if(P[i] != 0){
				queue.add(new Pair(i, P[i]));
			}
		}
		Pair[] tmp = new Pair[K];
		int ans = 0;
		LOOP:
		while(true){
			for(int i = 0; i < K; i++){
				if(queue.isEmpty()) break LOOP;
				tmp[i] = queue.poll();
			}
			ans++;
			for(int i = 0; i < K; i++){
				tmp[i].cnt--;
				if(tmp[i].cnt > 0) queue.add(tmp[i]);
			}
		}
		out.println(ans);
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

int main (){
	int i, n;
	double xa, ya, ra, xb, yb, rb, rd;
	scanf ("%d", &n);
	for (i=0; i<n; i++){
		scanf ("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb, &rb);
		rd = hypot (xa-xb, ya-yb);
		if (rd <= ra + rb){
			if (rd+rb < ra) {printf ("%s\n", "2"); continue;}
			if (rd+ra < rb) {printf ("%s\n", "-2"); continue;}
			printf ("%s\n", "1");
		} else {
			printf ("%s\n", "0");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;

typedef long long ll;

#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

ll H,W,A,B;

ll f[200001];

ll pow(ll a, ll b, ll MOD)
{
    ll x=1,y=a; 
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD; 
        b /= 2;
    }
    return x;
}
ll InverseEuler(ll n, ll MOD)
{
    return pow(n,MOD-2,MOD);
}

ll C(ll n, ll r, ll MOD)
{
    if (n==0) return 1;
    if (r==0) return 1;
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int RED = 1000000007;
 
int main(int argc, char * argv[])
{
    ios::sync_with_stdio(false);
    cin >> H >> W >> A >> B;
    ll sm = 0;
    f[0] = 1;
    for(int i = 1 ; i <= 200000 ; i++)
        f[i] = (f[i-1]*i)%RED;

    rep(i,H-A){
        sm += (C(B+i-1, B-1, RED) % RED)* (C(W-B-1+H-i-1,W-B-1,RED) % RED) % RED; 
        sm %= RED;
    }

    cout << sm << endl;





    

    return 0;
}



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

int main() {
  string s; 
  cin >> s;
  int n=s.size();
  vector<int>ans(n+1);
  ans.at(0)=0;
  ans.at(1)=1;
  rep2(i,1,n){
    if(s.at(i)==s.at(i-1)){
      if(i>1){
        ans.at(i+1)=max(ans.at(i-1)+1,ans.at(i-2)+2);
      }
      else{
        ans.at(i+1)=ans.at(i-1)+1;
      }
    }
    else{
      ans.at(i+1)=max(ans.at(i)+1,ans.at(i-1)+1);
    }
  }
  
  cout<<ans.at(n)<<endl;
}

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

using namespace std;

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

    if(abs(a - c) <= d){
        cout << "Yes" << endl;
    }else if(abs(a - b) <= d & abs(b - c) <= d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cctype>
#include<utility>

using namespace std;
int main()
{
    int n,k,i,c1,a,b;
    scanf("%d %d",&n,&k);
    int  p[n],m=n;
    for(i=0; i<n; i++)
    {
        scanf("%d",&p[i]);
        if(m>p[i])
        {
            m=p[i];
            a=i;
        }
    }
    if(k>=n)
        printf("1\n");
    else
    {
        c1=a/(k-1);
        b=c1*(k-1);
        c1+=(n-1-b)/(k-1);
        if((n-1-b)%(k-1))
            c1++;
        printf("%d\n",c1);
    }
    return 0;
}


Measured memory_bytes: 640
from sys import stdin
import math

a, b, m = [int(x) for x in stdin.readline().rstrip().split()]
aa = [int(x) for x in stdin.readline().rstrip().split()]
bb = [int(x) for x in stdin.readline().rstrip().split()]

result = min(aa) + min(bb)

for i in range(m):
    x, y, c = [int(x) for x in stdin.readline().rstrip().split()]
    temp = aa[x-1] + bb[y-1] - c
    if temp < result:
        result = temp

print(result)



Measured memory_bytes: 18200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MX = 1000005;
const int MOD = 998244353;
int n, pr[MX/5], p, a, b, c, e;
ll coe[MX], ac[MX], d[245], x, y, ans;
bool isnp[MX] = {1,1};
void exgcd(ll a, ll b, ll &x, ll &y){
	if(b){
		exgcd(b, a%b, y, x);
		y -= a/b*x;
	}else{
		x = 1; y = 0;
	}
}
int main(){
	for(int i = 1; i < MX; i++){
		exgcd(i,MOD,x,y);
		(coe[i] += x) %= MOD;
		if(!isnp[i]) pr[p++] = i;
		for(int j = i*2; j < MX; j += i){
			(coe[j] += MOD - coe[i]) %= MOD;
			if(!isnp[i]) isnp[j] = true;
		}
	}
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		d[0] = a; c = 1;
		for(int j=0; (ll)pr[j]*pr[j]<=a; j++) for(b=0; !(a%pr[j]); a/=pr[j])
			for(e = c; b < e; d[c++] = d[b++] / pr[j]);
		if(a != 1) for(b = 0,e = c; b < e; d[c++] = d[b++] / a);
		for(int j=0; j<c; j++){
			(ans += ac[d[j]] * coe[d[j]] % MOD * d[0] % MOD) %= MOD;
			(ac[d[j]] += d[0]) %= MOD;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 17152
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string A, B;
	cin >> A >> B;
	string C = A + B;
	istringstream c;
	c = istringstream(C);
	int N;
	c >> N;
	double n = N;
	if (sqrt(n) == int(sqrt(N))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc062/tasks/abc062_b

import itertools
import collections
import bisect

def main():
    H, W = map(int, input().split())
    lines = [input() for _ in range(H)]
    sharp = '#' * (W + 2)

    print(sharp)
    for line in lines:
        print('#{}#'.format(line))

    print(sharp)

if __name__ == '__main__':
    main()


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e5 + 3;

map<ll,ll> freq;
ll v[T];
ll n,MOD;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> MOD;

    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        v[i] = (v[i] + v[i-1]) % MOD;
        freq[v[i]]++;
    }

    freq[0]++;
    ll ans = 0;

    for(int i = 1; i <= n; i++) {
        freq[v[i-1]]--;
        ans += (ll)freq[v[i-1]];
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b=1;
signed main()
{
	cin>>a>>b;
	if(a*b==15){
		cout<<'*';
	}elif(a+b==15){
		cout<<'+';
	}else{
		cout<<'x';
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int A,B; cin >> A >> B;
    if(A+B<10) cout << A+B << endl;
    else cout << "error" << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <cstdio>
#include <algorithm>
using namespace std;
int H, W, cost[309][309], dp[309][309]; char s[309][309];
int main() {
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++) scanf("%s", s[i]);
	int ret = 0;
	for (int i = 1; i < W; i++) {
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < H; k++) {
				cost[j + 1][k + 1] = cost[j][k] + (s[j][i - 1] == s[k][i] ? 1 : 0);
			}
		}
		for (int j = 0; j <= H; j++) {
			for (int k = 0; k <= H; k++) {
				dp[j][k] = (j ? dp[j - 1][k] + cost[j][k] : (k ? 1012345678 : 0));
				if (k) dp[j][k] = min(dp[j][k], dp[j][k - 1] + cost[j][k]);
			}
		}
		ret += dp[H][H];
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 1152
import std;

bool calc(int k, int a, int b) {
    // return a <= b / k * k;

    return (a + k - 1) / k * k <= b;
}

void main() {
    int k; scan(k);
    int a, b; scan(a, b);
    writeln(calc(k, a, b) ? "OK" : "NG");
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 3680
#include <stdio.h>

#define MAXN 1001
int Stick[MAXN];


int main()
{
#ifdef _WIN32
	freopen("input.txt", "r", stdin);
#endif
	
	int N;
	scanf("%d", &N);

	for (int n = 0; n < N; n++)
		scanf("%d", &Stick[n]);

	for(int i = 0; i < N; i++)
		for(int j = i; j < N; j++)
			if (Stick[i] > Stick[j])
			{
				int Temp = Stick[i];
				Stick[i] = Stick[j];
				Stick[j] = Temp;
			}

	int Result = 0;
	for (int x = 0; x < N; x++)
		for (int y = x + 1; y < N; y++)
			for (int z = y + 1; z < N; z++)
					if (Stick[x] + Stick[y] > Stick[z])
							Result++;

	printf("%d", Result);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  set<string> st;
  char last = '1';
  bool ans = true;
  REP(i,n){
    string tmp;
    cin >> tmp;
    if(st.find(tmp)!=st.end()) ans = false;
    if(last!=tmp.front()&&i!=0) ans = false;
    st.insert(tmp);
    last = tmp.back();
  }
  cout << (ans?"Yes":"No") << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int		main(void)
{
	int a, b, c;

	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b))
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>
#include<list>
#include<cstdio>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)


using namespace std;

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




const int INF = 1e9 + 7;


/******************************************************************************************/


vector<int> G[30];
int in[30];

void preParse(int now) {

	if (now == -1) {
		return;
	}
	
	cout << " " << now;
	
	preParse(G[now][0]);
	preParse(G[now][1]);
}


void inParse(int now) {

	if (now == -1) {
		return;
	}

	inParse(G[now][0]);

	cout << " " << now;

	inParse(G[now][1]);
}


void postParse(int now) {

	if (now == -1) {
		return;
	}

	postParse(G[now][0]);
	postParse(G[now][1]);
	cout << " " << now;
}



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		G[a].push_back(b);
		G[a].push_back(c);

		if (b != -1) {
			in[b]++;
		}
		if (c != -1) {
			in[c]++;
		}
	}


	//root探し
	int root = 0;
	for (int i = 0; i < n; i++)
	{
		if (in[i] == 0) {
			root = i;
			break;
		}
	}

	cout << "Preorder" << endl;
	preParse(root);
	cout << endl;

	cout << "Inorder" << endl;
	inParse(root);
	cout << endl;

	cout << "Postorder" << endl;
	postParse(root);
	cout << endl;



	
	return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a,b;
	cin>>a>>b;
	cout<<a*b;
	
	return 0;
}

Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int k = sc.nextInt();

            int[][] dp = new int[k][10];
            for (int[] v : dp) Arrays.fill(v, Integer.MAX_VALUE);
            dp[1][1] = 1;

            TreeSet<int[]> set = new TreeSet<>((o1, o2) -> {
                int ret = dp[o1[0]][o1[1]] - dp[o2[0]][o2[1]];
                if (ret == 0) {
                    return o1[0] == o2[0] ? o1[1] - o2[1] : o1[0] - o2[0];
                } else {
                    return ret;
                }
            });
            set.add(new int[]{1, 1});
            while (set.size() > 0) {
                int[] v = set.pollFirst();
                if (v[1] + 1 < 10) {
                    int[] u = {(v[0] + 1) % k, v[1] + 1};
                    if (dp[v[0]][v[1]] + 1 < dp[u[0]][u[1]]) {
                        set.remove(u);
                        dp[u[0]][u[1]] = dp[v[0]][v[1]] + 1;
                        set.add(u);
                    }
                }
                int[] u = {(v[0] * 10) % k, 0};
                if (dp[v[0]][v[1]] < dp[u[0]][u[1]]) {
                    set.remove(u);
                    dp[u[0]][u[1]] = dp[v[0]][v[1]];
                    set.add(u);
                }
            }
            int ret = Integer.MAX_VALUE;
            for (int i = 0; i < 10; i ++) {
                ret = Math.min(ret, dp[0][i]);
            }
            System.out.println(ret);
        }
    }
}



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

using namespace std;

signed main(){

  const int MAX = 100;
  
  int A, B;
  int w, h;
  vector<vector<char> > ans(MAX+1, vector<char>(MAX+1));

  cin>>B>>A;

  A--, B--;
  
  for(int i = 0; i < MAX; i++){
    for(int j = 0; j < MAX; j++){
      if(j*2 < MAX) ans[i][j] = '#';
      else ans[i][j] = '.';
    }
  }
  
  for(int i = 0; i < MAX; i++){
    ans[0][i] = '#';
    ans[MAX-1][i] = '.';
  }

  cout<<MAX<<" "<<MAX<<endl;

  for(int i = 0; i < MAX; i+=2){
    
    for(int j = MAX-2; j >= 0; j-=2){
      
      if(A <= 0) break;
      if(j-1>=0)ans[j-1][i] = '.';
      if(j-1>=0)ans[j-1][i+1] = '.';
      ans[j][i+1] = '.';
      A--;
    }
    if(A <= 0) break;
  }

  for(int i = MAX-1; i >= 0; i-=2){
    for(int j = 1; j < MAX; j+=2){
      
      if(B <= 0) break;
      ans[j+1][i] = '#';
      ans[j+1][i-1] = '#';
      ans[j][i-1] = '#';
      B--;
    }
    if(B <= 0) break;
  }
  
  for(int i = 0; i < MAX; i++){
    for(int j = 0; j < MAX; j++){
      cout<<ans[i][j];
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
str_list = input().rstrip().split(' ')
num_list = input().rstrip().split(' ')
output = input().rstrip().split(' ')[0]
target_index = str_list.index(output)
num_list[target_index] = int(num_list[target_index]) - 1

out_str = ''
for i, num in enumerate(num_list):
  out_str += str(num)
  if i != len(num_list) - 1:
    out_str += ' '
print(out_str)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,cnt,a[N],f[N];
char ch[N];
int calc(int n,int l,int r){
	f[0]=1;
	int s=0;
	for (int i=1;i<=n;i++){
		if (i>=l) s=(s+f[i-l])%p;
		f[i]=s;
		if (i>=r) s=(s-f[i-r]+p)%p;
	}
	int ans=0;
	for (int i=l;i<=r;i++)
		ans=(ans+(ll)f[n-i]*i)%p;
	return ans;
}
int main(){
	n=read();m=read();
	scanf(" %s",ch+1);
	cnt=0;
	for (int i=1;i<=m;i++)
	if (ch[i]==ch[1]) a[cnt]++;
	else cnt++;
	if (cnt==0) printf("%d\n",(calc(n,2,n)+1)%p);
	else if (n&1) puts("0");
	else{
		int r=a[0]+1-(a[0]&1);
		for (int i=1;i<cnt;i++)
		if (a[i]%2==1) r=min(r,a[i]);
		printf("%d\n",calc(n/2,1,(r+1)/2)*2%p);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N, 0);
    for(int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++) {
            int a;
            cin >> a;
            a--;
            x[a]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++) ans += x[i] == 0;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3604
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

sumA = sum(As)

for i, B in enumerate(Bs):
    d = min(As[i], B)
    As[i] -= d
    B -= d
    d = min(As[i+1], B)
    As[i+1] -= d
    B -= d

print(sumA - sum(As))


Measured memory_bytes: 19116