akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

int main(){
    
    int N;cin>>N;
    string S;cin>>S;
    
    ll dp[N+1][N];//i番目 iより大きいものがj個
    for(int i=0;i<N+1;i++){
        for(int j=0;j<N;j++){
            dp[i][j]=0;
        }
    }
    for(int j=0;j<N;j++){
        dp[1][j]=1;
    }
    for(int i=2;i<=N;i++){
        vector<ll> sum(N+1);
        sum[0]=0;
        for(int j=1;j<N+1;j++){
            sum[j]=(sum[j-1]+dp[i-1][j-1])%mod;
        }
        
        if(S[i-2]=='<'){
            for(int j=0;j<N-i+1;j++){
                dp[i][j]=(sum[j+1]+mod)%mod;
            }
        }else{
            for(int j=0;j<N-i+1;j++){
                dp[i][j]=(sum[N]-sum[j+1]+mod)%mod;
            }
        }
    }
    /*for(int i=0;i<N+1;i++){
        for(int j=0;j<N;j++){
            if(j) cout<<" ";
            cout<<dp[i][j];
        }
        cout<<endl;
    }*/
  cout<<dp[N][0]<<endl;
}


Measured memory_bytes: 70656
#include <stdio.h>

int main(void)
{
    int q;
    int c, a, n;
    int cnt;
    int i;
    
    scanf("%d", &q);
    for (i = 0; i < q; i++){
        cnt = 0;
        scanf("%d %d %d", &c, &a, &n);
        
        while (c >= 1  && a >= 1 && n >= 1){
            cnt++;
            c--; a--; n--;
        }
        while (c >= 2 && a >= 1){
            cnt++;
            c -= 2;
            a--;
        }
        while (c >= 3){
            cnt++;
            c -= 3;
        }
        
        
        printf("%d\n", cnt);
    }
    return (0);
}

Measured memory_bytes: 600
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Ord
import Control.Monad


r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [n,m] <- r'
    print $ if abs (n-m) > 1 then 0 else (if n==m then (*2) else id) (fact n * fact m)

fact :: Int -> Mint
fact n = product $ map fromIntegral [1..n]




mdl = 1000000007

(^%) :: Int -> Int -> Int
b ^% e = powAux (b `rem` mdl) e 1 `mod` mdl
    where 
        powAux _ 0 ac = ac
        powAux b e ac = powAux (b*b `rem` mdl) (e `quot` 2)
            (if odd e then b*ac `rem` mdl else ac)

(+%), (-%), (*%), (/%) :: Int -> Int -> Int
a +% b = (a + b) `rem` mdl
a -% b = (a - b) `mod` mdl
a *% b = (a * b) `rem` mdl
a /% b = (a * invMod b) `mod` mdl
    where   invMod :: Int -> Int
            invMod = (^% (mdl-2))

newtype Mint = M Int deriving Eq
instance Num Mint where
    M a + M b = M (a +% b)
    M a * M b = M (a *% b)
    M a - M b = M (a -% b)
    abs = id
    signum (M 0) = 0
    signum _ = 1
    fromInteger = M.(`mod`mdl).fromInteger
instance Show Mint where
    show (M a) = show a

