akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
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;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
int hw[2010][2010];
int ww[2010][2010];
void solv() {
	int h, w;
	cin >> h >> w;
	string t[2010];
	for (size_t i = 0; i < h; i++)
	{
		cin >> t[i];
	}

	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			if (t[i][j] == '.') {
				ww[i][j] += 1;
				if (j > 0) ww[i][j] += ww[i][j - 1];
			}
		}
		char bef = '#';
		for (int j = w - 1; j >= 0; j--)
		{
			if (t[i][j] == '.') {
				if (bef == '.') ww[i][j] = ww[i][j + 1];
			}
			bef = t[i][j];
		}
	}

	for (size_t i = 0; i < w; i++)
	{
		for (size_t j = 0; j < h; j++)
		{
			if (t[j][i] == '.') {
				hw[j][i] += 1;
				if (j > 0) hw[j][i] += hw[j - 1][i];
			}
		}
		char bef = '#';
		for (int j = h - 1; j >= 0; j--)
		{
			if (t[j][i] == '.') {
				if (bef == '.') hw[j][i] = hw[j + 1][i];
			}
			bef = t[j][i];
		}
	}
	int res = 0;
	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			if (t[i][j] == '.') {
				res = max(res, hw[i][j] + ww[i][j] - 1);
			}
		}
	}
	cout << res << endl;
}

int main() {
//	COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 37120
N,M = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(M)]
l.sort(key= lambda x: x[1])
removed = 0
ans = 0
for i in l:
  s = i[1]
  if removed<i[0]:
    removed = s-1
    ans+=1

print(ans)

Measured memory_bytes: 29084
N, K, Q = [ int(n) for n in input().split() ]
A = []
for _ in range(Q):
    A.append( int(input())-1 )

Points = [ K-Q for _ in range(N) ]
for a in A:
    Points[a] += 1
        
for i in range(N):
    if Points[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 56536
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <climits>
using namespace std;
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, init, n) for (int i = (init); i < (n); ++i)
#define RepLong(i, n) for (int64 i = 0; i < (n); ++i)
#define InitRepLong(i, init, n) for (int64 i = (init); i < (n); ++i)
#define RepItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)


vint64 createEnumerate(const vint& items)
{
	vint64 answers;

	if (items.size() == 1)
	{
		answers.push_back(items[0]);
		return answers;
	}

	for (const int item : items)
	{
		vint leftItems;
		Rep(i, items.size())
		{
			if (items[i] != item)
			{
				leftItems.push_back(items[i]);
			}
		}
		for (const int64 answer : createEnumerate(leftItems))
		{
			answers.push_back((item << (3 * leftItems.size())) + answer);
		}
	}
	return answers;
}

int main()
{
	int n;
	cin >> n;
	int64 p = 0, q = 0;
	Rep(i, n)
	{
		p <<= 3;
		int64 pi;
		cin >> pi;
		p += pi - 1;
	}
	Rep(i, n)
	{
		q <<= 3;
		int64 qi;
		cin >> qi;
		q += qi - 1;
	}

	vint items(n);
	Rep(i, n)
	{
		items[i] = i;
	}
	vint64 dic = createEnumerate(items);

	/*
	cout << oct << "p = " << p << ", q = " << q << endl;
	cout << "begin dic" << endl;
	for (auto ans : dic)
	{
		cout << oct << ans << endl;
	}
	cout << "end dic" << endl;
	/*/

	int a = -1, b = -1;
	Rep(i, dic.size())
	{
		if (dic[i] == p)
		{
			a = i;
		}
		if (dic[i] == q)
		{
			b = i;
		}
	}
	//cout << "a = " << a << ", b = " << b << endl;
	cout << (a < b ? b - a : a - b) << endl;

	return 0;
}

Measured memory_bytes: 936
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

int compare_int(const void *a, const void *b){
	ll *A = (ll *)a;
	ll *B = (ll *)b;
    if(*A < *B)return 1;
    if(*A > *B)return -1;
    return 0;
}
int main(void){
    int  n;
    scanf("%d", &n);
    ll a[n];
    for(int i = 0;i < n;i++){
        scanf("%lld", &a[i]);
    }
    qsort(a, n, sizeof(ll), compare_int);
    int ans = 0;
    int now = -1;
    int count = 0;
    for(int i = 0;i < n;i++){
        if(now == a[i])count++;
        else{
            ans += count%2;
            count = 1;
            now = a[i];
        }
    }
    ans += count % 2;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int sz = s.length();
  cout << s.substr(0, sz-8) << '\n';
  return 0;
}


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

