akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,Q;
  string S;
  cin>>N>>Q>>S;
  vector<pair<char,char>> A(Q);
  for(pair<char,char> &p:A)cin>>p.first>>p.second;
  int ok=-1,ng=N;
  while(ng-ok>1){
    int n=(ok+ng)/2,m=n;
    for(pair<char,char> p:A){
      if(S[m]==p.first){
        if(p.second=='R')m++;
        else m--;
      }
      if(m==-1){
        ok=n;
        goto home;
      }
      if(m==N){
        ng=n;
        goto home;
      }
    }
    ok=n;
    home:;
  }
  int mx=ok;
  ok=N,ng=-1;
  while(ok-ng>1){
    int n=(ok+ng)/2,m=n;
    for(pair<char,char> p:A){
      if(S[m]==p.first){
        if(p.second=='R')m++;
        else m--;
      }
      if(m==-1){
        ng=n;
        goto home2;
      }
      if(m==N){
        ok=n;
        goto home2;
      }
    }
    ok=n;
    home2:;
  }
  cout<<mx-ok+1<<endl;
}

Measured memory_bytes: 3920
//============================================================================
// Name        : e.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int main() {
	ll n,m,k;cin>>n>>m>>k;
	ll def=998244353;
	if(m==1){
		if(k==n-1){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}
		return 0;
	}
	if(n==1){
		cout<<m<<endl;
		return 0;

	}
	vector<ll> c(n);
	c[0]=1;
	c[1]=n-1;
//	cout<<'A'<<endl;
	for(int i=2;i<=n-1;i++){

		c[i]=c[i-1]*(n-1-i+1);
		c[i]%=def;
//		cout<<c[i]<<endl;
		c[i]=c[i]*modPow(i,def-2,def);
		c[i]%=def;
//		cout<<c[i]<<endl;
	}
	ll ans=0;
//	cout<<"B"<<endl;
	for(int i=0;i<=k;i++){
		ll add=0;
		if(i==n-1){
			add=m;
			ans+=m;
			ans%=def;
			break;
		}
		add=modPow(m-1,n-i-1,def);
		add*=m;
		add%=def;
		add*=c[i];
		add%=def;
		ans+=add;
		ans%=def;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
bool exist[1100][10];
struct State {
    bitset<10> bit;
    int t;
    State() {
        t = 0;
        bit = 0;
    }
    void show() {
        cerr << bit << endl;
        cerr << "t:" << t << endl;
    }
    bool operator<(const State &b) { return t < b.t; }
};
bool ign(State &a, State &b) {
    if (!a.bit[b.t] && !b.bit[a.t]) return true;
    REP(i, 10) {
        if (a.bit[i] && b.bit[i]) return true;
    }
    return false;
}
bool dead(State &a, State &b) {
    if (a.bit[b.t] && b.bit[a.t]) return true;
    return false;
}
bool canmerge(State &a, State &b) { return (a.bit[b.t] && !b.bit[a.t]) || (!a.bit[b.t] && b.bit[a.t]); }
State merge(State &a, State &b) {
    State nw;
    if (a.bit[b.t] && !b.bit[a.t]) {
        nw.bit = a.bit | b.bit;
        nw.t = a.t;
        return nw;
    } else if (!a.bit[b.t] && b.bit[a.t]) {
        nw.bit = a.bit | b.bit;
        nw.t = b.t;
        return nw;
    } else {
        cerr << "cannot merge!!!!!" << endl;
    }
}
bool solve() {
    int N;
    cin >> N;
    REP(i, 1 << 10) REP(j, 10) exist[i][j] = false;
    if (N == 0) return false;
    string S;
    cin >> S;
    // set<State> ss;
    State now;
    vector<State> vs;
    REP(i, N) {
        if (S[i] == 'u') {
            now.t = 0;
            now.bit = 0;
        } else {
            int num = S[i] - '0';
            now.t = num;
            if (now.bit[now.t]) {
                cout << "UNSAFE" << endl;
                return true;
            }
            int bi = now.bit.to_ulong();
            if (!exist[bi][now.t]) {
                exist[bi][now.t] = true;
                // ss.insert(now);
                // now.show();
                vs.push_back(now);
            }

            now.bit[now.t] = true;
        }
    }

    // for (auto s : ss) vs.push_back(s);
    bool found = true;
    while (found) {
        found = false;
        int n = vs.size();
        REP(i, n) {
            FOR(j, i + 1, n) {
                if (ign(vs[i], vs[j])) continue;
                if (dead(vs[i], vs[j])) {
                    // vs[i].show();
                    // vs[j].show();
                    cout << "UNSAFE" << endl;
                    return true;
                }
                State nw = merge(vs[i], vs[j]);
                int bi = nw.bit.to_ulong();
                if (!exist[bi][nw.t]) {
                    found = true;
                    vs.push_back(nw);
                    // ss.insert(nw);
                    exist[bi][nw.t] = true;
                }
            }
        }
    }
    cout << "SAFE" << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
   int a, b;
   cin >> a >> b;
   int tmp = b - a;
   tmp = tmp*(tmp-1)*0.5;
   cout << tmp - a << endl;
   return 0;
}


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> B[i];

  for (int sy = 0; sy + M - 1 < N; sy++) {
    for (int sx = 0; sx + M - 1 < N; sx++) {
      bool is_same = true;
      for (int y = 0; y < M; y++) {
        int y2 = y + sy;
        for (int x = 0; x < M; x++) {
          int x2 = x + sx;
          if (A[y2][x2] != B[y][x]) {
            is_same = false;
            break;
          }
        }
      }

      if (is_same) {
        cout << "Yes\n";
        return 0;
      }
    }
  }

  cout << "No\n";

  return 0;
}


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