Measured memory_bytes: 380
// 美しい文字列
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    int a[26]={};
    cin>>s;
    for(int i=0;i<s.size();i++){
        a[s[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        if(a[i]%2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

// http://www.spoj.com/problems/QCJ4/
// http://www.spoj.com/status/ns=18116289

// int main(){
//     srand(time(0));
//     int n;
//     cin >> n;
//     vector<P> ps(n);
//     for(int i = 0; i < n; ++i){
//         ld x,y;
//         cin >> x >> y;
//         ps[i] = P(x,y);
//     }

//     printf("%.2lf\n", (double)smallest_enclosing_disc(ps).rad*2);
// }


int n,m;
ld r[111], mb[111];

bool used[111];

bool chk(int s){
    vector<int> b;
    rep(i,n)if(!used[i]) b.emplace_back(r[i]);
    vector<ld> a;
    for(int i = s; i < m; ++i) a.emplace_back(mb[i]);
    sort(all(a));
    sort(all(b));
    int last = -1;
    rep(i,a.size()){
        bool found = false;
        for(int j = last+1; j < (int)b.size(); ++j){
            if(a[i] < b[j] + eps){
                found = true;
                last = j;
                break;
            }
        }
        if(!found)return false;
    }
    return true;
}

int main(){
    cout<<std::setprecision(10);

    cin >> n;
    G g(n);
    rep(i,n){
        ld x,y;
        cin >> x >> y;
        g[i] = P(x,y);
    }
    double ans = smallest_enclosing_disc(g).first;
    cout<<ans<<endl;
}

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

const ll mod = 998244353;

int main() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(s + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= mod;
            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= mod;
            }
        }
    }
    cout << dp[n][s] << endl;
}

Measured memory_bytes: 73728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  ll n,m;
  string s,t;
  cin >>n>>m>>s>>t;
  ll k = __gcd(n,m);
 
  ll x = n / k, y = m / k;
  for (int i = 0; i < k; i++)
  {
    if (s[i*x] != t[i*y]) {
      cout << -1 << endl;
      return 0;
    } 
  }
  cout << n/k*m << endl;
  return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	ll n;cin>>n;
	ll x=0;
	ll a[n];rep(i,0,n){cin>>a[i];x=(x^a[i]);}
	if(n%3==0){
		ll t=(n/3)%2;
		if(x==0)cout<<"Yes";
		else cout<<"No";
	}
	else{
		ll f=1;rep(i,0,n)if(a[i]!=0)f=0;
		if(f)cout<<"Yes";
		else cout<<"No";
	}
	
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  long long n, k; cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
    a[i]--;
  }
  if (a[0] == 0) {
    cout << 1 << endl;
    return 0;
  }

  vector<int> x(n, -1);
  long long now = 0;
  for(long long i=0; i<k; i++) {
    if (x[now] != -1) {
      long long d = i - x[now];
      long long p = (k-i) / d;
      if (p >= 1) {
        i += (p-1) * d;
      }
    }
    x[now] = i;
    now = a[now];
  }

  cout << now + 1 << endl;

  return 0;
}

// EOF

Measured memory_bytes: 4848
function main()
  
  (N,M,X,Y) = map(x -> parse(Int,x), split(readline()))
  x = map(x -> parse(Int,x), split(readline()))
  y = map(x -> parse(Int,x), split(readline()))
  
  check = false
  
  for i in X+1:Y
    
    if maximum(x) < i && minimum(y) >= i
      check = true
      println("No War")
      break
    end
    
  end
  
  if check == false
    println("War")
  end
  
end

main()


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

//問題文より、入力される最大の桁数1000+1(改行文字分)を要素数とする
#define MAXDIGIT 1001

//各桁の和を計算する関数
int get_ans(char *str);

int main(void)
{
	//iはループ変数、countは入力されたデータセット数を格納
	int i, count;
	char num[MAXDIGIT][MAXDIGIT];

	count = 0;
	//データセットの入力(0ならば入力終了)
	do{
		scanf("%s", num[count]);
		count++;
	}while(strcmp(num[count - 1], "0"));

	//最後の入力(0)に対しては出力しない
	count--;
	//結果の出力
	for(i = 0; i < count; i++){
		printf("%d\n", get_ans(num[i]));
	}

	return 0;
}

int get_ans(char *str)
{
	//ansに各桁の和を格納
	int ans;

	ans = 0;
	//文字列の最後まで繰り返す
	while(*str != '\0'){
		//文字を数値に変換して加算する
		ans += (*str - '0');
		str++;
	}

	return ans;
}


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

int main(){
  int w,a,b;
  cin >> w >> a >> b;
  int x = min(a,b);
  int y = max(a,b);
  cout << max(0,y-x-w) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

ll N,A,B;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>A>>B;
	if(A==0){
		cout<<0;
		return 0;
	}
	ll t=N/(A+B);
	ll k=N%(A+B);
	ll res=0;
	res+=t*A;
	if(k>=A){
		res+=A;
	}else{
		res+=k;
	}
	// if((A+B)*)
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
signed main() {
  int n;
  cin >> n;
  vi p(n);
  rep (i, n) {
    cin >> p[i];
  }
  int mi = inf;
  int ans = 0;
  rep (i, n) {
    if (p[i] <= mi) ans++;
    chmin(mi, p[i]);
  }
  cout<< ans << endl;
}

Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc145/tasks/abc145_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

const int MOD = 1000000007;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) {
    int x = a.n + b.n;
    return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
    int x = a.n - b.n;
    return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
    for (int i = I_.size(); i <= n; i++) {
        I_.push_back(I_[MOD % i] * (MOD - MOD / i));
        F_.push_back(F_[i - 1] * i);
        R_.push_back(R_[i - 1] * I_[i]);
    }
}

