akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,D;
    cin >> A >>B;
    C=B/2;
    D=0;
    if(A>=13) cout <<B;
    else if(A<13&&A>5)cout << C;
    else cout <<D;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <stdio.h>
#define ll long long
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define vvvb vector<vector<vector<bool> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define rep1(i,a) for(ll i = 1;i<a;++i)
#define rrep(i,a) for(ll i = a;i>=0;--i)
#define mod 1000000007
#define inf 10010010010
using namespace std;

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

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

int main(){

    int n;
    cin >> n;
    int A = 0, V = -1;
    for(int i = 0; i < n; i++){
        int a, v;
        cin >> a >> v;
        if(v > V){
            A = a;
            V = v;
        }
        if(v == V && a < A){
            A = a;
            V = v;
        }
    }
    cout << A << " " << V << endl;

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    string W; cin >> W;
    string T = W;
    int ans = 0;
    sort(W.begin(),W.end());
    REP(i,N) if(T[i] != W[i]) ans++;
    cout << ans/2 << endl;
}

Measured memory_bytes: 3924
#include <stdio.h>

int main()
{
    int n, m, i, j, k, t;
    int a[100][100], b[100], c[100] = {0};

    scanf("%d %d\n", &n, &m);
    
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
 
    for(j = 0; j < m; j++)
    {
        scanf("%d\n", &b[j]);
    }

    for(i = 0; i < n; i++)
    {
        for(j = 0; j < m; j++)
        {
            c[i] += a[i][j] * b[j];
        }
    }

    for(i = 0; i < n; i++)
    {
        printf("%d\n", c[i]);
    }

    return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,r; cin >> n >> r;
    int ans=0;
    while(n){
        ans++;
        n/=r;
    }
    cout << ans << endl;
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

#define MOD 1000000007

int nxt, N, tmp;
string S;
ll dp[MAXN][13]={};

void print_table(){
    rep(i,N){
        rep(j,13){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}

void solve(){
    if(S[0]=='?'){
        rep(i, 10){
            dp[0][i] = 1;
        }
    } else {
        tmp = (int)(S[0]) - '0';
        dp[0][tmp] = 1;
        // cout << tmp << endl;
    }

    for(int i=1; i < N; ++i){
        rep(j, 13){
            if(S[i]!='?'){
                tmp = (int)(S[i]) - '0';
                nxt = (10*j + tmp) % 13;
                dp[i][nxt] += dp[i-1][j];
                dp[i][nxt] %= MOD;
            } else {
                rep(k, 10){
                    nxt = (10*j + k) % 13;
                    dp[i][nxt] += dp[i-1][j];
                    dp[i][nxt] %= MOD;
                }
            }
        }
    }

    // print_table();

    cout << dp[N-1][5] << endl;
}

int main(){
    cin >> S;
    N = S.length();

    solve();
}


Measured memory_bytes: 10624
S = input()[::-1]
P = 10**9+7
c = 1
X = [1]+[0]*12
for s in S:
    Y = [0] * 13
    if s == "?":
        for i in range(10):
            for j in range(13):
                Y[(c*i+j)%13] += X[j]
                Y[(c*i+j)%13] %= P
    else:
        for j in range(13):
            Y[(c*int(s)+j)%13] = X[j]
            
    X = Y
    c = c*10%13
 
print(X[5])

Measured memory_bytes: 43116
#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
#include<string>
using namespace std;

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
#define pb push_back
/////////////////

int const N = 2e5 + 41;
string const yes = "POSSIBLE";
string const no = "IMPOSSIBLE";

int n, m, a[N];
vector<int> e[N];
int order[N], cnt;
vector<int> c;
bool cyc[N];
int d[N];

void print(string s){
	cout << s << endl;
	exit(0);
}

int w[N];

void clearW(){
	fr(i, 0, N) w[i] = 0;
}

vector<int> st;

void findCyc(int u){
	st.pb(u);
	w[u] = 1;

	fr(i, 0, sz(e[u])){
		int to = e[u][i];
		if(!w[to]) findCyc(to);
		else{
			if(w[to] == 1){
				while(true){
					int v = st.back();
					st.pop_back();
					c.pb(v);
					if(v == to) break;
				}
			}
		}
	}

	w[u] = 2;
	if(sz(st) > 0 && st.back() == u) st.pop_back();
}

void dfs(int u){
	w[u] = 1;
	fr(i, 0, sz(e[u])){
		int to = e[u][i];
		if(w[to]) continue;
		dfs(to);
	}
	order[n-1-cnt] = u;
	++cnt;
}

int dfs1(int u){
	set<int> q;
	fr(i, 0, sz(e[u])){
		int to = e[u][i];
		if(cyc[to]) continue;
		assert(!w[to]);
		q.insert(dfs1(to));
	}
	fr(i, 0, N){
		if(q.find(i) == q.end()){
			return d[u] = i;
		}
	}
	assert(false);
	return 41;
}

bool check(){
	fr(i, 0, n){
		set<int> q;
		fr(j, 0, sz(e[i])){
			int to = e[i][j];
			q.insert(d[to]);
		}
		if(q.find(d[i]) != q.end()) return false;
		fr(j, 0, d[i]) if(q.find(j) == q.end()) return false;
	}
	return true;
}

int getFirst(int id){
	set<int> q;
	fr(i, 0, sz(e[id])){
		int to = e[id][i];
		q.insert(d[to]);
	}
	fr(i, 0, N){
		if(q.find(i) == q.end()) return i;
	}
	assert(false);
	return 41;
}

int getSecond(int id){
	int cnt = 0;
	set<int> q;
	fr(i, 0, sz(e[id])){
		int to = e[id][i];
		if(cyc[to]) continue;
		q.insert(d[to]);
	}
	fr(i, 0, N){
		if(q.find(i) == q.end()){
			++cnt;
			if(cnt == 2) return i;
		}
	}

	assert(false);
	return 41;
}

void solve(){
	cin >> n;
	fr(i, 0, n){
		int pi;
		cin >> pi;
		--pi;
		e[pi].pb(i);
	}

	clearW();
	fr(i, 0, n) if(!w[i]) findCyc(i);
	fr(i, 0, sz(c)) cyc[c[i]] = true;

	clearW();
	fr(i, 0, n) if(!w[i]) dfs(i);

	clearW();
	fr(i, 0, n) if(!w[order[i]]) dfs1(order[i]);

	fr(i, 1, sz(c)){
		d[c[i]] = getFirst(c[i]);
	}
	if(check()) print(yes);

	d[c[0]] = getSecond(c[0]);
	fr(i, 1, sz(c)){
		d[c[i]] = getFirst(c[i]);
	}
	if(check()) print(yes);
	else print(no);

}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	solve();

	return 0;
}

Measured memory_bytes: 24564
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Q;

int n;
int x[50];
int y[50];
Q sx[25];
Q sy[25];

ll gcd(ll a, ll b){
    return b == 0 ? a : gcd(b, a % b);
}

void make_q(ll p, ll q, Q& x){
    if(q < 0){
        p = -p;
        q = -q;
    }
    ll g = gcd(abs(p), q);
    x.first = p / g;
    x.second = q / g;
}

double eval_q(Q x){
    return double(x.first) / x.second;
}

void line_eq(int i, int j, ll& p, ll& q, ll& r){
    ll a = x[i];
    ll b = y[i];
    ll c = x[j];
    ll d = y[j];
    p = b - d;
    q = c - a;
    r = a * d - b * c;
}

void intersect(ll p0, ll q0, ll r0, ll p1, ll q1, ll r1, Q& x, Q& y){
    ll a = q0 * r1 - q1 * r0;
    ll b = p1 * r0 - p0 * r1;
    ll c = p0 * q1 - p1 * q0;
    make_q(a, c, x);
    make_q(b, c, y);
}

bool is_parallel(int i, int j, int k, int l){
    ll a = x[i] - x[j];
    ll b = y[i] - y[j];
    ll c = x[k] - x[l];
    ll d = y[k] - y[l];
    return a * d - b * c == 0;
}

bool solve(double& x, double& y){
    if(n % 2){
        return false;
    }

    int m = n / 2;
    
    rep(i, m){
        if(!is_parallel(i, i + 1, m + i, (m + i + 1) % n)){
            return false;
        }
    }

    rep(i, m){
        ll p0, q0, r0, p1, q1, r1;
        line_eq(i, m + i, p0, q0, r0);
        line_eq(i + 1, (m + i + 1) % n, p1, q1, r1);
        intersect(p0, q0, r0, p1, q1, r1, sx[i], sy[i]);
    }
    rep(i, m - 1){
        if(sx[i] != sx[m - 1] || sy[i] != sy[m - 1]){
            return false;
        }
    }
    x = eval_q(sx[0]);
    y = eval_q(sy[0]);
    return true;
}

int main(){
    cin >> n;
    rep(i, n){
        cin >> x[i] >> y[i];
    }

    double x, y;
    if(solve(x, y)){
        cout << fixed << setprecision(8) << x << ' ' << fixed << setprecision(8) << y << endl;
    }
    else{
        cout << "NA" << endl;
    }
    return 0;
}

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

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#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 fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.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))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7, N = 2e6 + 5;
vll fac(N, -1);
ll factorial(ll n)
{
    if (n == 0)
        return 1;
    return fac[n] == -1 ? fac[n] = (n * factorial(n - 1)) % mod : fac[n];
}
ll power(ll a, ll b, ll m = mod)
{
    if (b == 0)
    {
        return 1 % m;
    }
    ll u = power(a, b / 2, m);
    u = (u * u) % m;
    if (b % 2 == 1)
    {
        u = (u * a) % m;
    }
    return u;
}
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, ans = 0;
    cin >> k;
    string s;
    cin >> s;
    n = len(s);
    for (ll i = 0; i <= k; i++)
    {
        ll now = (power(25, i) * power(26, k - i)) % mod;
        ll com = (factorial(n + i - 1) * power((factorial(n - 1) * factorial(i)) % mod, mod - 2)) % mod;
        ans = (ans + (now * com) % mod) % mod;
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  rep(i,n+1) {
    int rest = n-i*100;
    if (0 <= rest && rest <= 5*i) {
      puts("1");
      return 0;
    }
    if (rest < 0) break;
  }
  puts("0");
  return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 10.01.2020 23:57:48       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, v;
  cin >> n >> v;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  vector<int> vs(1, v / 2);
  while (vs.back() > 0) {
    vs.push_back(vs.back() / 2);
  }
  int cnt = (int) vs.size();
  vector<pair<int, int>> segs;
  int beg = 0;
  while (beg < n) {
    int end = beg;
    while (end + 1 < n && x[end + 1] - x[end] <= v) {
      ++end;
    }
    segs.emplace_back(beg, end);
    beg = end + 1;
  }
  if ((int) segs.size() > cnt + 1) {
    for (int i = 0; i < n; i++) {
      cout << "Impossible" << '\n';
    }
    return 0;
  }
  vector<vector<int>> nxt(cnt, vector<int>(n + 1, n));
  vector<vector<int>> prv(cnt, vector<int>(n + 1, 0));
  for (int id = 0; id < cnt; id++) {
    for (int i = n - 1; i >= 0; i--) {
      if (i < n - 1 && x[i + 1] - x[i] > vs[id]) {
        nxt[id][i] = i + 1;
      } else {
        nxt[id][i] = nxt[id][i + 1];
      }
    }
    for (int i = 1; i <= n; i++) {
      if (i > 1 && x[i - 1] - x[i - 2] > vs[id]) {
        prv[id][i] = i - 1;
      } else {
        prv[id][i] = prv[id][i - 1];
      }
    }
  }
  vector<int> pref(1 << cnt, 0);
  for (int t = 0; t < (1 << cnt); t++) {
    for (int id = 0; id < cnt; id++) {
      if (!(t & (1 << id))) {
        pref[t | (1 << id)] = max(pref[t | (1 << id)], nxt[id][pref[t]]);
      }
    }
  }
  vector<int> suf(1 << cnt, n);
  suf[0] = n;
  for (int t = 0; t < (1 << cnt); t++) {
    for (int id = 0; id < cnt; id++) {
      if (!(t & (1 << id))) {
        suf[t | (1 << id)] = min(suf[t | (1 << id)], prv[id][suf[t]]);
      }
    }
  }
  for (auto& p : segs) {
    int from = p.first;
    int to = p.second;
    bool ok = false;
    for (int t = 0; t < (1 << cnt); t++) {
      ok |= (pref[t] >= from && suf[(1 << cnt) - 1 - t] <= to + 1);
    }
    for (int i = from; i <= to; i++) {
      cout << (ok ? "Possible" : "Impossible") << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 34160
use std::io::BufReader;
use std::io::BufRead;
use std::io;

fn main() {
    let reader = io::stdin();
    let mut reader = BufReader::new(reader.lock());

    let mut s = String::new();

    let _ = reader.read_line(&mut s);
    let rate: u32 = s.trim().parse().unwrap();
    if rate < 1200 {
        println!("ABC");
    } else if rate < 2800 {
        println!("ARC");
    } else {
        println!("AGC")
    }
}


Measured memory_bytes: 4352
def main():
    from collections import Counter
    s = list(input())
    a = 'E' in s
    b = 'W' in s
    c = 'N' in s
    d = 'S' in s

    if not (a ^ b) and not (c ^ d):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long


signed main(void) {
  int a[5];
  int maxRemain = 0;
  int maxIndex = 0;
  rep(i, 5) {
    cin >> a[i];
    int A = a[i]/10;
    int R = a[i]%10;
    if (R != 0) {
      R = (A+1) * 10 - a[i];
    }
    if (maxRemain < R) {
      maxIndex = i;
      maxRemain = R;
    }
  }

  int ans = 0;

  rep(i, 5) {
    int A = a[i]/10;
    int R = a[i]%10;
    if (R != 0) {
      A++;
    }
    if (i != maxIndex) {
      //cout << A*10 << endl;
      ans += A * 10;
    } else {
      //cout << a[i] << endl;
      ans += a[i];
    }
  }

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


Measured memory_bytes: 256
#S = (input())
N = int(input())
#N, M = map(int, input().split())
#A = list(map(lambda x: int(x)*(-1), input().split()))
X = list(map(int, input().split()))
#C = [list(map(int, input().split())) for i in range()]

final_ans = 100000000000000000000
for p in range(1,101):
    ans = 0
    for x in X:
        ans += (x-p)**2
    if final_ans > ans:
        final_ans = ans
print(final_ans)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int num(int x, int y, char c);
int main(){
  vector<int> s(4);
  while(cin >>s[0]>>s[1]>>s[2]>>s[3],s[0]){
    bool f = false;
    vector<char> one(3);
    vector<char> two(3);
    vector<char> thr(3);
    one[0] = two[0] = thr[0] = '+';
    one[1] = two[1] = thr[1] = '-';
    one[2] = two[2] = thr[2] = '*';
    sort(s.begin(),s.end());
    sort(one.begin(),one.end());
    sort(two.begin(),two.end());
    sort(thr.begin(),thr.end());
    do{
      do{
	do{
	  do{
	    if(num(num(num(s[0],s[1],one[0]),s[2],two[0]),s[3],thr[0]) == 10){
	      cout <<"((("<<s[0]<<" "<<one[0]<<" "<<s[1]<<")"<<" "<<two[0]<<" "<<s[2]<<")"<<" "<<thr[0]<<" "<<s[3]<<")";
	      f = true;goto end;
	    }
	    if(num(num(s[0],s[1],one[0]),num(s[2],s[3],thr[0]),two[0]) == 10){
	      cout <<"(("<<s[0]<<" "<<one[0]<<" "<<s[1]<<")"<<" "<<two[0]<<" "<<"("<<s[2]<<" "<<thr[0]<<" "<<s[3]<<"))";
	      f = true;goto end;
	    }
	    if(num(s[0],num(s[1],num(s[2],s[3],thr[0]),two[0]),one[0]) == 10){
	      cout <<"("<<s[0]<<" "<<one[0]<<" "<<"("<<s[1]<<" "<<two[0]<<" "<<"("<<s[2]<<" "<<thr[0]<<" "<<s[3]<<")))";
	      f = true;goto end;
	    }
	    if(num(num(s[0],num(s[1],s[2],two[0]),one[0]),s[3],thr[0]) == 10){
	      cout <<"(("<<s[0]<<" "<<one[0]<<" "<<"("<<s[1]<<" "<<two[0]<<" "<<s[2]<<"))"<<" "<<thr[0]<<" "<<s[3]<<")";
	      f = true;goto end;
	    }
	    if(num(s[0],num(num(s[1],s[2],two[0]),s[3],thr[0]),one[0]) == 10){
	      cout <<"("<<s[0]<<" "<<one[0]<<" "<<"(("<<s[1]<<" "<<two[0]<<" "<<s[2]<<")"<<" "<<thr[0]<<" "<<s[3]<<"))";
	      f = true;goto end;
	    }
	  }while(next_permutation(thr.begin(),thr.end()));
	}while(next_permutation(two.begin(),two.end()));
      }while(next_permutation(one.begin(),one.end()));
    }while(next_permutation(s.begin(),s.end()));
  end:;
    if(f){cout<<endl;}
    else{cout <<"0"<<endl;}
  }
  return 0;
}
int num(int x, int y, char c){
  if(c == '+'){return x+y;}
  if(c == '-'){return x-y;}
  return x*y;
}

Measured memory_bytes: 0
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    set<int> s;
    for(int i = 1, j = a, x = b; i <= k; i++, j++, x--){
        if(j >= a && j <= b) s.insert(j);
        if(x >= a && x <= b) s.insert(x);
    }
    for(auto x : s){
        cout << x << nl;
    }
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    ll delta = n - 1;
    for(ll before = 0; before <= delta; before++){
        ll after = delta - before;
        if(a + before * d < b + after * c) continue;
        if(a + before * c > b + after * d) continue;
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}


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

int main(){
  vector<string> data;
  for(string buf;getline(cin,buf),buf!="END_OF_TEXT";)
    {
      data.push_back(buf);
    }
  int x=0,y=0;
  string buf="";
  bool buf_br=false;
  for(char code;cin>>code,code!='-';)
    {
      if(code=='a')
	y=0;
      else if(code=='e')
	y=data[x].size();
      else if(code=='p')
	{
	  x=max(0,x-1);
	  y=0;
	}
      else if(code=='n')
	{
	  x=min((int)data.size()-1,x+1);
	  y=0;
	}
      else if(code=='f')
	{
	  if(y<data[x].size())
	    y++;
	  else if(y==data[x].size() &&x<data.size()-1)
	    {
	      x++;
	      y=0;
	    }
	}
      else if(code=='b')
	{
	  if(y>0)
	    y--;
	  else if(y==0 &&x>0)
	    {
	      x--;
	      y=data[x].size();
	    }
	}
      else if(code=='d')
	{
	  if(y<data[x].size())
	    data[x].erase(y,1);
	  else if(y==data[x].size() && x<data.size()-1)
	    {
	      data[x]+=data[x+1];
	      data.erase(data.begin()+x+1);
	    }
	}
      else if(code=='k')
	{
	  if(y==data[x].size())
	    {
	      if(x<data.size()-1)
		{
		  data[x]+=data[x+1];
		  data.erase(data.begin()+x+1);
		  buf="\n";
		  buf_br=true;
		}
	    }
	  else
	    {
	      buf=data[x].substr(y,data[x].size()-y);
	      buf_br=false;
	      data[x].erase(y,data[x].size()-y);
	    }	 
	}
      else if(code=='y')
	{
	  if(buf=="")
	    continue;
	  if(buf!="" && buf_br)
	    {
	      string tmp=data[x].substr(y,data[x].size()-y);
	      data[x].erase(y,data[x].size()-y);
	      data.insert(data.begin()+x+1,tmp);
	      x++;
	      y=0;
	    }
	  else  if(buf!="" && !buf_br)
	    {
	      data[x]=data[x].substr(0,y)+buf+data[x].substr(y,data[x].size()-y);
	      y+=buf.size();
	    }
	}    
      /*  
      cout<<"x,y="<<x<<","<<y<<endl;
      for(int i=0;i<data.size();i++)
	cout<<data[i]<<endl;
      */
    }
  
  for(int i=0;i<data.size();i++)
      cout<<data[i]<<endl;
}

Measured memory_bytes: 1220
# -*- coding: utf-8 -*-
n = int(input())
number_of_digits = len(str(n))
if number_of_digits == 6:
    print(90909)
elif number_of_digits == 5:
    print(90909 - (99999 - n))
elif number_of_digits == 4:
    print(909)
elif number_of_digits == 3:
    print(909 - (999 - n))
elif number_of_digits == 2:
    print(9)
elif number_of_digits == 1:
    print(9 - (9 - n))


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

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

int main(){
    int K;
    cin>>K;
    int sum=0;
    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int l=1;l<=K;l++){
                sum+=gcd(gcd(i,j),l);
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(){

    char s[4];
    int cnt = 0;

    cin >> s;

    for(int i = 0; i < 4; i++){
        if(s[i] == '1'){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 105
 
 
int n,g[MAX][MAX];
 
void check(int i, int u){
    
    /*check 1*/
    if(u != 0)
    g[i][u] = 1;
    
}
 
int main(){
    int i,j,k[MAX],a,b,s[MAX][MAX],num[MAX];
    
    scanf("%d",&n);
    for(i=1; i<=n; i++){
        scanf("%d %d",&num[i],&k[i]);
        for(j=1; j<=k[i]; j++){
            scanf("%d",&s[i][j]);
        }
    }
     /*array all 0*/
    for(i=1; i<=n; i++){
        for(j=0; j<n; j++){
        g[i][j] = 0;
    }
    }
    
    
      for(i=1; i<=n; i++){
        for(j=1; j<=k[i]; j++){
            check(num[i],s[i][j]);
        }
    }
    
    
    
     for(i=1; i<=n; i++){
        for(j=1; j<=n; j++){
        printf("%d",g[i][j]);
        if(j>=1 && j<n)
        printf(" ");
    }
    printf("\n");
    }
    
    
 return 0;   
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int A,p;
	cin>>A>>p;
	int ans = (A*3+p)/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    ll total = (n*(n+1))/2;
    ll m3 = n%3;
    m3 = ((n-m3+3)*(n/3))/2;
    ll m5 = n%5;
    m5 = ((n-m5+5)*(n/5))/2;
    total -= m3+m5;
    ll m15 = n%15;
    m15 = ((n-m15+15)*(n/15))/2;
    total += m15;
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
  int r0,r,w,n,c;
  while(1){
    cin>>r0>>w>>c>>r;
    if(r0+r+c+w==0)break;
    n=0;
    while(1){
      if(r0+n*r-c*w>=0)break;
      n++;
    }
    cout<<n<<endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 1e5 + 5;

vector<int> adj [MAX_N];
int vis [MAX_N];

void dfs (int u, int col, int &bip) {
  vis[u] = col;
  for (int nxt : adj[u]) {
    if (vis[nxt] == 0) {
      dfs(nxt, -col, bip);
    } else if (vis[nxt] == col) {
      bip = 0;
    }
  }
}

int main () {
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  ll singl = 0, ev = 0, od = 0;
  for (int i = 1; i <= n; i++) {
    if (adj[i].empty()) {
      singl++;
    } else {
      if (vis[i] == 0) {
        int bip = 1;
        dfs(i, 1, bip);
        if (bip) ev++;
        else od++;
      }
    }
  }

  ll ans = 2 * (ll) n * singl - singl * singl;
  ans += 2 * ev * ev;
  ans += ev * od;
  ans += od * ev;
  ans += od * od;

  cout << ans << endl;
}


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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int n, r; cin >> n >> r;
  if (n >= 10) cout << r << endl;
  else cout << r+(100*(10 - n)) << endl;
  return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)


int main()
{
    LL n;
    cin>>n;
    LL a[n];
    LL s=0;
    for(LL i=0; i<n; i++)
        cin>>a[i];
    for(LL i=0; i<n; i++)
    {
        for(LL j=i+1; j<n; j++)
            s+=a[i]*a[j];

    }
    cout<<s;

}


Measured memory_bytes: 256
lines = $stdin.read.split(?\n)
lines.each do |line|
  a, op, b = line.split(' ')
  break if op == '?'
  a, b = a.to_i, b.to_i
  case op
  when "+" then puts a + b
  when "-" then puts a - b
  when "*" then puts a * b
  when "/" then puts a / b
  end
end

Measured memory_bytes: 8620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    map<int,int> m;
    rep(i,3){
        int x;
        cin>>x;
        m[x]++;
    }
    int ans=0;
    for(auto p:m){
        ans++;
    }
    cout <<ans << endl;





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 85;
const int INF = 0x3f3f3f3f;

int maps[N][N],dp[N][N][160*N];

int main()
{
	int x,n,m,Max = 0;
	scanf("%d%d",&n,&m);
	memset(dp,0,sizeof(dp));
	for(int i = 1;i <= n;++i){
		for(int j = 1;j <= m;++j){
			scanf("%d",&maps[i][j]);
		}
	}
	for(int i = 1;i <= n;++i){
		for(int j = 1;j <= m;++j){
			scanf("%d",&x);
			maps[i][j] = abs(maps[i][j]-x);
			Max = max(Max,maps[i][j]);
		}
	}
	
	dp[1][1][maps[1][1]] = 1;
	for(int i = 1;i <= n;++i){
		for(int j = 1;j <= m;++j){
			for(int k = 0;k <= (n+m)*Max;++k){
				if(dp[i][j][k]){
					if(i < n){
						dp[i+1][j][k+maps[i+1][j]] = 1;
						dp[i+1][j][abs(k-maps[i+1][j])] = 1;
					}
					if(j < m){
						dp[i][j+1][k+maps[i][j+1]] = 1;
						dp[i][j+1][abs(k-maps[i][j+1])] = 1;
					}
				}
			}
		}
	}
	
	for(int i = 0;i <= (n+m)*Max;++i){
		if(dp[n][m][i]){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;

int main(){
    int H,W; cin>>H>>W;
    vector<string> S(H);
    rep(i,H)cin>>S[i];
    vector<vector<ll>> dp(H,vector<ll> (W,0));
    dp[0][0]=1;
    rep(h,H){
        rep(w,W){
            if(S[h][w]=='#')continue;
            if(h>0&&S[h-1][w]=='.')(dp[h][w]+=dp[h-1][w]%MOD)%MOD;
            if(w>0&&S[h][w-1]=='.')(dp[h][w]+=dp[h][w-1]%MOD)%MOD;
        }
    }
    cout<<dp[H-1][W-1]%MOD<<endl;
}

Measured memory_bytes: 12940
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}


///////////////////////////



int main() {

	ll N, M;
	cin >> N >> M;
	if (N == M) { cout << "Yes"; }
	else { cout << "No"; }
	
	
	system("PAUSE");

}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

int main() {
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << max({(N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E}) + 5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;
  cin>>k>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int maxd=k-a[n-1]+a[0];
  for(int i=0;i<n-1;i++){
    if(maxd<a[i+1]-a[i]){
      maxd=a[i+1]-a[i];
    }
  }
  cout<<k-maxd<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    string S;
    cin >> S;

    int N = S.size();
    int balance = 0;
    for(int i=0;i<N;i++){
        balance += S[i] == '0' ? 1 : -1;
    }
    cout << N - abs(balance) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 300010;

int h, w, n;

void drop(vector<string> &a){
    rep(j, w){
        vector<char> tmp;
        rrep(i, h)if(a[i][j] != '.') tmp.push_back(a[i][j]);
        rep(i, h) a[i][j] = '.';
        rep(i, tmp.size()) a[h-1-i][j] = tmp[i];
    }
}

vector<string> f(vector<string> &a){
    while(true){
        vector<pair<pii, int>> tate, yoko;
        rep(j, w){
            int l = 0;
            while(l < h){
                if(a[l][j] == '.'){
                    ++l;
                    continue;
                }
                int r = l;
                while(r < h && a[l][j] == a[r][j]) ++r;
                if(r-l >= n) tate.push_back({{l, j}, r-l});
                l = r;
            }
        }

        rep(i, h){
            int l = 0;
            while(l < w){
                if(a[i][l] == '.'){
                    ++l;
                    continue;
                }
                int r = l;
                while(r < w && a[i][l] == a[i][r]) ++r;
                if(r-l >= n) yoko.push_back({{i, l}, r-l});
                l = r;
            }
        }

        if(tate.empty() && yoko.empty()) break;

        for(auto &p: tate){
            rep(i, p.se) a[p.fi.fi+i][p.fi.se] = '.';
        }
        for(auto &p: yoko){
            rep(i, p.se) a[p.fi.fi][p.fi.se+i] = '.';
        }

        drop(a);
    }
    return a;
}

bool check(vector<string> &a){
    rep(i, h)rep(j, w)if(a[i][j] != '.') return false;
    return true;
}

int main(){
    scanf("%d%d%d", &h, &w, &n);
    vector<string> c(h);
    rep(i, h) cin >> c[i];

    rep(i, h)rep(j, w-1){
        vector<string> a = c;
        swap(a[i][j], a[i][j+1]);
        drop(a);

        a = f(a);
        if(check(a)){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
}


Measured memory_bytes: 3292
N,M = map(int,input().split())

AC = {}
WA = {}

if M == 0:
    print("0 0")
    exit()
for i in range(M):
    prob,sub = input().split()
    if sub == "WA":
        if (prob in AC) == False:
            if (prob in WA) == False:
                WA[prob] = 1
            else:
                WA[prob] += 1
    
    if sub == "AC":
         if (prob in AC) == False:
            AC[prob] = 1
         else:
            AC[prob] += 1
            
ans_WA = 0
for prob,sub in WA.items():
    if (prob in AC) == True:
        ans_WA += int(sub)
            
print(len(AC.values()),ans_WA)

Measured memory_bytes: 58072
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
#define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--)
using namespace std;

int main(void){
	int N;
	int read[1000];
	int write[1000];
	bool dp[1001];
	while (true){
		cin >> N;
		if (N == 0)
			return(0);

		rep(i, 0, N)
			cin >> read[i] >> write[i];

		int read_sum = 0;
		int read_max = 0;
		int max_index = 0;
		rep(i, 0, N){
			if (read[i] > read_max)
				read_sum += read_max,
				read_max = read[max_index = i];
			else
				read_sum += read[i];
		}


		int write_sum = 0;
		rep(i, 0, N)
			write_sum += write[i];

		int all_sum = read_max + read_sum + write_sum;
		int wait_space = read_max - read_sum;
		if (wait_space <= 0)
			cout << all_sum << endl;
		else{
			rep(i, 0, wait_space + 1)
				dp[i] = false;
			dp[0] = true;
			rep(i, 0, N)
			if (i!=max_index)
				rev(j, write[i], wait_space + 1)
			if (dp[j - write[i]])
				dp[j] = true;

			rev(i, 0, wait_space + 1)
			if (dp[i]){
				cout << ((wait_space)-i) + all_sum<<endl;
				break;
			}

		}
	}
}

Measured memory_bytes: 1168
Public Class Main
    Public Shared Sub Main(ByVal args() As String)
        Dim a, b As Integer
        Dim arr(2) As String
        arr = Split(Console.ReadLine())
        a = arr(0) : b = arr(1)
        If a < b Then
            Console.WriteLine(New String(arr(0)(0), b))
        Else
            Console.WriteLine(New String(arr(1)(0), a))
        End If
    End Sub
End Class

Measured memory_bytes: 11488
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=4e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//ÄæÔª
//int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}


int a[24][24];
ll dp[24][M];
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n;
    scanf("%d",&n);
    //n=21;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            scanf("%d",&a[i][j]);
            //a[i][j]=rand()%2;
        }
    }
    dp[0][0]=1;
    for(int j=1;j<=(1<<n)-1;j++){
        int i=0;
        for(int k=1;k<=n;k++){
            if(j&(1<<(k-1))) i++;
        }
        for(int k=1;k<=n;k++){
            if(j&(1<<(k-1))&&a[i][k]){
                dp[i][j]+=dp[i-1][j-(1<<(k-1))];
                dp[i][j]%=mod;
            }
        }
    }
    printf("%lld\n",dp[n][(1<<n)-1]);



    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




Measured memory_bytes: 334080
#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>
#include <stack>
using namespace std;

int main()
{
	string s;
	cin >> s;

	auto len = 0;
	for (auto i = 0; i < s.length(); ++i)
	{
		if (s[i] == 'A')
		{
			for (auto j = i + 1; j < s.length(); ++j)
			{
				if (s[j] == 'Z')
				{
					len = j - i + 1;
				}
			}
			break;
		}
	}

	cout << len << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define db long double
#define ull unsigned long long int
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
#define MAXN 1000005
 
using namespace std;

vector<ll> tree[100005];
ll dpw[100005],dpb[100005];

void dfs(ll node,ll par)
{
	ll black=1,white=1;
	for(auto x:tree[node])
	{
		if(x==par) continue;
		dfs(x,node);
		black*=dpw[x];
		black%=MOD;
		white*=(dpw[x]+dpb[x]);
		white%=MOD;
	}
	dpw[node]=white;
	dpb[node]=black;
}

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    int tests=1;
    // compute();
    // cin>>tests;
    while(tests--)
    {
    	ll i,j,n;
    	cin>>n;
    	rep(i,1,n-1)
    	{
    		ll x,y;
    		cin>>x>>y;
    		tree[x].pb(y);
    		tree[y].pb(x);
    	}
    	dfs(1,0);
    	cout<<(dpb[1]+dpw[1])%MOD;

    }
    	return 0;
    
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a>0&&b>0){
    cout<<"Positive"<<endl;
  }else if(a<=0&&b>=0||a==0||b==0){
    cout<<"Zero"<<endl;
  }else if(a<0&&b<0){
    if(abs(a-b)%2){
      cout<<"Positive"<<endl;
    }else{
      cout<<"Negative"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
LL x[N],y[N];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld",&x[i]);
    for(int j=1;j<=m;j++)
        scanf("%lld",&y[j]);

    LL sx=0;
    for(int i=1;i<=n;i++){
        sx=(sx+x[i]*(i-1))%MOD;
        sx=(sx-x[i]*(n-i))%MOD;
    }
    LL sy=0;
    for(int i=1;i<=m;i++){
        sy=(sy+y[i]*(i-1))%MOD;
        sy=(sy-y[i]*(m-i))%MOD;
    }
    LL res=(sx*sy)%MOD;
    printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  int ans = 0;
  rep(i,n) for (int j = i+1; j < n; ++j) {
    ans += d[i]*d[j];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());  //入力した数字
            int n = 0;                            //奇数の数
            double ans = 0.0f;

            if(a % 2 == 0)
            {
                n = a / 2;             
            }
            else
            {
                n = (a + 1) / 2;
            }
            ans = (float)n / a;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
using System;


class AOJ
{
    public static void Main()
    {
        int[] a = new int[10];
        int c=0;

        while (true)
        {
            string s = Console.ReadLine();
            if (s == null) break;

            int n = int.Parse(s);

            if (n == 0)
            {
                c--;
                Console.WriteLine(a[c]);
            }
            else
            {
                a[c] = n;
                c++;
            }
        }
    }
}

Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define LDB long double
#define DB double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
inline LL read(){
	LL nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}

#define mod 998244353
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x+=y;(x>=mod)?(x-=mod):0;}
	inline void dec(int &x,int y){x-=y;(x<0)?(x+=mod):0;}
	inline int qpow(int x,int sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;
#define M 400200
#define INF 10000000
int F[39][M],A[M],B[M],t[M],n,m;
int G[M],W[M],od[M],pre[M];
int sz[M],ans=INF;
inline bool cmp(int x,int y){return G[x]<G[y];}
int main(){
	n=read(),memset(F,0x3f,sizeof(F)),F[0][0]=0;
	for(int i=0;i<n;i++) A[i]=read(),t[++m]=A[i];
	for(int i=0;i<n;i++) B[i]=read(),t[++m]=B[i];
	sort(t+1,t+m+1),m=unique(t+1,t+m+1)-t-1;
	for(int i=0;i<n;i++) A[i]=lower_bound(t+1,t+m+1,A[i])-t;
	for(int i=0;i<n;i++) B[i]=lower_bound(t+1,t+m+1,B[i])-t;
	// for(int i=0;i<n;i++) debug(i)sp,debug(A[i])sp,debug(B[i])el;
	// debug(m)el;
	for(int sta=0;sta+1<(1<<n);sta++){
		sz[sta]=(sz[sta>>1]+(sta&1));
		int now=INF,tot=0,bs=1;
		for(int i=0;i<n;i++) if(!((sta>>i)&1)) G[++tot]=(((i^sz[sta])&1)?B[i]:A[i]),W[tot]=i,od[tot]=tot;
		sort(od+1,od+tot+1,cmp);
		for(int i=0;i<=n;i++) pre[i]=((sta>>i)&1);
		for(int i=1;i<=n;i++) pre[i]+=pre[i-1];
		for(int k=0;k<=m&&bs<=tot;k++){
			if(F[k][sta]<now) now=F[k][sta];
			// if(sta==3&&k==1) debug(sta)sp,debug(k)sp,debug(now)el;
			while(bs<=tot&&G[od[bs]]==k){
				int tar=(sta|(1<<W[od[bs]]));
				// if(sta==3&&k==1) debug(G[od[bs]])sp,debug(W[od[bs]])sp,debug(k)sp,debug(tar)el;
				F[k][tar]=min(F[k][tar],now+sz[sta]-pre[W[od[bs]]]);
				bs++;
			}
		}
	}
	for(int i=m;i>0;--i) ans=min(ans,F[i][(1<<n)-1]);
	if(ans>=INF) ans=-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 72832
#include <iostream>
#include <string>
using namespace std;
int main() {
string S;
cin >> S;
string Alph = "abcdefghijklmnopqrstuvwxyz";
sort(S.begin(), S.end());
string ans = "None";
for (char i : Alph) {
        if (S.find(i) == -1) {
                ans = i;
                break;
        }   
}
cout << ans << endl;
}

Measured memory_bytes: 512