int n;
int s[110];

void solve() {
  sort(s, s+n);
  int sum = 0;
  for (int i=0;i<n;i++) {
    sum += s[i];
  }
  if (sum % 10 == 0) {
    for (int i=0;i<n;i++) {
      if (s[i] % 10 != 0) {
        sum -= s[i];
        break;
      }
    }
  }
  if (sum % 10 == 0) {
    cout << 0 << endl;
  } else {
    cout << sum << endl;
  }
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> s[i];
  }
  solve();
}


Measured memory_bytes: 256
use proconio::input;

const MOD: i64 = 998244353;

fn main() {
    input! {
	A: usize,
	B: usize,
	C: usize,
	D: usize,
    }

    let mut dp = vec![0i64; 3001];
    let mut prevDp = vec![0i64; 3001];

    for i in A..C+1 {
	std::mem::swap(&mut dp, &mut prevDp);
	for j in B..D+1 {
	    dp[j] = 0;
	    if i == A && j == B {
		dp[j] = 1;
		continue;
	    }
	    if i > A {
		dp[j] = (dp[j] + prevDp[j] * j as i64) % MOD;
	    }
	    if j > B {
		dp[j] = (dp[j] + dp[j - 1] * i as i64) % MOD;
	    }
	    if i > A && j > B {
		dp[j] = (dp[j] - prevDp[j - 1] * (i - 1) as i64 * (j - 1) as i64) % MOD
	    }
	}
    }

    println!("{}", (dp[D] + MOD) % MOD);
}


Measured memory_bytes: 2176
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


int dx[] = { 0, 0, +1, -1, -1  +1, -1, +1 };
int dy[] = { +1, -1, 0, 0, -1, +1, +1, -1 };


const int mx = 1e5+123;
int lev[mx];
vi adj[mx];
int par[mx];

void bfs ( int s )
{
	mem ( lev, -1 );

	queue<int> q;
	q.push ( s );

	while ( !q.empty() ) {
		int u = q.front();
		q.pop();

		for ( auto v : adj[u] ) {
			if ( lev[v] == -1 ) {
				lev[v] = lev[u] + 1;
				par[v] = u;
				q.push( v );
			}
		}
	}
}


int main()
{
	optimize();

	int n, m;
	cin >> n >> m;
	for ( int i = 1; i <= m; i++ ) {
		int u, v;
		cin >> u >> v;
		adj[u].PB ( v );
		adj[v].PB ( u );
	}

	bfs ( 1 );

	for ( int i = 2; i <= n; i++ ) {
		if ( lev[i] == -1 ) return cout << "No", 0;
	}

	cout << "Yes\n";
	for ( int i = 2; i <= n; i++ ) cout << par[i] << endl;





	return 0;
}


















Measured memory_bytes: 10936
#include <iostream>
#include <cstdlib>
#include <cstdio>
#define ll long long
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 1e5;

int n, s, lx, rx;
ll ans, lp, rp;
int x[N + 1], p[N + 1];

inline void solve()
{
	lx = 1;
	rx = n;
	lp = p[lx];
	rp = p[rx];
	int la = 0;
	while (s < x[rx] && s > x[lx]) {
		if (lp < rp) {
			if (la > lx || !la)
				ans += 1ll * (x[rx] - x[lx]);
			rp += lp;
			lx++;
			lp = p[lx];
			la = lx - 1;
		} else {
			if (la < rx || !la)
				ans += 1ll * (x[rx] - x[lx]);
			lp += rp;
			rx--;
			rp = p[rx];
			la = rx + 1;
		}
	}
	if (s > x[rx])
		ans += 1ll * (s - x[lx]);
	else
		ans += 1ll * (x[rx] - s);
	return;
}
int main()
{
	n = read();
	s = read();
	for (int i = 1; i <= n; i++) {
		x[i] = read();
		p[i] = read();
	}

	solve();

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4488
use std::io::Read;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut s: Vec<char> = Vec::with_capacity(n);
    for c in iterator.next().unwrap().chars() {
        s.push(c);
    }

    let mut ans = 0;
    for i in 1..n {
        if s[i] == 'E' {
            ans += 1;
        }
    }

    let mut a = ans;
    for i in 1..n {
        if s[i] == 'E' {
            a -= 1;
        }
        if s[i - 1] == 'W' {
            a += 1;
        }
        ans = min(ans, a);
    }

    return ans.to_string();
}


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