mint I(int n) {
    check_fact(abs(n));
    return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
    check_fact(n);
    return n < 0 ? 0 : F_[n];
}
mint R(int n) {
    check_fact(n);
    return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0) {
        cout << "0\n";
        return 0;
    }
    int m = (2 * X - Y) / 3;
    int n = (2 * Y - X) / 3;
    cout << C(m + n, min(m, n)) << endl;

    return 0;
}


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

using namespace std;

const int N = 2 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int k, n;
long long dp[N][N], sdp[N][N], binomial[N + N][N + N];
const long long M = 998244353;

bool read() {
    if (!(cin >> k >> n))
        return false;

    return true;
}

long long sums(int n, int k) {
    return (n == 0 && k >= 0) ? 1ll : (n <= 0 || k <= 0 ? 0ll : binomial[n + k - 1][k - 1]);
}

void solve() {
    dp[0][0] = 1;

    for (int j = 0; j < N; ++j)
        sdp[0][j] = 1;

    for (int i = 1; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dp[i][j] = dp[i - 1][j] + 2 * (j > 0 ? sdp[i - 1][j - 1] : 0);
            dp[i][j] %= M;
        }

        sdp[i][0] = dp[i][0];

        for (int j = 1; j < N; ++j)
            sdp[i][j] = (dp[i][j] + sdp[i][j - 1]) % M;
    }

    binomial[0][0] = 1;

    for (int i = 1; i < N + N; ++i) {
        binomial[i][0] = 1;

        for (int j = 1; j <= i; ++j)
            binomial[i][j] = (binomial[i - 1][j - 1] + binomial[i - 1][j]) % M;
    }

    for (int i = 2; i <= 2 * k; ++i) {
        auto l = max(1, i - k);
        auto r = min(i - 1, k);
        auto p = (r - l + 1) / 2;
        auto res = 0ll;

        for (auto s1 = 0; s1 <= n; ++s1) {
            auto s2 = n - s1;
            auto b1 = dp[p][s1];
            auto b2 = 0ll;

            if (i % 2 == 0)
                b2 = sums(s2, k - 2 * p - 1) + sums(s2 - 1, k - 2 * p - 1);
            else
                b2 = sums(s2, k - 2 * p);

            res += b1 * b2 % M;
        }

        cout << res % M << endl;
    }
}

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

    while (read())
        solve();

    return 0;
}



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    string N;
    std::cin >> N;

    if(N[0] == N[2]) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
def solve(G1, G2, w1, w2):
  global ans
  n = len(G2)
  for e in G2:
    w, lim, s = Food[e]
    a = w1 + w * n
    if w2 > lim or a > ans[0]: return
    b = G1 + [e]
    if n == 1:
      ans = min(ans, [a, b])
    else:
      x = G2[:]
      x.remove(e)
      solve(b, x, a, w2 + w)
  return
 
while 1:
  n = input()
  if n==0: break
  ans = [1e9, []]
  N = range(n)
  f = lambda x: map(int, x[1:3]) + [x[0]]
  Food = [f(raw_input().split()) for _ in [0]*n]
  solve([], N, 0, 0)
  for e in ans[1][::-1]:
    print Food[e][2]

Measured memory_bytes: 4296
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        double b = sc.nextDouble();

        long bb = (long)(b * 100 + 0.1);
        long ans = a * bb;

        System.out.println(ans / 100);
    }
}



