akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;


int main(void)
{
    const vector<pair<int, int>> diffs =
        { make_pair(-1, 0), make_pair(0, -1), make_pair(0, 1), make_pair(1, 0) };

    int n;
    cin >> n;
    const int sq_n = n * n;
    vector<int> orders(sq_n);
    for (size_t i = 0; i < sq_n; i++)
    {
        cin >> orders[i];
    }
    
    auto rems = vector<vector<bool>>(n, vector<bool>(n, true));

    auto seats = vector<vector<int>>(n, vector<int>(n, 1));
    const int half_n = n / 2;
    for (size_t i = 1; i <= n / 2; i++)
    {
        for (size_t j = i; j < n - i; j++)
        {
            seats[i][j] = seats[n - 1 - i][j] = seats[j][i] = seats[j][n - 1 - i] = i + 1;
        }
    }
    
    
    ll ans = 0;
    for (auto &&order : orders)
    {
        int row = (order - 1) / n;
        int col = (order - 1) % n;

        ans += seats[row][col] - 1;

        rems[row][col] = false;
        
        if (row == 0 || row == n - 1 || col == 0 || col == n - 1)
        {
            seats[row][col] = 0;
        }
        else
        {
            ll min_cost = seats[row][col];
            for (auto &&diff : diffs)
            {
                const int nei_row = row + diff.first;
                const int nei_col = col + diff.second;
                
                if (0 <= row && row < n && 0 <= col && col < n)
                {
                    if (seats[nei_row][nei_col] < min_cost)
                    {
                        min_cost = seats[nei_row][nei_col];
                    }
                }
            }
            seats[row][col] = min_cost;
        }

        auto opening = queue<pair<int, int>>( { make_pair(row, col) } );
        while (!opening.empty())
        {
            const auto curr_pos = opening.front();
            opening.pop();
            
            for (auto &&diff : diffs)
            {
                const int next_row = curr_pos.first + diff.first;
                const int next_col = curr_pos.second + diff.second;

                if (!(0 <= next_row && next_row < n && 0 <= next_col && next_col < n))
                {
                    continue;
                }
                
                const int next_cost = seats[curr_pos.first][curr_pos.second] + rems[next_row][next_col];

                if (next_cost < seats[next_row][next_col])
                {
                    seats[next_row][next_col] = next_cost;
                    opening.push(make_pair(next_row, next_col));
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5296
import numpy as np
import warnings
warnings.filterwarnings('ignore')

Mv = 10 ** 5
Mw = 10 ** 11

N, W = list(map(int, input().split()))
w = np.array([0] * (N+1))
v = np.array([0] * (N+1))
for i in range(N):
    w[i+1], v[i+1] = map(int, input().split())

V = np.max(v)

# dp[i,j]:iまでのアイテムで価値がj以下の時の重さの最小値
dp = np.array([[Mw] * (Mv + 1)] * (N+1))
dp[0][0] = 0
for i in range(1, N+1):
    tmp_arr = np.full(Mv+1, Mw, dtype=int)
    tmp_arr[v[i]:] = dp[i-1][:-v[i]] + w[i]
    dp[i] = np.minimum(dp[i-1], tmp_arr)

print(np.max(np.where(dp[N] <= W, dp[N], 0).nonzero()))

Measured memory_bytes: 107860
/* Author darklight13 -_- 
   IIT Patna 
*/
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey! ";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;

int32_t main()
{
	SYNC
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin >> k;
	cout << a[k-1];
    return 0;
}

Measured memory_bytes: 256
import sys
import time
import math
sys.setrecursionlimit(20000)
def update(tree,x,y,N):
    # offset
    #x += int(N/2)
    x += N - 1
    tree[x] = y
    # segment tree no update suru
    while True:
        if(x <= 0):
            break
        x = math.floor((x - 1)/2)
        left = x*2+1
        right = x*2+2
        tree[x] = min(tree[left],tree[right])

def find(tree,x,y,k,l,r):

    if (r <= x or y <= l):
        return 2**31 - 1
    # sita wo mite itte mitukatta toki (intersect)
    if ( x <= l and r <= y):
        return tree[k]
    # sita ni sagaru
    v_left = find(tree, x, y, k*2 + 1, l, int((l+r)/2))
    v_right = find(tree, x, y, k*2 + 2, int((l+r)/2), r)
    return min(v_left, v_right)

if __name__ == '__main__':
    _N,query_num = map(int, input().split())
    INT_MAX = 2**31 - 1
    N = 1
    while True:
        if(N >= _N):
            break
        N *= 2
    #N = 2*N - 1 - 1
    if not (N == 1):
        A_bin_tree = [INT_MAX]*(2*N - 1)
    else:
        A_bin_tree = [INT_MAX]
    #start = time.time()
    for i in range(query_num):
        operate,x,y = map(int, input().split())
        # update
        if(operate==0):
            update(A_bin_tree,x,y,N)
            #print(A_bin_tree)
        # find
        if(operate==1):
            # tyouten kara miteiku
            z = find(A_bin_tree,x,y+1,0,0,N)
            print(z)
    #elapsed_time = time.time() - start
    #print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")



Measured memory_bytes: 8792
import numpy as np
from itertools import permutations
import math

n = int(input())

li = []
for _ in range(n):
    i, j = map(int, input().split())
    li.append(np.array([i, j]))

li2 = permutations(li)

re = []
for a in li2:
    dis = 0 
    for (x1,y1),(x2,y2) in zip(a,a[1:]):
        dis += math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
    re.append(dis)

print(np.average(re))


Measured memory_bytes: 13772
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int r=sc.nextInt();
        int d=sc.nextInt();
        int x[]=new int[11];
        x[0]=sc.nextInt();
        for(int i=0; i<10; i++){
            x[i+1]=r*x[i]-d;
            System.out.println(x[i+1]);
        }
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb emplace_back
#define mp make_pair
const ll MOD=1e9+7;
using vi=vector<ll>;
struct Union_Find{
    ll N;
    vi par;
    Union_Find(int n):N(n){
        par.resize(N);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
    }
};
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll N,M,X; cin>>N>>M>>X;
    vector<tuple<ll,ll,ll>> edge(M);
    rep(i,0,M){
        ll X,Y,Z; cin>>X>>Y>>Z;
        edge[i]=make_tuple(Z,X,Y);
    }
    sort(ALL(edge));
    vi memo(M);
    rep(i,0,M){
        ll x,y,z; std::tie(x,y,z)=edge[i];
        memo[i]=x;
        Union_Find tree(N);
        tree.unite(z-1,y-1);
        rep(j,0,M){
            ll X,Y,Z; std::tie(Z,X,Y)=edge[j];
            if(!tree.same(X-1,Y-1)){
                memo[i]+=Z;
                tree.unite(X-1,Y-1);
            }
        }
    }
    sort(ALL(memo));
    ll ans=0;
    rep(i,1,M){
        if(memo[i]==X){
            ans+=modpow(2,M-i-1,MOD);
            ans%=MOD;
        }
    }
    ans*=2;
    ans%=MOD;
    cout<<ans<<endl;
}


Measured memory_bytes: 3664
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
memo = [10**10]*(H+1)
memo[0] = 0
i = 0
while i <= H:
  for a, b in AB:
    memo[i] = min(memo[i], b+memo[max(0, i-a)])
  i += 1
print(memo[H])



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

using namespace std;
int main(){
  int n,m;
   cin >>n >> m;
  
   long res=1;
  for(int i=0;i<m;i++) res*=2;
  
  res*=(1900*m+100*(n-m));
  
cout << res << endl;

  
    
  
}


Measured memory_bytes: 256
// atcoder/abc054/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, ma, mb;
  while (cin >> n >> ma >> mb) {
    using T = struct{
      int a, b, c;
    };
    vector<T> v(n);
    each (i, v) cin >> i.a >> i.b >> i.c;

    const int N = 40 + 5;
    const int M = (N * 10) + 5;
    static int dp[N][M][M];
    const int inf = 1 << 29;
    fill(&dp[0][0][0], &dp[N - 1][M - 1][M - 1] + 1, inf);
    dp[0][0][0] = 0;
    for (int i = 0; i < v.size(); ++i) {
      for (int j = 0; j < M; ++j) {
        for (int k = 0; k < M; ++k) {
          setmin(dp[i + 1][j][k], dp[i][j][k]);
          int p = j + v[i].a;
          int q = k + v[i].b;
          if (max(p, q) < M) {
            setmin(dp[i +  1][p][q], dp[i][j][k] + v[i].c);
          }
        }
      }
    }
    int x = inf;
    for (int i = 1; max(ma, mb) * i < M; ++i) {
      setmin(x, dp[n][ma * i][mb * i]);
    }
    cout << (inf == x ? -1 : x) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 36608
#include<stdio.h>

#define MAX                     (100000)

#define ABS(NUM)                ((NUM>0)?(NUM):((-1)*(NUM)))
#define MIN(NUM1, NUM2)         ((NUM1>NUM2)?(NUM2):(NUM1))

int main(void)
{
        int n, k, h[MAX]={};
        int i, j;
        int step[MAX]={};

        scanf("%d %d", &n, &k);
        for(i=0; i<n; i++)
                scanf("%d", &h[i]);

        for(i=1; i<n; i++){
                step[i] = 0x7FFFFFFF;
                for(j=1; j<=k; j++){
                        if( (i-j) < 0) break;
                        step[i] = MIN( (ABS(h[i]-h[i-j])+step[i-j]), step[i] );
                }
        }
        printf("%d\n", step[--i]);

        return (0);
}


Measured memory_bytes: 896
#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 pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll n;
int main(){
    cin>>n;
    cout<<n*(n-1)/2<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll total = 1LL;
  for (int i = 0; i < n; i++) {
    total *= 3LL;
  }

  ll odd = (a[0] & 1) ? 1 : 2;
  for (int i = 1; i < n; i++) {
    if (a[i] & 1) {
      odd *= 1;
    } else {
      odd *= 2;
    }
  }
  cout << total - odd << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(n: int, a: int, b: int):
    al = modPow(2, n, MOD) - 1
    # aに対して
    X = 1
    # 分子
    for i in range(a):
        X = (X * (n - i)) % MOD
    Y = 1
    # Y
    for i in range(a):
        Y = (Y * (a - i)) % MOD
    a_val = (X * modPow(Y, MOD - 2, MOD)) % MOD

    # bに対して
    X = 1
    # 分子
    for i in range(b):
        X = (X * (n - i)) % MOD
    Y = 1
    # Y
    for i in range(b):
        Y = (Y * (b - i)) % MOD
    b_val = (X * modPow(Y, MOD - 2, MOD)) % MOD

    print((al - a_val - b_val) % MOD)


def modPow(a: int, n: int, p: int):
    if n == 1:
        return a
    elif n % 2 == 0:
        n2 = modPow(a, n / 2, p)
        return pow(n2, 2) % p
    else:
        return (a * modPow(a, n - 1, p)) % p


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double p[n+1];
    for(int i = 1; i <= n; i++)
    cin >> p[i];
    double dp[n+1][n+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
    {
        dp[0][i] = (1-p[i])*dp[0][i - 1];
        for(int heads = 1; heads <= i; heads++)
        dp[heads][i] = p[i]*dp[heads - 1][i - 1] + (1-p[i])*dp[heads][i-1];
    }
    double ans = 0;
    for(int i = n/2 + 1; i <= n; i++)
    ans += dp[i][n];
    cout << setprecision(9) << ans;
    return 0;
}

Measured memory_bytes: 70528
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a); i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin >> s;
	int memo = 0;
		rep(i,1,s.size()){
			if(s[i-1] != s[i]){
				memo++;
			}
			
		}
	
	cout << memo << endl;
	return 0;
}

Measured memory_bytes: 512
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 2005;

int n, m, ans;
int l[maxn][maxn], r[maxn][maxn], u[maxn][maxn], d[maxn][maxn];
char s[maxn][maxn];

int main(){
	scanf("%d%d", &n, &m);
	FOR(i, 0, n) scanf("%s", s + i);
	FOR(i, 0, n) FOR(j, 0, m){
		if(s[i][j] == '#')
			l[i][j] = 0;
		else{
			if(j)
				l[i][j] = l[i][j - 1] + 1;
			else
				l[i][j] = 1;
		}
	}
	for(int i = n - 1; i >= 0; --i) FOR(j, 0, m){
		if(s[i][j] == '#')
			d[i][j] = 0;
		else{
			if(i != n - 1)
				d[i][j] = d[i + 1][j] + 1;
			else
				d[i][j] = 1;
		}
	}
	FOR(i, 0, n) FOR(j, 0, m){
		if(s[i][j] == '#')
			u[i][j] = 0;
		else{
			if(i)
				u[i][j] = u[i - 1][j] + 1;
			else
				u[i][j] = 1;
		}
	}
	FOR(i, 0, n) for(int j = m - 1; j >= 0; --j){
		if(s[i][j] == '#')
			r[i][j] = 0;
		else{
			if(j != m - 1)
				r[i][j] = r[i][j + 1] + 1;
			else
				r[i][j] = 1;
		}
	}
	FOR(i, 0, n) FOR(j, 0, m) ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
	printf("%d\n", ans);
	return 0;
}



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

int main(){
    int a,b,c,tmp;
    cin>>a>>b>>c;
    if(a>b){
      tmp=a;
      a=b;
      b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
      tmp=a;
      a=b;
      b=tmp;
    }
    cout <<a<<" "<<b<<" "<<c<<"\n";
    return 0;
}

Measured memory_bytes: 3056
_int = int(input())
_list = []
_bool = 0
for i in range(_int):
  _list_element = list(map(int, input().split()))
  _list.append(_list_element[0])
  _list.append(_list_element[1])
  

for i in range(1, 2*_int - 4, 2):
  #index 1　から index 2*_intまで2ずつ繰り返す(1組の最後の数)
  if _list[i] == _list[i -1]:
    if _list[i + 2] == _list[i + 1]:
      if _list[i + 4] == _list[i + 3]:
        _bool += 1

if _bool >= 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9196
W, H, x, y, r = map(int, input().split())

x_lower = x - r
x_upper = x + r

y_lower = y - r
y_upper = y + r

if x_lower >= 0 and y_lower >= 0 and x_upper <= W and y_upper <= H:
    print('Yes')
else:
    print('No')



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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

vector<ll> f((int)(1e7)+1,1);
// template <typename T>
// map<T, T> get_prime(T n) {
//   map<T, T> prime;
//   T num = n;
//   for (T i = 2; i * i < n; i++) {
//     while (num % i == 0) {
//       prime[i]++;
//       num /= i;
//     }
//   }
//   if (num > 1) prime[num]++;

//   return prime;
// }
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin>>n;
reps(i,n+1,2){
    int k=i;
    while(k<=n){
        f[k]++;
        k+=i;
    }
}
ll ans=0;
reps(k,n+1,1){
    ans+=k*f[k];
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 81252
#include <iostream>
#include <string>
using namespace std;
 
 
int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int B[M];
    int A[N][M];
    int all=0;
    int ans=0;
 

 
    for(int i=1;i<=M;i++){
        cin >> B[i];
    }
    for(int i=1;i<=N;i++){
      all=0;
        for(int j=1;j<=M;j++){
            cin >> A[i][j];
            all +=A[i][j]*B[j];
        }
        if(all+C >0)ans++;
    }
 
    cout<<ans;
 
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

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

	cout << ((a+b==c||b+c==a||c+a==b)?"Yes":"No") << endl;
	return 0;
}

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

#define db(x) //cerr << #x << " == " << x << endl
#define all(container) container.begin(), container.end()
#define mp(i,j) make_pair(i,j)
#define pb push_back

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vii;

template<typename T>
void print_vector_debug(const T& t) {
	cout << "[DEBUG] VECTOR:";
	for (auto i = t.cbegin(); i != t.cend(); ++i) {
		if ((i + 1) != t.cend()) {
			cout << *i << " ";
		} else {
			cout << *i << endl;
		}
	}
}

#define MAXN 105
#define MAXV 100005
#define INF (ll)20000000000000000LL

ll N, W;
ll v[MAXN], w[MAXN];
int vis[MAXN][MAXV];
ll dp[MAXN][MAXV];

ll solve_dp(int idx, ll r)
{
	if (idx == N)
	{
		return r <= 0 ? 0:INF;
	}
	
	if (r <= 0)
	{
		return 0;
	}
	
	if (vis[idx][r])
	{
		return dp[idx][r];
	}
	vis[idx][r] = 1;
	
	ll res = min(solve_dp(idx + 1, r), solve_dp(idx + 1, r - v[idx]) + w[idx]);
	dp[idx][r] = res;
	
	return res;
}

ll solve()
{
	for (int i = MAXV - 1; i >= 0; i--)
	{
		if (solve_dp(0, i) <= W)
		{
			return i;
		}
	}
	
	return 0;
}

int main() 
{
	scanf("%lld%lld", &N, &W);
	
	for (int i = 0; i < N; i++)
	{
		scanf("%lld%lld", &w[i], &v[i]);
	}
	
	printf("%lld\n", solve());
	
	return 0;
}


Measured memory_bytes: 120960
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
long long counter;
counter=1;
long long counter1;
counter1=1;
long long N,x;
cin>>N>>x;
if(N>x){
for(long long i=1;i<=x;i++){
counter1=((COM(N-1,N-1-i)*COM(N,i))%(1000000007)+counter1)%(1000000007);
}
cout<<counter1<<endl;}
else{
for(long long i=1;i<=N-1;i++){
counter1=((COM(N-1,N-1-i)*COM(N,i))%(1000000007)+counter1)%(1000000007);
}
cout<<counter1<<endl;}
}


Measured memory_bytes: 12160
N = int(input())

A = list(map(int, input().split()))

dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

dic2 = {}
sum_ = 0
for key, val in dic.items():
    if val < 2:
        dic2[key] = (0, 0)
    elif val == 2:
        dic2[key] = (1, 0)
        sum_ += 1
    else:
        x = int((val * (val - 1)) / 2)
        val -= 1
        y = int((val * (val - 1)) / 2)

        dic2[key] = (x, y)
        sum_ += x

for k in range(N):
    t = A[k]

    print(sum_ - dic2[t][0] + dic2[t][1])


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

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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      n: usize,
      w: usize,
      wvs: [(usize, usize); n],
    }
    let w1 = wvs[0].0;
    let mut tbl = vec![vec![]; 4];
    for &(w, v) in wvs.iter() {
        tbl[w-w1].push(v);
    }
    for i in 0..4 {
        tbl[i].sort();
        tbl[i].reverse();
    }

    let mut ans = 0;
    for i in 0..tbl[0].len()+1 {
        for j in 0..tbl[1].len()+1 {
            for k in 0..tbl[2].len()+1 {
                for l in 0..tbl[3].len()+1 {
                    let cur_w = w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l;
                    if cur_w > w {
                        continue;
                    }
                    let mut v: usize = 0;
                    v += (&tbl[0][0..i]).iter().map(|&v| v).sum();
                    v += (&tbl[1][0..j]).iter().map(|&v| v).sum();
                    v += (&tbl[2][0..k]).iter().map(|&v| v).sum();
                    v += (&tbl[3][0..l]).iter().map(|&v| v).sum();
                    ans = max(ans, v);
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys, bisect
input = sys.stdin.readline
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]
inf = 10 ** 18

s = [-inf] + s + [inf]
t = [-inf] + t + [inf]

ans_Q = [None] * Q
i_last = j_last = 0
for idx, x_tmp in sorted(enumerate(x), key=lambda x: x[1]):
    i_l = max(0, bisect.bisect_left(s, x_tmp, lo=i_last) - 1)
    j_l = max(0, bisect.bisect_left(t, x_tmp, lo=j_last) - 1)
    # print("#", x_tmp, (i_l, s[i_l]), (j_l, t[j_l]))
    #
    ans = inf
    for i, j in ((i_l, j_l), (i_l + 1, j_l), (i_l, j_l + 1), (i_l + 1, j_l + 1)):
        if i < 1 or A < i: continue
        if j < 1 or B < j: continue
        ans_tmp_s = abs(x_tmp - s[i]) + abs(s[i] - t[j])
        ans_tmp_t = abs(x_tmp - t[j]) + abs(s[i] - t[j])
        ans_tmp = min(ans_tmp_s, ans_tmp_t)
        # print("#", x_tmp, s[i], t[j], ans_tmp)
        if ans > ans_tmp:
            ans = ans_tmp
    #
    i_last, j_last = i_l, j_l
    ans_Q[idx] = ans

for ansi in ans_Q: print(ansi)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(17);

	int n;
	cin >> n;

	ld p[n+1];
	FOR(i,1,n) {
		cin >> p[i];
	}

	ld dp[n+1][n/2+1];
	fill(dp[0], dp[0]+n/2+1, 0);
	dp[0][0] = 1;
	FOR(i,1,n) {
		For(j,n/2+1) {
			dp[i][j] = dp[i-1][j] * p[i];
			if (j>0) dp[i][j] += dp[i-1][j-1] * (1-p[i]);
		}
	}

	ld ans = 0;
	For(j,n/2+1) {
		ans += dp[n][j];
	}
	cout << ans << nl;

	return 0;
}


Measured memory_bytes: 70656
#include<iostream>
#include<map>

using namespace std;
const int MOD = 1e9 + 7;

int N;
int order[100005];

long long pow(long long x, int n) {
    long long res = 1;
    while (0 < n) {
        if(n % 2 != 0)
            res = res * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return res;
}

int main() {
    cin >> N;
    int num;
    int d = (N - 1) % 2;
    for (int i = 0; i < N; i++){
        cin >> num;
        order[num]++;

        if(num % 2 != d || order[num] > 2 || order[0] > 1) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << pow(2, N / 2) << endl;
    return 0;
}

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

bool comp_second(const pair<long long,long long>& a,const pair<long long,long long>& b){
	if(a.second!=b.second)return a.second>b.second;
	else return a.first<b.first;
}

int main(){
	long long N,K;
	cin >> N >> K;
	vector<pair<long long ,long long>> sushi;
	vector<long long> sum(N+1,-12345678987654321);
	vector<long long> exist(N,0);
	
	for(long long i=0;i<N;i++){
		long long t,d;
		cin >> t >> d;
		pair<long long,long long> p={t,d};
		sushi.push_back(p);
		exist[t-1]=1;
	}
	
	sort(sushi.begin(),sushi.end(),comp_second);
	
	priority_queue<long long,vector<long long>,greater<long long>> que;
	long long max_val=min(K,accumulate(exist.begin(),exist.end(),0LL));
	
	long long s=0;
	fill(exist.begin(),exist.end(),0);
	for(long long i=0;i<K;i++){
		s+=sushi[i].second;
		if(exist[sushi[i].first-1]==1){
			que.push(sushi[i].second);
		}
		exist[sushi[i].first-1]=1;
	}
	long long min_val=accumulate(exist.begin(),exist.end(),0LL);
	sum[min_val]=s;
	
	long long j=K-1;
	for(long long i=min_val+1;i<=max_val;i++){
		s-=que.top();
		que.pop();
		while(1){
			j++;
			if(exist[sushi[j].first-1]==0){
				s+=sushi[j].second;
				exist[sushi[j].first-1]=1;
				sum[i]=s;
				break;
			}
		}
	}
	
	long long ans=0;
	for(long long i=min_val;i<=max_val;i++){
		long long add=i*i;
		sum[i]+=add;
		ans=max(sum[i],ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4208
import java.util.*;

class B {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int K = sc.nextInt();
        final char[][] P = new char[N][];
        for (int i = 0; i < P.length; i++)
            P[i] = sc.next().toCharArray();
        final int[] cnts = new int[26];
        for (int i = 0; i < N; i++)
            cnts[P[i][0] - 'A']++;
        int ans = 0;
        while (true) {
            Arrays.sort(cnts);
            if (cnts[26 - K] == 0)
                break;
            for (int i = 26 - K; i < 26; i++)
                cnts[i]--;
            ans++;
        }
        System.out.println(ans);
    }
}

public class Main {
    public static void main(String... args) {
        B.main();
    }
}

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

int main() {
  int x1;
  cin >> x1;
  int x2;
  cin >> x2;
  int x3;
  cin >> x3;
  int x4;
  cin >> x4;
  int x5;
  cin >> x5;
  if (x1 == 0) {
    cout << 1;
  }else if (x2 == 0){
    cout << 2;
  }else if (x3 == 0){
    cout << 3;
  }else if (x4 == 0){
    cout << 4;
  }else if (x5 == 0){
    cout << 5;
  }
	return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string s;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> s;
  int t = 0;
  rep(i, s.length()) {
    if (t == 0 && s[i] == 'C') t = 1;
    else if (t == 1 && s[i] == 'F') t = 2;
  }
  cout << (t==2?"Yes":"No")<<"\n";
  return 0;
}


Measured memory_bytes: 256
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  x, a = map(int, readline().split())
  if x<a:
    print(0)
  else:
    print(10)
  
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
const ld EPS=1e-6;
class Combination{
private:
    vvi dat;
public:
    Combination(int size){
        size++;
        dat.resize(size);
        REP(i,size){
            dat[i].resize(size);
        }
        dat[0][0]=1;
        REP(i,size-1){
            REP(j,size-1){
                dat[i+1][j]+=dat[i][j];
                dat[i+1][j+1]+=dat[i][j];
            }
        }
    }
    int Comb(int n,int r){
        if(r>n){
            return 0;
        }
        return dat[n][r];
    }
};
signed main(){
    cout<<fixed<<setprecision(10);
    cerr<<fixed<<setprecision(10);
    int n,a,b;
    cin>>n>>a>>b;
    vi vec(n);
    Combination C(n+1);
    map<int,int> ma;
    REP(i,n){
        cin>>vec[i];
        ma[vec[i]]++;
    }
    sort(all(vec),greater<double>());
    ld sum=0.0;
    ld ans;
    REP(i,a){
        sum+=vec[i];
    }
    ans=sum/a;
    FOR(i,a,b){
        sum+=vec[i];
        ans=max(ans,sum/(i+1));
    }
    cout<<(double)ans<<endl;
    sum=0.0;
    int r=0;
    REP(i,a-1){
        sum+=vec[i];
        if(vec[r]!=vec[i]){
            r=i;
        }
    }
    int cnt=0;
    FOR(i,a-1,b){
        sum+=vec[i];
        if(vec[r]!=vec[i]){
            r=i;
        }
        if(abs(ans-sum/(i+1))<=EPS){
            cnt+=C.Comb(ma[vec[i]],i-r+1);
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n;
    cin >> n;
    int ret = 0;
    while (n > 1) {
        int tmp = n % 3;
        n /= 3;
        if (tmp) {
            n++;
        }
        ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3080
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, 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; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
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 S = RD!string;

	long ans, cnt;
	foreach (c; S)
	{
		if (c == 'A' || c == 'C' || c == 'G' || c == 'T')
		{
			++cnt;
		}
		else
		{
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  vector<string> s(n);
  vector<int> t(n+1);
  rep(i, 0, n) cin >> s.at(i) >> t.at(i);
  
  string x; cin >> x;
  int ans = 0;
  int y = n;
  rep(i, 0, n) {
    if(s.at(i) == x)
      y = i +1;
  }
  
  for(int i = y; i < n; i++) {
    ans += t.at(i);
  }
  
  cout << ans << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    string n;
    cin >> n;
    if (n[0] == n[1] && n[1] == n[2]) {
        cout << "Yes" << endl;
    }else if(n[1] == n[2] && n[2] == n[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

typedef long long int64;

const int MAXN = 50 + 10;

int n;
int64 a[MAXN];

inline int randint(int l, int r) {
	static unsigned seed;
	return (seed = (seed * 31 + 998244353) % 1000000007) % (r - l + 1) + l;
}

int main() {
	int i, k;
	int64 l, r, mid, ans = 0;
	
	scanf("%d", &n);
	for(i=1; i<=n; i++)
		scanf("%lld", &a[i]);
	
	std::sort(a+1, a+1+n);
	while(a[n] >= n) {
		k = n;
		while(k > 1 and a[n] - n < a[k - 1] + 1)
			k--;
		l = 0;
		r = std::max(0LL, (a[k]-n) / k - 2); // (a[n] - n)/k >= t
		if(k == 1) 
			l = r;
		else {
			while(l ^ r) {
				mid = (l + r + 1) >> 1;
				if(a[k - 1] + mid * (n - k + 1) <= a[k] - mid * k)
					l = mid;
				else
					r = mid - 1;
			}
		}
		
		if(l) {
			for(i = 1; i < k; i++) 
				a[i] += l * (n - k + 1);
			for(i = k; i <= n; i++)
				a[i] -= l * k;
			ans += l * (n - k + 1);
		}
		
		k = randint(1, 5);
		while(k and a[n] >= n) {
			for(i = 1; i < n; i++)
				a[i]++;
			a[n] -= n;
			ans++;
			k--;
			std::sort(a+1, a+1+n);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[30][(1<<21) + 10];

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

  int n;
  cin >> n;

  vector<vector<int>> a(n, vector<int>(n));
  rep(i, n) rep(j, n) cin >> a[i][j];
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int s = 0; s < (1<<n); s++) {
      if (dp[i][s].x != 0) {
        for (int j = 0; j < n; j++) {
          if (!(s & (1 << j)) && a[i][j]) dp[i+1][s | (1<<j)] += dp[i][s];
        }
      }
    }
  }

  cout << dp[n][(1<<n)-1].x << endl;

  return 0;
}


Measured memory_bytes: 491776
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main(){ 
    int a, b, x; cin >> a >> b >> x;
    if(a+b<x || a>x) cout << "NO" << ln;
    else cout << "YES" << ln;
}

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

int main(){
  string s;
  cin >> s;
  string res;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '0'){
      res.push_back('0');
    }
    else if(s[i] == '1'){
      res.push_back('1');
    }
    else{
      if(res.size() > 0){
        res.pop_back();
      } 
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
 
public class node
{
    public node parent;
    public node rightChild;
    public node leftChild;
    public int key;
}
 
public class Test
{
    public static int[] preorderKey, inorderKey;
    public static int precount, incount;
     
    public static void Main()
    {
 
        int n = int.Parse(Console.ReadLine());
        List<node> tree = new List<node>();
         
        for(int i = 0; i < n ; i++) {
            string[] atom = Console.ReadLine().Split(" ".ToCharArray());
             
            switch(atom[0][0]){
                case 'i':
                    Insert(int.Parse(atom[1]), tree);
                    break;
				
				case 'f':
					Console.WriteLine( Find( int.Parse(atom[1]), tree[0])? "yes" : "no" );
					break;
                 
                case 'p':
                    Print(tree.ToArray());
                    break;
            }
        }
    }
     
    public static void Insert(int v ,List<node> T)
    {
        node y = null;
        
        node z = new node();
		z.key = v;
		T.Add(z);
        
        if(T.Count == 1) return;
        node x = T[0];
 
        while(x != null) {
            y = x;
            if(v < x.key) x = x.leftChild;
            else x = x.rightChild;
        }
        z.parent = y;
         
        if(y == null) {
            
        } else if (v < y.key) {
            y.leftChild = T[T.Count - 1];
        } else {
            y.rightChild = T[T.Count - 1];
        }
    }
	
	public static bool Find(int v, node x)
	{
		while(x != null) {
			if(x.key == v) return true;
			else if(v < x.key) x = x.leftChild;
			else x = x.rightChild;
		}
		
		return false;
	}
 
    public static void Print(node[] T)
    {
        preorderKey = new int[T.Length];
        inorderKey = new int[T.Length];
        precount = 0;
        incount = 0;
         
        node root = T[0];
        Inorder(root, T);
        Preorder(root, T);
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < T.Length; i++) {
            sb.Append(" " + inorderKey[i]);
        }
        Console.WriteLine(sb.ToString());
        sb = new StringBuilder();
        for(int i = 0; i < T.Length; i++) {
            sb.Append(" " + preorderKey[i]);
        }
        Console.WriteLine(sb.ToString());
         
    }
     
    public static void Preorder(node t, node[] tree)
    {
        preorderKey[precount++] = t.key;
        if(t.leftChild != null) Preorder(t.leftChild, tree);
        if(t.rightChild != null) Preorder(t.rightChild, tree);
    }
     
    public static void Inorder(node t, node[] tree)
    {
        if(t.leftChild != null) Inorder(t.leftChild, tree);
        inorderKey[incount++] = t.key;
        if(t.rightChild != null) Inorder(t.rightChild, tree);
    }
     
    public static node GetRoot(node[] T)
    {
        if ( T ==  null ) return null;
        if ( T.Length == 0) return null;
         
        node u = T[0];
        while(u.parent != null) {
            u = u.parent;
        }
         
        return u;
    }
}

Measured memory_bytes: 76536
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int cnt[31];
int n;

int main(void) {

  REP(i, 1, 30 + 1) {
    cnt[i] = 0;
  }

  REP(i, 1, 28 + 1) {
    cin >> n;
    cnt[n] = 1;
  }

  REP(i, 1, 30 + 1) {
    if(cnt[i] == 0) {
      cout << i << endl;
    }
  }

  return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    for(int i=0; i<s.size(); i++){
        string r = s.substr(i) + s.substr(0,i);
        if(r == t){
            cout << "Yes"<< endl;   
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n, k;
	cin >> n >> k;

	rep(i, k) {
		int a, b;
		cin >> a >> b;

		a--;
		b--;

		if(a > n / 2) {
			a = n - 1 - a;
		}

		if(b > n / 2) {
			b = n - 1 - b;
		}

		// cout << a << " " << b << endl;
		if(a > b) {
			cout << b % 3 + 1 << endl;
		} else {
			cout << a % 3 + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
    char x,y;
	cin>>x>>y;
	if (x>y)
		cout<<">"<<endl;
	else
    {
        if (x==y)
		  cout<<"="<<endl;
        else 
          cout<<"<"<<endl;
	}
    system("pause");
    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	int x; int good = 0, bad = 0;
	for (int i = 0; i < N; i++) {
		cin >> x;
		if (x % 4 == 0)good++;
		else {
			if (x % 4 == 1 || x % 4 == 3)bad++;
		}
	}
	if (good >= bad)cout << "Yes";
	else {
		if (good == bad - 1) {
			if (good + bad == N)cout << "Yes";
			else cout << "No";
		}
		else cout << "No";
	}
    return 0;
}



Measured memory_bytes: 256