typedef long long LL;

const int N = 50;
const int M = 250;

bool mat[N][N];

int n, m, s;
LL mod;

LL pow_mod(LL x, int p){
    LL s = 1;
    while(p){
        if(p & 1)   s = s * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return s;
}

int query(int a, int b, int c, int d){
    printf("? %d %d %d %d\n", a, b, c, d);
    fflush(stdout);
    int x;
    scanf("%d", &x);
    return x;
}

void solve(int x1, int x2, int y1, int y2, int div, int s){
    if(s == 0 || x1 > x2 || y1 > y2)  return;
    int area = (x2 - x1 + 1) * (y2 - y1 + 1);
    if(area == s){
        for(int i=x1; i<=x2; i++){
            for(int j=y1; j<=y2; j++){
                mat[i][j] = 1;
            }
        }
        return;
    }
    if(x1 == x2 && div){
        div ^= 1;
    } else if(y1 == y2 && !div){
        div ^= 1;
    }
    if(div){
        int mid = x1 + x2 >> 1;
        int ans = query(x1, y1, mid, y2);
        solve(x1, mid, y1, y2, 1^div, ans);
        solve(mid+1, x2, y1, y2, 1^div, s - ans);
    } else {
        int mid = y1 + y2 >> 1;
        int ans = query(x1, y1, x2, mid);
        solve(x1, x2, y1, mid, 1^div, ans);
        solve(x1, x2, mid+1, y2, 1^div, s - ans);
    }
}

int main(){
    while(~scanf("%d %d %d %lld", &n, &m, &s, &mod)){
        memset(mat, 0, sizeof(mat));
        for(int i=0; i<n-1 && s; i++){
            int g = query(i, 0, i, m-1);
            if(g){
                solve(i, i, 0, m-1, 1, g);
                s -= g;
            }
        }
        solve(n-1, n-1, 0, m-1, 1, s);

        LL ans = 0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(mat[i][j]){
                    ans = (ans + pow_mod(2, i*m+j)) % mod;
                }
            }
        }
        printf("! %lld\n", ans);
        fflush(stdout);
    }
    return 0;
}


Measured memory_bytes: 724
from collections import deque

s = deque((str(input())))
loop = int(input())

rev = 0
for i in range(loop):
    queries = input().split()
    if len(queries) == 1:
        rev = (rev+1) % 2
    else:
        type = int(queries[1])
        c = str(queries[2])
        if (type + rev) % 2 == 1:
            s.appendleft(c)
        else:
            s.append(c)
if rev == 1:
    s.reverse()
print("".join(list(s)))



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

const int N = 201000, p = 1e9+7;
int fac[N], inv[N];

inline int C(int n, int m) {return (ll)fac[n] * inv[m]%p * inv[n-m]%p;}
inline int qpow(int A, int B) {
	int res = 1; while(B) {
		if(B&1) res = (ll)res * A%p;
		A = (ll)A * A%p, B >>= 1;
	} return res;
}

int n, m, a, b;