Measured memory_bytes: 36876
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
  int n;
  cin >> n;
  vector<int> villager(n);
  for(int i = 0; i < n; ++i) cin >> villager[i];
  sort(villager.begin(), villager.end());
  int ans = INF;
  int sum;
  for(int i = villager[0]; i <= villager[n - 1]; ++i){
    sum = 0;
    for(int j = 0; j < n; ++j){
      sum += pow((i - villager[j]), 2);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# 初期入力
X = int(input())

# 枚数設定
a_500 =0
a_100 =0
a_50 =0
a_10 =0
a_5 =0
a_1 =0

# ５００円を多く持てるように、１００円１０円は持たず、５円を多く持つ
a_500,amari = divmod(X,500)
a_5,amari = divmod(amari,5)

#幸福
koufuku = a_500 * 1000 + a_5 * 5
print(koufuku)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const LL MOD = 1e9 + 7;
void marmot0814() {
    int n; cin >> n;
    vector<LL> dp(1 << n, 0); dp[0] = 1;
    for (int i = 0 ; i < n ; i++) {
        vector<LL> tmp(1 << n, 0);
        vector<int> arr(n);
        for (auto &v : arr)
            cin >> v;
        for (int S = 0 ; S < (1 << n) ; S++) {
            if (__builtin_popcount(S) != i + 1)
                continue;
            for (int j = 0 ; j < n ; j++) {
                if (arr[j] == 0) continue;
                if (((S >> j) & 1) == 0)
                    continue;
                (tmp[S] += dp[S ^ (1 << j)]) %= MOD;
            }
        }
        dp = tmp;
    }
    cout << dp.back() << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 36092
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> X(M,0);
    for(int i=0;i<M;i++){
        cin >> X[i];
    }
    sort(X.begin(),X.end());
    vector<int> X_sa(M-1,0);
    for(int i=0;i<M-1;i++){
        X_sa[i]=X[i+1]-X[i];
    }
    sort(X_sa.begin(),X_sa.end());
    int ans=0;
    for(int i=0;i<M-N;i++){
        ans+=X_sa[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

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

	for i := 1; i <= 1000; i++ {
		if 8*i/100 == a && 10*i/100 == b {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
 
using namespace std;
 
int main(void)
{
  int n;
  cin >> n;
  vector<string> f(n*2);
  REP(i,n) cin >> f[i];
  REP(i,n) f[i+n] = f[i];
  int answer = 0;
  REP(d,n) {
    bool flag = true;
    REP(i,n) REP(j,n)
      if(f[i+d][j] != f[j+d][i]) flag = false;
    if(flag) answer+= n;
  }
  cout << answer << endl;
  return 0;
}

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

using namespace std;

template<typename T> T gcd(T a, T b) {
  return __gcd(a, b);
}

template<typename T> T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int main() {
  int a, b;
  while (cin >> a >> b) {
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }
}

Measured memory_bytes: 1160
use proconio::input;

fn main() {
    input! {
        n:usize,
        a:[u32;n]
    };

    let sum = a.iter().fold(0,|sum,&x| sum^x);
    
    let ans:Vec<u32> = a.into_iter().map(|x|x^sum).collect();

    for x in ans {
        print!("{} ",x);
    }
    
 
   
}

Measured memory_bytes: 5540
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int a[30],b[30],dp[31][1<<16];

int count(int bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(void){

  int n,c,in;

  while(cin >> n >> c,n|c){
    
    fill(a,a+n,0);
    fill(b,b+c,0);

    for(int i=0;i<n;i++){
      for(int j=0;j<16;j++){
	cin >> in;
	a[i] |= in<<(15-j);
      }
    }

    for(int i=0;i<c;i++){
      for(int j=0;j<16;j++){
	cin >> in;
	b[i] |= in<<15-j;
      }
    }

    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;

    for(int i=0;i<n;i++){
      for(int j=0;j<(1<<16);j++){
	if(dp[i][j]<0)continue;

	int now=a[i]|j;
	for(int k=0;k<c;k++){
	  int next=now & ~b[k];
	  dp[i+1][next]=max(dp[i+1][next],dp[i][j]+count(now & b[k]));
	}
      }
    }

    int ans=0;
    for(int i=0;i<(1<<16);i++){
      ans=max(ans,dp[n][i]);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 9104
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vLL vector<LL>
#define vpint vector<pair<int, int>>
#define vpLL vector<pair<LL, LL>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(n) \
    for (int i = 0; i < n; i++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long LU;
const LL mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i, j, n, x, y;
    cin >> n >> x >> y;
    int a[n+1][n+1], dis[20000]={0};
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n; j++)
        {
            a[i][j] = abs(i - j);
        }
    }
    a[x][y] = a[y][x] = 1;
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n; j++)
        {
            if (a[i][x] + a[x][j] < a[i][j])
            {
                a[i][j] = a[i][x] + a[x][j];
            }
        }
    }
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n; j++)
        {
            if (a[i][y] + a[y][j] < a[i][j])
            {
                a[i][j] = a[i][y] + a[y][j];
            }
        }
    }
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n; j++)
        {
            if (a[i][x] + a[x][j] < a[i][j])
            {
                a[i][j] = a[i][x] + a[x][j];
            }
        }
    }
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n; j++)
        {
            if (a[i][y] + a[y][j] < a[i][j])
            {
                a[i][j] = a[i][y] + a[y][j];
            }
        }
    }
    for (i = 1; i <= n; i++)
    {
        for (j = 1; j <= n; j++)
        {
            if (i > j)
            {
                dis[a[i][j]]++;
            }
        }
    }
    for (i = 1; i < n; i++)
    {
        cout << dis[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 16000
#include <iostream>
using namespace std;
int main(void){
    int height;
    int width;
 std::cin >>height;cin >> width;
 
 int circumference; int acreage;
 circumference= height*2+width*2;
 acreage= height*width;
 std::cout <<  acreage << " " << circumference << std::endl;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<array<int,2>> vii;
typedef vector<int> vi;
#define INF 1000000000
#define MOD 1000000007
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
int dp[1002][1002]; 
bool tr[1002][1002];
 
void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <=n; ++i) {
        for (int j = 1; j <= m; ++ j) {
            char c;
            cin >> c;
            if (c == '#') tr[i][j] = 1;
        }
    }
    if (!tr[1][1])
        dp[1][1] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (i == 1 && j == 1) continue;
            if (!tr[i][j]) {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[n][m] << "\n";
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

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

const int MAX_N = 2e5 + 10;
int n;
char c;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c;
		if (c == 'Y') {
			cout << "Four\n";
			return 0;
		}
	}

	cout << "Three\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc006_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  string p, s;
  cin >> p >> s;

  ll ans = 0;
  rep(i, N) {
    ll tmp = 0;
    rep(j, N - i) {
      if (p[i + j] == s[j]) {
        tmp++;
      } else {
        break;
      }
    }
    ans = max(ans, tmp);
  }

  cout << 2 * N - ans << endl;
}

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())
sum=0
m=min(x,y)
if(a+b>2*c):
    sum+=2*c*m
else:
    sum+=x*a+b*y
    print(sum)
    exit()
s=0
z=0
if x>y:s=a
else: s=b
sum+=min(2*c,s)*max(x-m,y-m)
print(sum)

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

namespace _0345
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x);
            if(x[0]==x[1]&&x[2]==x[3])
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
        }
    }
}