using namespace std;

const int N = 18;
const int M = 51;
const int MOD = 1e9+7;
typedef pair<int, int> pii;

int n;
int a[N][2], dp[1<<N][M];

inline void update(int &x, const int &y)
{
    if (x == -1 || y < x) x = y;
}

inline void solve()
{
    cin >> n;
    for (int j = 0; j < 2; ++j)
        for (int i = 0; i < n; ++i)
            cin >> a[i][j];

    memset(dp, -1, sizeof dp);
    dp[0][1] = 0;
    for (int i = 1; i < 1<<n; ++i) {
        int t = __builtin_popcount(i)-1;
        for (int p = 0; p < n; ++p) if ((i>>p)&1) {
            int j = a[p][abs(t-p)&1], num = 0;
            for (int k = p+1; k < n; ++k) num += (i>>k)&1;
            for (int k = 1; k <= j; ++k) if (dp[i^(1<<p)][k] != -1) {
                update(dp[i][j], dp[i^(1<<p)][k]+num);
            }
        }
    }
    int res = -1;
    for (int j = 0, i = (1<<n)-1; j < M; ++j) if (dp[i][j] != -1) {
        update(res, dp[i][j]);
    }
    cout << res << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 52480
#include<bits/stdc++.h>
#define SIZE 130
using namespace std;


int main(){
  int n,q;
  string s;

  int index=0;  
  int num_span[SIZE],length[SIZE],ok_LOC[SIZE];
  int***table;
  
  cin>>n>>q;
  
  //約数を求める
  for(int i=2;i<=n/2;i++){
    if(n%i==0){
      num_span[index]=i;//区間の数
      length[index++]=n/i;//各区間の長さ
    }
  }
  num_span[index]=n;
  length[index++]=1;

  
  table = new int**[index];
    for(int i=0;i<index;i++){
      table[i]=new int*[length[i]];
      for(int k=0;k<length[i];k++){
	table[i][k]=new int[26];
	for(int a=0;a<26;a++){
	  table[i][k][a]=0;
	}
      }
    }

  for(int i=0;i<index;i++){
    ok_LOC[i]=0;
  }
  
  cin>>s;
  for(int i=0;i<n;i++){
    for(int k=0;k<index;k++){
      table[k][i%length[k]][s[i]-'a']++;
      if(table[k][i%length[k]][s[i]-'a'] == num_span[k]){
	ok_LOC[k]++;
      }
    }
  }

  
  char pre;
  int p;
  char c;
  
  for(int loop=0;loop<q;loop++){
    cin>>p>>c;
    p--;
    
    pre=s[p];
    s[p]=c;
    int minimum=n; 

    for(int i=0;i<index;i++){
      if(table[i][p%length[i]][pre-'a'] == num_span[i]){
	ok_LOC[i]--;
      }
      
      table[i][p%length[i]][pre-'a']--;
      table[i][p%length[i]][c-'a']++;
      
      if(table[i][p%length[i]][c-'a'] == num_span[i]){
	ok_LOC[i]++;
      }
      
      if(ok_LOC[i] == length[i]){
	minimum=min(minimum,length[i]);
      }
    }
    cout<<minimum<<"\n";    
  }

  return 0;
}



Measured memory_bytes: 34104
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    string s;cin>>s;
    if(s.back()=='s'){
        cout<<s<<"es"<<endl;
    }else{
        cout<<s<<"s"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
/**** Union Find ****/

class UnionFind {
  vector<ll> par, rank; // par > 0: number, par < 0: -par
public:
  void init(ll n) {
    par.resize(n, 1); rank.resize(n, 0);
  }
  ll getSize(ll x) {
    return par[find(x)];
  }
  ll find(ll x) {
    if (par[x] > 0) return x;
    return -(par[x] = -find(-par[x]));
  }
  void merge(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[y] += par[x];
      par[x] = -y;
    } else {
      par[x] += par[y];
      par[y] = -x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool isSame(ll x, ll y) {
    return find(x) == find(y);
  }
};
int main(){
    UnionFind uf;
    int N,M;
    cin>>N>>M;
    uf.init(2*N);
    for(int i=0;i<M;i++){
        int x,y,z;
        cin>>x>>y>>z;
        if(z%2==0){
            uf.merge(x,y);
            uf.merge(x+N,y+N);
        }else{
            uf.merge(x,y+N);
            uf.merge(x+N,y);
        }
    }
    set<ll> st;
    int c=0;
    for(int i=1;i<=N*2;i++){
        st.insert(uf.find(i));
    }
    cout<<st.size()/2<<endl;
    return 0;
}

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

int main(void)
{

    long long int n, min;
    cin >> n;
    min = n - 1;
    for (int i = 2; i <= sqrt(n); i++)
    {
        if ((n % i) == 0 && ((n / i) + i < min))
        {
            min = (n / i) + i - 2;
        }
    }
    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := iScan(), iScan()
	d := make(map[int]struct{})
	for i := 1; i*i <= a; i++ {
		if a%i == 0 {
			if b%i == 0 {
				d[i] = struct{}{}
			}
			if b%(a/i) == 0 {
				d[a/i] = struct{}{}
			}
		}
	}
	x := make(map[int]struct{})
	x[1] = struct{}{}
	for k, _ := range d {
		y := PrimeFactors(k)
		for _, v := range y {
			x[v] = struct{}{}
		}
	}
	fmt.Println(len(x))
}
func PrimeFactors(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}
	if n > 2 {
		pfs = append(pfs, n)
	}
	return
}


Measured memory_bytes: 3480
#入力
lst = input().split()

#整数値化
for i in range(len(lst)):
   lst[i] = int(lst[i])

#各面積
area1 = lst[0] * lst[1]
area2 = lst[2] * lst[3]

#リストに格納してソート
areas = [area1, area2]
areas.sort()

#出力
print(areas[1])

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

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

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

  string S;
  cin >> S;

  ll ans = 0;
  int white_count = 0;
  RREP(i,S.size()) {
    if (S[i] == 'W') {
      white_count++;
    } else if (S[i] == 'B') {
      ans += white_count;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3716
#include<stdio.h>
int main(void)
{
	int i,a,aa,b,c,d,e,f,s,ss,q;
	for(i=0;i<3;i++){
		scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
		s=a*3600+b*60+c;
		ss=d*3600+e*60+f;
		q=ss-s;
		a=q/3600;
		aa=q%3600;
		b=aa/60;
		c=aa%60;
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}

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

int main() {
    int N,M;
    cin>>N>>M;
    vector<vi> work_list(100001);
    for (int i = 0; i < N; i++){
        int A,B;cin>>A>>B;
        work_list[A].push_back(B);
    }
    priority_queue<int> q;
    int ans=0;
    for (int i = 1; i <=M; i++){
        for(auto x:work_list[i])q.push(x);
        if(q.size()){
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
}

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

#define fi first
#define se second

const int N = 1000300;
const long long mod = 1e9 + 7;

using namespace std;

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        int n;
        cin >> n;
        vector < int > v(2 * n);
        for(int i = 0; i < 2 * n; i++){
                cin >> v[i];
        }
        sort(v.begin(), v.end());
        int res = 0;
        for(int i = 0; i < n; i++){
                res += v[i * 2];
        }
        cout << res << "\n";
}


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

const int INF = 1001001001;
const int NV=100100;

int main() {
  int N;
  cin>>N;
  int a[N], b[N];
  for(int i=0; i<N; i++){
    cin>>a[i];
  }
  for(int i=0; i<N; i++){
    cin>>b[i];
  }
  int num_a=0, num_b=0;
  for(int i=0; i<N-1; i++){
    int fn=1;
    for(int k=1;k<N-i;k++){
      fn*=(N-i-k);
    }
    for(int j=i+1; j<N; j++){
      if(a[i]>a[j]){
        num_a+=fn;
      }
      if(b[i]>b[j]){
        num_b+=fn;
      }
    }
  }  
  cout<<abs(num_b-num_a)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

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

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n);
  vector<ll> a(n);

  REP(i, n) {
    cin >> a[i];
  }

  ll now = 0;
  ll cnt = 0;
  REP(i, n) {
    if (a[i] == now) {
      if (now != 0) cnt++;
      now++;
    } else if(a[i] < now) {
      cnt += a[i];
      now = a[i] + 1;
    } else {
      print(-1);
      return 0;
    }
  }
  print(cnt);
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=1e6+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int a[N];
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;
    int n;cin>>n;
    rep1(i,n) cin>>a[i];
    int sum=0;
    rep1(i,n) sum^=a[i];
    rep1(i,n)
    {
        cout<<(sum^a[i])<<" ";
    }
    return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int a, b, c; cin >> a >> b >> c;
	cout << min({a+b, b+c, c+a}) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        if (m.count(x)) {
            m.erase(x);
        } else {
            m[x]++;
        }
    }

    cout << m.size() << endl;
    return 0;
}

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

#include <unordered_map> 
#include <cstdio>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n

using namespace std;

// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

// UTILITY FUNCTIONS

// String
char toUpper(const char &c) { return isupper(c) ? c : c - 'a' + 'A'; }
char toLower(const char &c) { return islower(c) ? c : c + 'a' - 'A'; }
bool isvowel(char c){  c = toLower(c);return (c == 'a' or c == 'e' or c == 'i' or c == 'i' or c == 'o' or c == 'u' || c == 'y');}
void toLowerCase(string &s){rep(s.size()){  if (!islower(s[i]))  {    s[i] = tolower(s[i]);  }}}
void toUpperCase(string &s){rep(s.size()) { s[i] = toupper(s[i]); }}
bool ispal(string s){  ll lo, hi;  lo = 0;  hi = s.length() - 1;  while (lo <= hi)  {    if (s[lo] != s[hi])    {      return 0;    }    lo++;    --hi;  }  return 1;}
template <class T>string toString(T n){  string v = "";  while (n)  {    v.pb(n % 10 + '0');    n /= 10;  }  reverse(all(v));  return v;}

// Maths
template <typename t>t gcd(t a, t b){  a = abs(a), b = abs(b);  return ((b == 0) ? a : gcd(b, a % b));}
template <typename t>t lcm(t a, t b) { return (a * (b / gcd(a, b))); }
template <typename T>T modpow(T base, T exp, T modulus){  base %= modulus;  T result = 1;  while (exp > 0)  {    if (exp & 1)      result = (result * base) % modulus;    base = (base * base) % modulus;    exp >>= 1;  }  return result;}
template <typename T>void cumulative(T *a, T *b, T n){  rep(n) { i ? b[i] = b[i - 1] + a[i] : b[i] = a[i]; }}

// Some constants
const int inf = 1e9 + 7;
const double eps = 1e-6;
const double pi = 1.00 * acos(-1.00);

//------------------------------------------------------------------------


const int N = 1e6;
map<ll, vii> adj;
bool color[N] = {0};
bool ans[N] = {0};

void dfs(ll u, ll wt){
  color[u] = 1;
  for(auto x: adj[u]){
    if(color[x.fr] == 0){
      if((wt + x.sc) & 1){
        ans[x.fr] = 1;
      }else{
        ans[x.fr] = 0;
      }
      dfs(x.fr, wt+x.sc);
    }
  }
}




void solve(ll testcase){
  ll n;
  cin >> n;
  rep(n-1){
    ll u, v, wt;
    cin >> u >> v >> wt;
    u--, v--;
    adj[u].pb(mp(v, wt));
    adj[v].pb(mp(u, wt));
  }
  dfs(0, 0);
  rep(n){
    cout << ans[i] << endl;
  }
}

int main()
{
  std::ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef ONLINE_JUDGE
#else
//  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  ll t = 1;
  // cin >> t;
  ll cas = 0;
  while (t--)
  {
    solve(++cas);
  }
}


Measured memory_bytes: 16128
#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 rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#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(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  multiset<int> ms;
  rep(i, n){
    int in;
    cin >> in;
    ms.insert(in);
  }
  int m;
  cin >> m;
  rep(i, m){
    int in;
    cin >> in;
    if(ms.find(in) != ms.end()){
      ms.erase(ms.find(in));
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 12956
#include <bits/stdc++.h>
#define int long long
#define dl long double
#define ff first
#define ss second
#define pb push_back
#define MAXN 20
#define inf 1000000007
#define INI 12332112
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;

int pre[(1<<16)+10];
int a[MAXN][MAXN];
int dp[(1<<16)+10];
int full=0;


int32_t main(){
	fastio;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n;i++){
		full+=(1<<i);
	}
	for(int x=1;x<=full;x++){
		int atual=0;
		for(int b1=0;b1<n;b1++){
			for(int b2=b1+1;b2<n;b2++){
				if(((x&(1<<b1))!=0) && ((x&(1<<b2))!=0)){
					atual+=a[b1][b2];
				}
			}
		}
		pre[x]=atual;
	}
	for(int i=1;i<=full;i++){
		dp[i]=pre[i];
	}
		
	for(int x=1;x<=full;x++){
		for(int g1=x;g1>0;g1=(g1-1)&x){
			int g2=x^g1;
			dp[x] = max(dp[x],dp[g1]+dp[g2]);
		}
	}
	
	cout<<dp[full]<<endl;
		
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int keta=0;
    for(int i=N;i!=0;keta++){
        i/=10;
    }
    // cout<<keta<<endl;
    int num=0;
    int temN=N;
    int temN2=N;
    for(int i=keta-1;i>=0;i--){
        temN/=10;
        num+=temN2-temN*10;
        temN2/=10;
    }
    // cout<<num<<endl;
    if(N%num==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;

#define INF 987654321
#define ll long long

int N;

int f(int A, int K)
{
	if (A < K) return 0;
	if (A % K == 0) return A / K;

	int x = (A%K - 1) / (A / K + 1) + 1; //분자가 분모로 나누어 떨어지는 경우만 예외 처리
	return f(A - x * (A / K + 1), K); //O(sqrt(A)) Optimization
}

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

	int res = 0, one = 0, zero = 0;
	for (int i = 0; i < N; i++)
	{
		int A, K;
		scanf("%d %d", &A, &K);
		int val = f(A, K);
		res ^= val;
		if (val == 0) zero++;
		else if (val == 1) one++;
	}
	
	if (one + zero == N)
	{
		if (one % 2 == 1) printf("Takahashi");
		else printf("Aoki");
	}
	else
	{
		if (res == 0) printf("Aoki");
		else printf("Takahashi");
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

// 普通のKnapsack問題ではなかった
int main() {
	string S, T;
	cin >> S >> T;
	int cnt = 0;
	rep(i, 3) {
		if(S[i]==T[i]) cnt++;
	}
	
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 764
x,y,a,b,c = (int(num) for num in input().split())
p = [int(num) for num in input().split()]
q = [int(num) for num in input().split()]
r = [int(num) for num in input().split()]
apples = []
for i in range(a):
    apples.append((p[i],"r"))
for i in range(b):
    apples.append((q[i],"g"))    
for i in range(c):
    apples.append((r[i],"n"))
    
apples.sort(reverse = True)

cntr = 0
cntg = 0
cntall = 0
i = 0
ans = 0
#print(apples)
while True:
    if apples[i][1] == "r" and cntr < x:
        ans += apples[i][0]
        cntr += 1
        cntall += 1
    if apples[i][1] == "g" and cntg < y:
        ans += apples[i][0]
        cntg += 1
        cntall += 1
    if apples[i][1] == "n":
        ans += apples[i][0]
        cntall += 1
        
    if cntall == x + y:
        break
    i += 1
    
print(ans)

Measured memory_bytes: 38704
#include <bits/stdc++.h>
using namespace std;
int main()
{
     string str[1000];
     int N, L;
     cin >> N >> L;
     for (int i = 1; i <= N; i++) {
        cin >> str[i];
     }
     sort(str + 1, str +N+1);
     string sh = "";
     for (int i = 1; i <= N; i++) {
        sh += str[i];
     }
     cout << sh << endl;
     return 0;
}


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

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            int n;
            cin>>n;
            if(n%1000==0)
              cout<<0;
            else
              cout<<1000-n%1000;
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3800
import numpy
d = int(input())
c = list(map(int,input().split()))
s = [[2 for j in range(26)] for i in range(d)]
k = [1]*26
for i in range(d):
    if i%36 == 0:
        k = [1]*26
    x = sum(k)
    if x >= 30 - i%30:
        q = 0
        for i in range(26):
            if k[i] == 1:
                q = i
                break
    else:
        q = numpy.argmax(s[i])
    print(q+1)
    k[q] = 0

Measured memory_bytes: 27296
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	long A,B,C;
	public void solve() {
		A = nextLong();
		B = nextLong();
		C = nextLong();
		
		if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
			out.println(0);
			return;
		}
		
		long ans = Math.min(A * B,Math.min(B * C,C * A));
		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
	
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

#define int long long

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;

	if (n % 1000 > 0)
		cout << 1000 - (n % 1000);
	else
		cout << 0;

	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll MOD;
template<class T> struct Matrix {
    vector<vector<T> > val;
    Matrix(int n = 1, int m = 1) {val.clear(); val.resize(n, vector<T>(m));}
    Matrix(int n, int m, T x) {val.clear(); val.resize(n, vector<T>(m, x));}
    void init(int n, int m, T x = 0) {val.clear(); val.resize(n, vector<T>(m, x));}
    void resize(int n, int m, T x = 0) {val.resize(n); for (int i = 0; i < n; ++i) val[i].resize(m, x);}
    int size() {return val.size();}
    inline vector<T>& operator [] (int i) {return val[i];}
    friend ostream& operator << (ostream& s, Matrix<T> M) {s << endl;
        for (int i = 0; i < M.val.size(); ++i) s << M[i] << endl; return s;}
};

template<class T> Matrix<T> operator * (Matrix<T> A, Matrix<T> B) {
    Matrix<T> R(A.size(), B[0].size());
    for (int i = 0; i < A.size(); ++i)
        for (int j = 0; j < B[0].size(); ++j)
            for (int k = 0; k < B.size(); ++k)
                R[i][j] = (R[i][j] + A[i][k] * B[k][j])%MOD;
    return R;
}

template<class T> vector<T> operator * (Matrix<T> A, vector<T> B) {
    vector<T> v(A.size());
    for (int i = 0; i < A.size(); ++i)
        for (int k = 0; k < B.size(); ++k)
            v[i] = (v[i] + A[i][k] * B[k]) % MOD;
    return v;
}

template<class T> Matrix<T> pow(Matrix<T> A, long long n) {
    Matrix<T> R(A.size(), A.size());
    for (int i = 0; i < A.size(); ++i) R[i][i] = 1;
    while (n > 0) {
        if (n & 1) R = R * A;
        A = A * A;
        n >>= 1;
    }
    return R;
}
ll ruijo(ll a,ll n){
	if(n==0) return 1;
	if(n%2==0) return ruijo(a*a%MOD,n/2);
	else return ruijo(a,n-1)*a%MOD;
}
int main(){
	ll L,A,B;
	scan(L>>A>>B>>MOD);
	ll ketanum[20]={};
	ll LAST=A+B*(L-1);
	rep1(i,18){
		if(i==1) ketanum[i]=max(0LL,(min(LAST,(ll)(pow(10,i)+eps)-1)-A)/B+1);
		else ketanum[i]=max(0LL,(min(LAST,(ll)(pow(10,i)+eps)-1)-A)/B+1)-max(0LL,(min(LAST,(ll)(pow(10,i-1)+eps)-1)-A)/B+1);
		//printf("i:%d keta:%lld\n",i,ketanum[i]);
	}
	Matrix<ll> Xs1(1,3);
	Xs1[0][0]=0,Xs1[0][1]=A%MOD,Xs1[0][2]=1;
	rep1(i,18){
		Matrix<ll> M(3,3);
		M[0][0]=(ll)(pow(10,i)+eps)%MOD,M[0][1]=0,M[0][2]=0;
		M[1][0]=1,M[1][1]=1,M[1][2]=0;
		M[2][0]=0,M[2][1]=B%MOD,M[2][2]=1;
		Xs1=Xs1*pow(M,ketanum[i]);
		//printf("i:%d  Xs1: %lld, %lld, %lld\n",i,Xs1[0][0],Xs1[0][1],Xs1[0][2]);
	}
	prin(Xs1[0][0]);
	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


inline void transpose(vector<string> &a) {

    int n = a.size();
    if (n == 0) return;
    int m = a[0].size();
    vector<string> b(m, string(n, ' '));
    fori (i, n) fori (j, m) b[j][i] = a[i][j];
    a = b;
}


template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

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


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#define cerr cout
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}


const int N = 3009;

ll dp[N][N];
char did[N][N];
ll a[N];


ll get_dp(int l, int r) {
    if (l > r) return 0;
    if (did[l][r]) return dp[l][r];
    did[l][r] = 1;
    ll & ret = dp[l][r];
    return ret = max(a[l] - get_dp(l + 1, r), a[r] - get_dp(l, r - 1));
}

void smain() {

    int n;
    cin >> n;
    fori (i, n) cin >> a[i];

    cout << get_dp(0, n - 1);
}

Measured memory_bytes: 78592
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int64_t powmod(int64_t x, int64_t n, int64_t mod) {
	int64_t ret = 1;
	while (n > 0) {
		if (n & 1) (ret *= x) %= mod;
		(x *= x) %= mod;
		n >>= 1;
	}
	return ret;
}



int main() {

	int n; cin >> n;

	vector<LL> a(n);
	vector<LL> d(n);

	LL mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];

		mx = max(mx, a[i]);
		d[a[i]]++;
	}

	if (a[0] != 0 || d[0]>1) {
		cout << 0 << endl;
		return 0;
	}

	LL ans = 1;

	for (int i = 1; i < mx+1; i++) {
		for (int j = 0; j < d[i]; j++) {
			ans = (ans*d[i - 1]);
			ans %= 998244353;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << wi+1 << ": "  


int main()
{
    string s;
    cin >> s;
    int sum=0;
    for(int i=0;i<s.length();i++)
    {
        int a=s[i]-'0';
        sum+=a;
    }
    if(sum%9==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define LL long long int

int main() {
	LL n;
	cin>>n;
	LL a[n],b[n];
	for(LL i=0;i<n;i++){
	    LL x;
	    cin>>x;
	    a[i]=x;
	    b[i]=x;
	}
	sort(a,a+n);
	LL cnt=0;
	for(LL i=0;i<n;i++){
	    if(a[i]!=b[i]){
	        cnt++;
	    }
	}
	if(cnt==2||cnt==0){
	    cout<<"YES"<<endl;
	}
	else{
	    cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int i64;
i64  mod= 1000000007;
void inline solve(int tt){

    int a,b;
    cin>>a>>b;
    if(a>9 || b>9)
        cout<<-1<<endl;
    else
        cout<<a*b;


}
int main()
{
    int tt=0,t=1;
    //cin>>t;

    while(t--){solve(++tt);}
}



Measured memory_bytes: 3600
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
 
using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
 
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007
 
typedef long long ll;
typedef tuple<int,int,bool> Tb;


int abc104_c(){
    //入力
    int a,b;
	cin >> a >> b;
  
    //処理
  
    //出力
    cout << RUP(a+b,2) << ENT;
    return 0;
}

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


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

using namespace std;

#define llong long long 
typedef pair<long int, int> P;
long int d[10001];
bool Dec[10001];
vector<P> edges[10001];
priority_queue<P, vector<P>, greater<P> > q;

void solve(){
	fill_n(d, 10001, 9999999);
	d[0] = 0;
	fill_n(Dec, 10001, false);
	q.push(P(0,0));

	while(!q.empty()){
		P p = q.top(); q.pop();
		if(Dec[p.second] == true) continue;
		Dec[p.second] = true;
		d[p.second] = p.first;

		for(int i = 0; i < edges[p.second].size(); i++){
			P e = edges[p.second][i];
			if(d[e.second] > p.first + e.first){
				q.push(P(p.first + e.first, e.second));
			}
		}
	}

	return;
}

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		int num;
		int howedge;
		cin >> num >> howedge;
		for(int j = 0; j < howedge; j++){
			int to;
			long int cost;
			cin >> to >> cost;
			edges[num].push_back(P(cost, to));
		}
	}

	solve();

	for(int i = 0; i < N; i++){
		cout << i << " " << d[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 16056
#include <bits/stdc++.h>
#define int64 long long int
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

int main() {
	int A,B,C,X,Y,Z;
	cin >> X>>Y>>Z;

	int tmp=X;
	X=Y;
	Y=tmp;
	tmp=X;
	X=Z;
	Z=tmp;
	cout << X<<" "<<Y<<" "<<Z << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
// finish date: 2018/03/13

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N, K;
    cin >> N >> K;
    if (K == 0) {
        cout << (ll) N * N << endl;
        return 0;
    }
    ll ans = 0;
    FOR(b, K + 1, N + 1) {
        ans += N / b * (b - K);
        ans += max(N % b - K + 1, 0);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256