int main() {
	scanf("%d%d%d%d",&n,&m,&a,&b);
	int L = n + m;
	fac[0] = 1;
	for(int i=1;i<=L;++i) fac[i] = (ll)fac[i-1] * i%p;
	inv[L] = qpow(fac[L], p-2);
	for(int i=L;i;--i) inv[i-1] = (ll)inv[i] * i%p;
	
	int ans = 0;
	for(int i=1;i<=n-a;++i)
		ans = (ans + (ll)C(i+b-2, i-1) * C(n-i+m-b-1, n-i))%p;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1792
H, W = map(int, input().split())
map_dict = {}
for i in range(H):
    W_list = input().split()
    W_list = [int(i) for i in W_list]
    map_dict.update({i: W_list})

min_total = 999999
for i in range(H):
    for j in range(W):
        total = 0
        for p in range(H):
            for q in range(W):
                total += map_dict[p][q] * min(abs(p - i), abs(q - j))
        
        if total < min_total:
            min_total = total

print(min_total)    


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=998244353;

int N;
vpint P;

int po[222];

signed main(){
    po[0]=1;
    for(int i=1;i<222;i++)po[i]=po[i-1]*2%mod;
    cin>>N;
    rep(i,N){
        int x,y;
        cin>>x>>y;
        P.pb({x,y});
    }
    sort(all(P));

    int ans=po[N];
    ans=(ans-1+mod)%mod;
    ans=(ans-N+mod)%mod;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int dx=P[j].fi-P[i].fi;
            int dy=P[j].se-P[i].se;

            int cnt=0;
            for(int k=j+1;k<N;k++){
                int dxx=P[k].fi-P[i].fi;
                int dyy=P[k].se-P[i].se;

                if(dy*dxx!=dx*dyy)continue;
                cnt++;
            }
            ans=(ans-po[cnt]+mod)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, l;
    cin >> n >>l;
    int a[n];
    long sum = 0;
    int f=0;
    for(int i=0;i<n;i++)
    {
        a[i]= l + i;
        if(a[i]==0)
        {
            f=1;
        }
        sum += a[i];
    }
    if(f==1)
    cout<<sum<<endl;
    else{ 
        long  s,s1;
        //notei
       long  min =100000000;
     for(int i=0;i<n;i++)
        {
             s = sum - a[i];
             if(abs(s-sum)<min)
             { 
               min = abs(s-sum);
               s1 = s;
            }
      }
      cout<<s1<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    string A, B;
    io.read(A, B);
    string ans = "EQUAL";
    if(A.size() > B.size()) ans = "GREATER";
    else if(A.size() < B.size()) ans = "LESS";
    else{
        for(int i = 0; i < A.size(); i++){
            if(A[i] != B[i]){
                if(A[i] > B[i]) ans = "GREATER";
                if(A[i] < B[i]) ans = "LESS";
                break;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

S=SR()
ym=0
my=0
if int(S[2:]) >0 and int(S[2:]) <13:
    ym=1
if int(S[:2]) >0 and int(S[:2]) <13:
    my=1

if ym==1 and my==1:
    print('AMBIGUOUS')
elif ym==1 and my==0:
    print('YYMM')
elif ym==0 and my==1:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;

int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	long long int a[200005],b[200005],x,y;
	//cout << fixed << setprecision(10);
	long long int n, m, two=0,res = 0, cou[200005]={}, mi = 999999999, ma = -9999999999;
	long long int max_id, min_id;
	cin >>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<n;i++)
	{
		x+=2*max(a[i]-b[i],0LL);
		y+=max(b[i]-a[i]-(b[i]-a[i])%2,0LL);
		
	}
	if(x>y)
		{
			
			cout<<"No"<<endl;
		}else
		{
			cout<<"Yes"<<endl;
			
		}
}


Measured memory_bytes: 2432
n,m,c = gets.chop.split(" ").map(&:to_i)
b = gets.chop.split(" ").map(&:to_i)
count = 0
n.times do
    a = gets.split(" ").map(&:to_i)
    sum = 0
    m.times do |i|
        sum += a[i]*b[i]
    end
    if sum>-c then count += 1 end
end
puts count

Measured memory_bytes: 1788
def solve():
    A=[0]*5
    for i in range(5):
        A[i]=int(input())
    B=[(a+9) // 10 * 10 for a in A]
    C=[((a+9) // 10 * 10) - a for a in A]
    return sum(B)-max(C)

print(solve())


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    for (int i=A; i<=B; i++){
        string s;
        string rev_s;
        s = to_string(i);
        rev_s = s;
        reverse(all(rev_s));
        if(rev_s == s)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll L[4000];
 
void input() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> L[i];
}
 
void solve() {
    input();
    vector<ll> v(N);
    for(int i = 0; i < N; i++) v[i] = L[i+1];
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll mid = N - 1; mid >= 0; mid--) {
        for(ll low = mid - 1; low >= 0; low--) {
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            ll ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
            //cerr << v[mid] + v[low] << " " << ng << " " << (N-1-mid)-ng << endl;
        }
    }
    cout << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

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

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

Measured memory_bytes: 256
#include <stdio.h>

int c[10001];
int a[2000001],b[2000001];
int n;

void CountingSort(int [], int, int [], int [], int);


int main(){
  int i,j;

  scanf("%d",&n);

  for(i=1; i <= n; i++){
    scanf("%d",&a[i]);
  }

CouningSort(a,10000);

for(j=1; j <= n; j++){
if(j > 1) printf(" ");
printf("%d",b[j]);
}
printf("\n");


return 0;
}

CouningSort(int a[], int k){
  int i,j;
  for(i=0; i < k; i++){
    c[i]=0;
  }

for(j=1; j <=n; j++){
    c[a[j]]++;
  }

  for(i=1; i <=k; i++){
    c[i]=c[i]+c[i-1];
  }

  for(j=n; j >0; j--){
    b[c[a[j]]]=a[j];
    c[a[j]]--;
  }

}

Measured memory_bytes: 16268
q=int(input())
P2017=[]
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
P=primes(10**5)
for p in P:
  if (p+1)//2 in P:
    P2017.append(p)
LR=[0]*(10**5)
for p in P2017:
  LR[p]+=1
for i in range(10**5-1):
  LR[i+1]+=LR[i]
for i in range(q):
  l,r=map(int,input().split())
  print(LR[r]-LR[l-1])

Measured memory_bytes: 6716
n=int(input())
s=input()

rc=s.count('R')
gc=s.count('G')
bc=s.count('B')

ans=rc*gc*bc
for i in range(n):
    for j in range(i+1,n-1):
        k=2*j -i

        if k >= n or s[i] == s[j] or s[j] == s[k] or s[i] == s[k]:
            continue

        ans-=1

print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int h, n, a, sum = 0;
    cin>>h>>n;
    REP(i,n) {
        cin>>a;
        sum += a;
    }
    Yes(sum >= h);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;  
long INF=1000000000000000;
int main() {
    long N;
    cin>>N;
    string s;
    cin>>s;
    long ans=-1;
      
      
    for(int i=1;i<N;i++){
        long pre=0;
        vector<bool> L(26,false),R(26,false);
        for(int j=0;j<N;j++){
            if(j<i) L.at(s.at(j)-'a')=true;
            else R.at(s.at(j)-'a')=true;
        }
        for(int i=0;i<26;i++) pre+=(L.at(i))*(R.at(i));
        ans=max(ans,pre);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
//author wjl

using namespace std;
#define LL long long
#define Rint register int
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define pii pair<int ,int>
#define MS0(X) memset(X,0,sizeof(X))
#define MSf(X) memset(X,false,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define BR printf("--------------------\n")
#define pb push_back
#define rep(i,a,b) for(Rint i=a;i<=b;++i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};
int n,t;
struct node
{
    int a,b;
}st[maxn];

bool cmp(node a,node b)
{
    return a.a<b.a;
}

int dp[3005][6005];
int mx[3005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>st[i].a>>st[i].b;
    }
    sort(st+1,st+n+1,cmp);//排序很重要
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=t+st[i].a-1;j>=st[i].a;--j)
        {
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-st[i].a]+st[i].b);
            ans=max(ans,dp[i][j]);
        }
        for(int j=st[i].a-1;j>=0;--j)
        {
            dp[i][j]=dp[i-1][j];
            ans=max(ans,dp[i][j]);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 71936
using System;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] sortArray = str.Select(s => int.Parse(s)).ToArray();
            int executeNum = 0;

            for(int i = 0;i < n-1; ++i)
            {
                for(int j = n-1;j > i; --j)
                {
                    if(sortArray[j] < sortArray[j-1])
                    {
                        Program.swap(ref sortArray[j], ref sortArray[j - 1]);
                        ++executeNum;
                    }
                }
            }
            for(int i = 0; i < n; ++i)
            {
                Console.Write(sortArray[i]);
                if(i != n - 1)
                {
                    Console.Write(" ");
                }
            }
            Console.Write("\n");
            Console.WriteLine(executeNum);
        }
        public static void swap(ref int x ,ref int y)
        {
            int temp = x;
            x = y;
            y = temp;
        }
    }
}

Measured memory_bytes: 9596
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;
signed main() {
	int a, b; cin >> a >> b;
	int ans;
	if (a >= 10) {
		ans = b;
	} else {
		ans = b + 100*(10-a);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>

int main() {
	int n;
	std::string s;
	std::string t;
	std::cin >> n;
	std::cin >> s;
	std::cin >> t;

	for (int i = 0; i < n; i++) {
		std::cout << s[i] << t[i];
	}
	std::cout << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  int K;
  cin>>K;
  vector<int> vec(K);
  for (int i = 0; i < K; i++)
  {
    cin>>vec[i];
  }
  reverse(ALL(vec));
  if(vec[0] != 2)
  {
    cout<<-1<<endl;
      return;
  }
  int L = 2,R = 3;

  for (int i = 0; i < K; i++)
  {
    
    int A = vec[i];
    // DEBUG(A,R);

    L = ceil(double(L)/double(A))*A;
    R = floor(double(R-1)/double(A))*A + A ;
    if(L >= R)
    {
      cout<<-1<<endl;
      return;
      break;
    }
  }
  cout<<L<<" "<<R-1<<endl;



  
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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



int main() {
    ll N,K;
    cin>>N>>K;
    vector<ll> H(N);
    rep(i,N){
        cin>>H.at(i);
    }
    sort(H.begin(),H.end());
    if(K>=N){
        cout<<0<<endl;
    }
    else{
        ll ans=0;
        rep(i,N-K){
            ans+=H.at(i);
        }
        cout<<ans<<endl;
    }
}


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

#define ll long long
#define pb push_back

int dp[2][8001];
int main() {
	
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	    string s;
	    cin>>s;
	    int x,y;
	    cin>>x>>y;
	    int sumx=0, sumy=0;
	    vector<int> v[2];
	    
	    int cur = 0;
	    int len=0;
	    
	    int j=0,cnt=0;
	    while(j<s.length() && s[j]!='T'){
	        cnt++;
	        j++;
	    }
	    for(int i=j;i<s.length();i++){
	        if(s[i]=='T'){
	            if(len>0)
	                v[cur].push_back(len);
	            cur^=1;
	            len=0;
	        }
	        else{
	            len++;
	        }
	    }
	    if(len>0){
	        v[cur].push_back(len);
	    }
	    dp[0][0]=dp[1][0]=1;
	    for(int i=0;i<v[0].size();i++){
	        sumx+=v[0][i];
	        for(int j=8000;j>=v[0][i];j--){
	            if(dp[0][j-v[0][i]]){
	                dp[0][j]=1;
	            }
	        }
	    }
	    for(int i=0;i<v[1].size();i++){
	        sumy+=v[1][i];
	        for(int j=8000;j>=v[1][i];j--){
	            if(dp[1][j-v[1][i]]){
	                dp[1][j]=1;
	            }
	        }
	    }
	    bool fx=0,fy=0;
	    for(int i=0;i<=8000;i++){
	        if(dp[0][i] && ((2*i-sumx) == (x-cnt)))
	            fx=1;
	        if(dp[1][i] && ((2*i-sumy) == y))
	            fy=1;
	    }
	    if(fx && fy)
	        cout<<"Yes\n";
        else
            cout<<"No\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
s=[]
for i in range(a):
    s.append(input())
ans=[]
dx=[1, 0, -1, 0, 1, -1, -1, 1]
dy=[0, 1, 0, -1, 1, 1, -1, -1]
for i in range(a):
    anssss=[]
    for j in range(b):
        if s[i][j]=="#":
            anssss.append("#")
            continue
        count=0
        for k in range(8):
            if (dx[k]+j>=0 and dy[k]+i>=0 and dx[k]+j<b and dy[k]+i<a):
                if (s[dy[k]+i][dx[k]+j]=="#"):
                    count+=1
        anssss.append(str(count))
    ans.append(anssss)
for i in range(a):
    for j in range(b):
        print(ans[i][j],end="")
    print()



Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define pi              acos(-1)
#define ll              long long
#define ld              long double
#define gcd             __gcd
#define bitscount       __builtin_popcount
#define ff              first
#define ss              second
#define MAXX            1e18
#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL)
//__builtin_popcount()  -->  counts how many 1 s are in a binary represented integer
//accumulate() --> finds sum of an array of integers
using namespace std;
//void showdp(vector<vector<ll> > v)
//{
//    ll i, j;
//    for(i=0; i<v.size(); i++){
//        for(j=0; j<v[i].size(); j++)
//            cout<<v[i][j]<<" ";
//        cout<<endl;
//    }
//    cout<<endl;
//}
int main()
{
    ll n, k, i, j;
    cin>>n>>k;
    vector<ll> w(n+1), v(n+1);
    vector<vector<ll> > dp(n+1, vector<ll>(k+1) );
    for(i=1; i<=n; i++)
        cin>>w[i]>>v[i];
    for(i=1; i<=n; i++){
        for(j=1; j<=k; j++){
//            cout<<w[i]<<" "<<v[i]<<" ";
            dp[i][j] = dp[i-1][j];
            if(w[i] <= j)
                dp[i][j] = max(dp[i][j], v[i]+dp[i-1][j-w[i]]);
//            cout<<i<<" "<<j<<endl;
//            showdp(dp);
        }
    }
    cout<<dp[n][k];
}


Measured memory_bytes: 80256
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
//#include "grader.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define read(FILENAME) assert(freopen((FILENAME + ".in").c_str(), "r", stdin))
#define write(FILENAME) assert(freopen((FILENAME + ".out").c_str(), "w", stdout))
#define files(FILENAME) read(FILENAME), write(FILENAME)
using namespace std;
template <typename A, typename B> void chkmin(A &x, B y) {if (x > y) x = y;}
template <typename A, typename B> void chkmax(A &x, B y) {if (x < y) x = y;}
     
typedef pair <int, int> point;
     
const string FILENAME = "input";
const int MAXN = 1e4, p = 1e9 + 7;

int n;
bool bag[MAXN - 1];

int main() {
	//read(FILENAME);
	ios::sync_with_stdio(0);
	cin >> n;
	bag[0] = true;
	for (int i = 0; i < n; ++i) {
		int s; 
		cin >> s;
		for (int j = MAXN; j - s >= 0; --j) {
			bag[j] |= bag[j - s];
		}
	}
	int ans = 0;
	for (int i = 0; i <= MAXN; ++i) {
		if (bag[i] && i % 10 != 0) {
			ans = i;
		}
	}
	cout << ans << endl;
}








Measured memory_bytes: 256
package main

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

type drink struct {
	p, x int
}

func main() {
	n := getInt()
	ts := getIntSlice(n)

	m := getInt()
	ds := make([]drink, m)
	for i := range ds {
		ds[i].p = getInt()
		ds[i].x = getInt()
	}

	sum := sum(ts...)

	for _, d := range ds {
		fmt.Println(sum + d.x - ts[d.p-1])
	}
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	ans := make([]int, n)
	for i := range ans {
		ans[i] = getInt()
	}
	return ans
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

int Figure(ll x){
	return to_string(x).size();
}

int n,k;
set<int> st;

bool func(int x){
	int F=Figure(x),tmp=1;
	for(int i=0;i<F;i++){
		if(st.find(x/tmp%10)!=st.end()) return 0;
		tmp*=10;
	}
	return 1;
}

int main(){
	cin>>n>>k;
	int a;
	for(int i=0;i<k;i++){
		cin>>a;
		st.insert(a);
	}
	int ans=n;
	while(1){
		if(func(ans)) break;
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
a['___'],c;
main(i,j)
{
  for(;++i*i<1e6;)for(j=i;j<1e6;)a[j+=i]=1;
  for(;scanf("%d",&j),i=j;c=!printf("%d\n",c))
    for(;++j<=i*2;)c+=!a[j];
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int i;
  int s = 0;
  for(i = 1; i <= b; i++)
  {
    if((a*i)%b==c)
    {
      s = 1;
      break;
    }
  }
  if(s == 1)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import copy
N,K=map(int,input().split())
L=[]
for i in range(N):
    a,b=map(int,input().split())
    if a<=K:
        L.append([a,b])

#print(L)
k=[]
num=copy.deepcopy(K)
for i in range(30):
    if num//(2**(29-i))==1:
        k.append(1)
        num%=(2**(29-i))
    else:
        k.append(0)
        num%=(2**(29-i))
        
ans=0
for a,b in L:
    if K|a==K:
        ans+=b
NUM=0
for i in range(30):
    if k[i]==1:
        cnt=0
        NUM+=2**(29-i)
        for a,b in L:
            if K-2**(29-i)|a<NUM:
                cnt+=b
        if ans<cnt:
            ans=cnt
        #print(cnt,i,K-2**(29-i))
    
print(ans)
#print(k)

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cerr << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;
#define DBG(x) cerr << x << endl;

/*
	http://abc072.contest.atcoder.jp/tasks/abc072_b
*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
	//freopen("tmp.out", "w", stderr);
#endif
	string s;
	cin >> s;

	for(int i = 0; i < sz(s); ++i)
		if(i % 2 == 0) cout << s[i];
	cout << flush;

	return 0;
}

Measured memory_bytes: 592
import numpy as np
 
data = int(input())
array = np.fromiter(map(int, input().split()), np.int64)
 
result = 0
for bit in range(60):
    array01 = int((array & 1).sum())
    result = (result + array01 * (data - array01) * (1 << bit)) % 1000000007
    array >>= 1
print(result)

Measured memory_bytes: 44524
(def N (read))
(def K (read))
(println (loop [n 0 ans 0]
  (if (>= n N)
    ans
    (let [h (read)]
      (if (>= h K) 
        (recur (+ n 1) (+ ans 1)) 
        (recur (+ n 1) ans))))))

Measured memory_bytes: 81132
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

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

int main() {
  vector<int> a(3);
  REP(i,3) cin>>a[i];
  int ans = 1<<30;
  do {
    int tmp = 0;
    tmp += abs(a[1]-a[0]);
    tmp += abs(a[2]-a[1]);
    ans = min(ans, tmp);
  } while(next_permutation(a.begin(), a.end()));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
   string s;
  cin>>n>>s;
  for(int i=0;i<s.length();i++){
  	int sum=((int)s[i])+n;
  	if(sum<=90)
  	 cout<<(char)sum;
  	 else
  	 cout<<char(64+(sum%90));
  }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  vector<string> vec(H);
  for(int i = 0; i < H; i++){
    cin >> vec.at(i);
  }
  for(int i = 0; i < W+2; i++){
    cout << '#';
  }
  cout << endl;
  for(int i = 0; i < H; i++){
    cout << '#' << vec.at(i) << '#' << endl;
  }
  for(int i = 0; i < W+2; i++){
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var a = input.split('\n');
for (var i=0;i<a.length;i++){
    var b = a[i].split(' ').map(Number);
    var h = b[0];
    var w = b[1];
    if(h === 0 && w === 0){
        break;
    }
    console.log(Array(h + 1).join(Array(w + 1).join('#') + '\n'));
}


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

using namespace std;

typedef pair<int,int> P;

int N,H;
int a[100005],b[100005];
P x[200005];

int main() {
  
cin>>N>>H;

for(int i=0; i<N; i++){
  scanf("%d %d",&a[i],&b[i]);
}

for(int i=0; i<N; i++){
  x[i].first=a[i];
  x[i].second=0;
}

for(int i=0; i<N; i++){
  x[i+N].first=b[i];
  x[i+N].second=1;
}

sort(x,x+2*N);

int damage=0; int cnt=0;

int j;
for(int i=2*N-1; i>=0; i--){
  if(x[i].second==0){
    j=i; break;
  }
}

for(int i=2*N-1; i>=0; i--){
  damage+=x[i].first; cnt++;

  if(damage>=H){
    cout<<cnt<<endl; return 0;
  }

  if(i==j) break;

}

  int n=0;

  if((H-damage)%x[j].first==0){
    n=(H-damage)/x[j].first;
  }
  else{
    n=(H-damage)/x[j].first;
    n++;
  }
    
  cout<<cnt+n<<endl; 
  
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
const int maxn=57;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll d[maxn];
ll x[maxn];
ll y[maxn];
ll z[maxn][maxn];

int n, m;
typedef long long ll;
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
    {
		scanf("%lld%lld", &a[i], &b[i]);
		c[i] = a[i];
		d[i] = b[i];
	}
	sort(c, c + n);
	sort(d, d + n);
	ll ans=3999999996000000009;

    for(int i=0;i<n;i++)
    {
        for(int ii=i+1;ii<n;ii++)
        {
            for(int j=0;j<n;j++)
            {
                for(int jj=j+1;jj<n;jj++)
                {
                    ll min1=c[i];
                    ll min2=c[ii];
                    ll max1=d[j];
                    ll max2=d[jj];
                    ll cnt=0;
                    for(int p=0;p<n;p++)
                    {
                        if(a[p]>=min1&&a[p]<=min2&&b[p]>=max1&&b[p]<=max2)
                        {
                            cnt++;
                            //printf("fgdgf\n");
                        }
                        if(cnt>=m)
                        ans=min(ans,(max2-max1)*(min2-min1));
                    }
                }
            }
        }
    }

printf("%lld\n",ans);
return 0;

}

Measured memory_bytes: 256
s_ = input()
t = input()
flag = False
ans = 'z' * 51
for i in range(len(s_) - len(t) + 1):
    for j in range(len(t)):
        if s_[i + j] != '?' and s_[i + j] != t[j]:
            break
    else:
        flag = True
        s = list(s_[:i] + t + s_[i + len(t):])
        for i in range(len(s)):
            if s[i] == '?':
                s[i] = 'a'
        x = ''.join(s)
        ans = min(ans, x)
if flag:
    print(ans)
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064