Measured memory_bytes: 9472
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	long long N;
	cin >> N;
	vector<long long> A(N);
	for (auto i = 1; i <= N; ++i)
	{
		cin >> A[i - 1];
		A[i - 1] -= i;
	}

	sort(A.begin(), A.end());

	auto result = 0ll;
	for (auto i = 1; i < N; ++i)
	{
		result += A[i] - A[0];
	}

	auto sum = result;
	for (auto i = 1; i < N; ++i)
	{
		auto diff = A[i] - A[i - 1];
		sum += diff * i;
		sum -= diff * (N - i);
		result = min(result, sum);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 1792
fun main() {
    val n = nextInt()
    val l = 9 * if (n % 7 == 0) {
        n / 7
    } else {
        n
    }
    var v = 10
    var count = 0
    repeat(n) {
        v %= l
        count++
        if (v == 1) {
            println(count)
            return
        }
        v *= 10
    }
    println(-1)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 34692
N,M = map(int, input().split())
Hs = list(map(int, input().split()))
i = 0
ABs = []
while True:
  if M <= i:
    break
  ABs.append(list(map(int, input().split())))
  i += 1
r = [0] * N

for A, B in ABs:
  if Hs[A-1] <= Hs[B-1]:
    r[A-1] = -1

  if Hs[B-1] <= Hs[A-1]:
    r[B-1] = -1

print(r.count(0))


Measured memory_bytes: 93388
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;

	writeln((A + B) % 24);
	stdout.flush();
	debug readln();
}

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

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	k--;
	vector<int> x;
	for(int i = a; i > 0; i--) {
		if (a % i == 0 && b % i == 0) {
			x.push_back(i);
		}
	}
	cout << x.at(k);
	return 0;
}

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

using namespace std;

char t[100005], used[100005];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int r, s, p;
	scanf("%d%d%d", &r, &s, &p);
	scanf("%s", t);
	
	long long res = 0;
	
	for (int i = 0; i < n; i++) {
		if (i - k >= 0) {
			if (t[i - k] == t[i]) {
				t[i] = '?';
				continue;
			}
			if (t[i] == 'r') res += p;
			else if (t[i] == 'p') res += s;
			else res += r;
		}
		else {
			if (t[i] == 'r') res += p;
			else if (t[i] == 'p') res += s;
			else res += r;
		}
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  string ans;
  string s;
  string t;
  int n;
  cin >> n;
  cin >> s >> t;
  rep_i(i, n){
    ans += string{s[i]};
    ans += string{t[i]};
  }
  say(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  if(x<0) x = -x;
  if(x/d>=k) {
    cout << x - k*d << endl;
    return 0;
  }
  if((x/d)%2==k%2) cout << x%d << endl;
  else cout << d-x%d << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;
int dx[] = {0,0,-1,1} ;
int dy[] = {-1,1,0,0} ;

void solve(){
	int n,m,k,x1,x2,y1,y2 ;
	cin >> n >> m >> k >> x1 >> y1 >> x2 >> y2 ;
	vector<vector<char>> a(n+1,vector<char>(m+1)) ;
	vector<vector<int>> d(n+1,vector<int>(m+1,INF)) ;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			cin >> a[i][j] ;
		}
	}
	queue<ii> Q ;
	Q.push({x1,y1}) ;
	d[x1][y1] = 0 ;
	while(!Q.empty()){
		int x = Q.front().first ;
		int y = Q.front().second ;
		Q.pop() ;
		for(int dir = 0 ; dir < 4 ; dir++){
			for(int i = 1 ; i <= k ; i++){
				int nx = x + dx[dir]*i ;
				int ny = y + dy[dir]*i ;
				if(nx<1||ny<1||nx>n||ny>m) break ;
				if(a[nx][ny] == '@') break ;
				if(d[nx][ny] <= d[x][y]) break ;
				if(d[nx][ny] > d[x][y]+1){
					d[nx][ny] = 1 + d[x][y] ;
					Q.push({nx,ny}) ;
				}
			}
		}
	} 	
	cout << (d[x2][y2] == INF ? -1 : d[x2][y2] ) ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
}


Measured memory_bytes: 28532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int c[26],i;
string d,res="yes";
int main(){
  for(cin>>d;i<d.size();i++){
    c[d[i]-'a']++;
    if(c[d[i]-'a']==2){
      res="no";break;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 768
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int x[100010],y[100010],c[100010],a[100010],b[100010];
int main(int argc,char** argv){
	int A,B,m;
	cin>>A>>B>>m;
	int ma=INF,mb=INF;
	rep(i,A){
		cin>>a[i];
		ma=min(ma,a[i]);
	}
	rep(i,B){
		cin>>b[i];
		mb=min(mb,b[i]);
	}
	int f=ma+mb;
	rep(i,m){
		cin>>x[i]>>y[i]>>c[i];
		int tot=a[x[i]-1]+b[y[i]-1]-c[i];
		f=min(f,tot);
	}
	cout<<f<<endl;
	return 0;
}

Measured memory_bytes: 2176
H,W = map(int, input().split())

ans = 0
if H == 1:
    ans = 1
elif W == 1:
    ans = 1
elif H % 2 == 1:
    ans = W * (H // 2) + (W+1) // 2
else:
    ans = W * (H // 2)

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll binpow(ll x,ll y){
    ll res=1;
    while(y>0){
        if(y&1)
            res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    cout<<binpow(2,floor(log2(n))+1)-1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>


using namespace std;


int main()
{
    char a, b;
    cin >> b;
    switch (b)
    {
        case 'A':
            a = 'T';
            break;
        case 'T':
            a = 'A';
            break;
        case 'C':
            a = 'G';
            break;
        case 'G':
            a = 'C';
            break;
            
        default :
            break;
    }
    cout << a << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc,char** argv) {
	int n;
	cin >> n;
	if(n % 10 == 9 || n / 10 == 9) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;

int main(){
	int num1[4],num2[4];
	while(cin>>num1[0]>>num1[1]>>num1[2]>>num1[3]>>num2[0]>>num2[1]>>num2[2]>>num2[3]){
		int h=0,b=0;
		for(int x=0;x<4;++x){
			for(int y=0;y<4;++y){
				if(num1[x]==num2[y])++b;
				if(x==y && num1[x]==num2[y])++h;
			}		
		}
		cout<<h<<" "<<b-h<<endl;
	}	
	return 0;
}	

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

int main() {
  int N;
  cin >> N;
  int t[110000], x[110000], y[110000];
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) cin >> t[i] >> x[i] >> y[i];

  bool can = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i + 1] - t[i];
    int dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dl) can = false;
    if (dt % 2 != dl % 2) can = false;
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define X first
#define Y second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define MAXN 100100

int n, m;
vector<int> g[MAXN];
vector<int> r[3];
int bio[MAXN];

void dfs(int cv, int x)
{//cout<<cv+1<<' '<<x<<endl;
  bio[cv] = 1;
  r[x].pb(cv);

  for (int i: g[cv]) {
    //cout<<i<<' ';
    if (!bio[i]) {
      //cout << cv + 1 << "->" << i + 1 << ' ' << x << endl;
      dfs(i, x);
      return;
    }
  }
}

int main()
{
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--; v--;
    g[u].pb(v);
    g[v].pb(u);
  }
  int ver = -1;
  for (int i = 0; i < n; i++) {
    if (g[i].size())
      ver = i;
  }
  dfs(ver, 1);
  for (int i: g[ver])
    if (!bio[i]) {
      dfs(i, 2);
      break;
    }
  printf("%d\n", r[1].size() + r[2].size());
  for (int i = r[2].size() - 1; i >= 0; i--)
    printf("%d ", r[2][i] + 1);
  for (int i: r[1])
    printf("%d ", i + 1);
  return 0;
}


Measured memory_bytes: 9848
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var I = G;
		int T = I[0], A = I[1];
		var H = G;
		T *= 1000;
		A *= 1000;
		var min = int.MaxValue;
		var ind = 0;
		for (int i = 0; i < N; i++)
		{
			var val = Abs(T - 6 * H[i] - A);
			if (val < min) { min = val; ind = i; }
		}
		WriteLine(ind + 1);
	}
}


Measured memory_bytes: 13340
#include <bits/stdc++.h>
using namespace std;
int main(){
  list<int> lst;
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string query;
  int key;
  list<int>::iterator itr;
  while(n--){
    cin >> query;
    if(query == "insert"){
      cin >> key;
      lst.push_front(key);
    }
    else if(query == "delete"){
      cin >> key;
      for(itr = lst.begin();itr != lst.end();itr++){
	if(*itr == key){lst.erase(itr);break;}
      }
    }
    else if(query == "deleteFirst")lst.pop_front();
    else if(query == "deleteLast")lst.pop_back();
  }
  for(itr = lst.begin();itr != --lst.end();itr++){
    cout << *itr << " ";
  }
  cout << *itr << endl;
  return 0;
}

Measured memory_bytes: 32476
n,k = map(int, input().split())
array = {}

for i in range(n):
  a,b = map(int, input().split())
  if a in array: #キーがある場合
    array[a] += b
  else:
    array[a] = b
    
#  キーの順番でソートする
array_sorted = sorted(array.items())

ans = 0
cnt = 0
# k番目が何かを確認する
for elem in array_sorted:
  cnt += elem[1]
    
  if cnt >= k:
    #ans = key
    print(elem[0])
    break

Measured memory_bytes: 14556
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <iostream>
#include <stack>
#include <string>
#include <unordered_set>
using namespace std;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n,a;
	cin>>n;
	unordered_set<int> exist;
	while(n){
		cin>>a;
		if(exist.find(a)==exist.end()){
			exist.insert(a);
		}else{
			exist.erase(a);
		}
		n--;
	}
	cout<<exist.size()<<endl;
	return 0;
}

Measured memory_bytes: 4388