akhauriyash/Code-Regression huggingface dataset:
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defmacro aif (expr then else)
    `(let ((it ,expr))
       ,then
       ,else))

(defun main(x)
  (labels ((f (x)
             (if (evenp x)
                 (ash x -1)
                 (+ (* x 3) 1)))
           (solve (lst)
             (let ((next (f (car lst))))
               (or (when (member next lst)
                     (1+ (length lst)))
                   (solve (cons next lst))))))
    (solve (list x))))


(princ (main (read)))


Measured memory_bytes: 16872
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n;
    cin >> n;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    constexpr auto M = 1000000007;
    using Key = std::tuple<int64_t, int64_t, int64_t>;
    unordered_map<Key, int64_t, boost::hash<Key>> m;
    // vector<vector<pair<Key, int64_t>>> v(n);
    m[Key{0, 0, 0}] = 1;
    // v[0].emplace_back(Key{0, 0, 0}, 0);
    // v[0].emplace_back(Key{0, 0, 0}, 1);
    // v[0].emplace_back(Key{0, 0, 0}, 2);
    for (auto p : a | indexed(0)) {
        auto i = p.index();
        auto aa = p.value();

        if (aa > i) {
            cout << 0 << endl;
            return 0;
        }

        decltype(m) m2;
        for (const auto& kv : m) {
            const auto& key = kv.first;
            auto num = kv.second;
            if (std::get<0>(key) == aa) {
                auto next_key =
                        std::make_tuple(std::get<0>(key) + 1, std::get<1>(key),
                                        std::get<2>(key));
                m2[next_key] += num;
                m2[next_key] %= M;
            }

            if (std::get<1>(key) == aa) {
                auto next_key =
                        std::make_tuple(std::get<0>(key), std::get<1>(key) + 1,
                                        std::get<2>(key));
                m2[next_key] += num;
                m2[next_key] %= M;
            }

            if (std::get<2>(key) == aa) {
                auto next_key =
                        std::make_tuple(std::get<0>(key), std::get<1>(key),
                                        std::get<2>(key) + 1);
                m2[next_key] += num;
                m2[next_key] %= M;
            }
        }

        m = std::move(m2);
    }

    int64_t ans = 0;
    for (const auto& kv : m) {
        ans += kv.second;
        ans %= M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  char c[300];
  char res[300]={};
  rep(i,2*n) res[i]='c';
  P t;
  int l=0,r=n;
  cout<<'?';
  rep(i,n){
    cout<<' '<<i+1;
  }
  cout<<endl;
  string s;
  cin>>s;
  if(s=="Red") c[0]='R';
  else c[0]='B';

  while(r-l>1){
    
    int m=(r+l)/2;
    
    cout<<'?'; 
    rep(i,n){
      cout<<' '<<i+m+1;
    }
    cout<<endl;
    string s;
    cin>>s;
    if(s=="Red") c[m]='R';
    else c[m]='B';
    if(c[0]==c[m]){
      l=m;
    }else{
      r=m;
    }
  }
 
  t=P(l+1,l+n-1);  
  //cout<<l<<' '<<l+n-2<<endl;

  vi red,blue;
  rep(i,2*n){
    if(t.F<=i&&i<=t.S) continue;
    cout<<'?';
    FOR(j,t.F,t.S+1){
      cout<<' '<<j+1;
    }
    cout<<' '<<i+1<<endl;
    string s;
    cin>>s;
    if(s=="Red"){
      res[i]='R';
      red.PB(i);
    }
    else{
      res[i]='B';
      blue.PB(i);
    }
  }

  rep(i,2*n){
    if(t.F<=i&&i<=t.S){
      cout<<'?';
      rep(j,n/2) cout<<' '<<red[j]+1;
      rep(j,n/2) cout<<' '<<blue[j]+1;
      cout<<' '<<i+1<<endl;
      string s;
      cin>>s;
      if(s=="Red"){
        res[i]='R';
        red.PB(i);
      }
      else{
        res[i]='B';
        blue.PB(i);
      }
    }
  }

  cout<<'!'<<' '<<res<<endl;


}

Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n], b[n], c[n], dp[n][3];
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i]>>c[i];
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    for(int i=1; i<n; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][2], dp[i-1][0]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

Measured memory_bytes: 2560
/*  ex3_4
    person_A  */
#include<stdio.h>
int main(void){
    int number,between19=1;
    //整数Nの入力
    scanf("%d",&number);
    //numberを1以上9以下を順に動くbetween19で割っていき、割り切れてかつ商が1以上9以下である時 Yes を出力
    while(between19<=9){
        if(number%between19==0&&1<=number/between19&&number/between19<=9){
            printf("Yes\n");
            return 0;
        }
        between19++;
    }
    //条件を満たせなかった場合 No を出力
    printf("No\n");
    return 0;
}

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

long    Cal(vector<long> &A, long b) {
        long S=0;
        for (int i=1; i<A.size(); i++) {
                S += abs(A.at(i)-(b+i));
        }
        return S;
}

int     main() {
        int N;
        cin >>N;
        vector<long> A(N+1, 0);
        for (int i=1; i<=N; i++) {
                cin >>A.at(i);
        }
        vector<long> B(N);
        for (int i=1; i<=N; i++) B.at(i-1)=A.at(i)-i;
        sort(B.begin(), B.end());
        long b1=B.at((N+1)/2-1);
        cout <<Cal(A, b1) <<endl;
        return 0;
};

Measured memory_bytes: 3328
//https://atcoder.jp/contests/m-solutions2019/tasks/m_solutions2019_b

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        int win = 0;
        for (int i=0;i<S.length();i++){
            if (String.valueOf(S.charAt(i)).equals("o")){
                win++;
            }
        }
        if (win>7 || win+(15-S.length())>7){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

const int N = 5e5+7;
int tr[4*N];

void update(int u, int st, int en, int idx, int x) {
    if (st == en)   tr[u] = x;
    else {
        int mid = (st+en)/2;
        if (idx <= mid) update(2*u, st, mid, idx, x);
        else             update(2*u+1, mid+1, en, idx, x);
        tr[u] = max(tr[2*u], tr[2*u+1]);
    }
}

int query(int u, int st, int en, int l, int r) {
    if (r<st || en<l)           return 0;
    else if (l<=st && en<=r)    return tr[u];
    else {
        int mid = (st+en)/2;
        return max(query(2*u, st, mid, l, r), query(2*u+1, mid+1, en, l, r));
    }
}

int a[N], b[N], out[N];
vector<int> in[N];
void add(int u, int v) {
    out[u]++;
    in[v].push_back(u);
}

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

    int n, k;
    cin>>n>>k;

    for (int i=1; i<=n; i++) {
        cin>>a[i];
        b[a[i]] = i;
    }

    for (int i=1; i<=n; i++) {
        int l1 = query(1,1,n,b[i]-k+1,b[i]);
        int l2 = query(1,1,n,b[i],b[i]+k-1);

        if (l1)        add(b[l1], b[i]);
        if (l2)        add(b[l2], b[i]);
        update(1,1,n,b[i],i);
    }

    vector<int> ans;
    priority_queue<int> pq;
    for (int i=1; i<=n; i++)
        if (out[i] == 0)
            pq.push(i);

    while (pq.size()) {
        int u = pq.top();
        pq.pop();
        ans.push_back(u);

        for (int v: in[u]) {
            out[v]--;
            if (out[v] == 0)    pq.push(v);
        }
    }

    reverse(ans.begin(), ans.end());
    for (int i=1; i<=n; i++)    a[ans[i-1]] = i;
    for (int i=1; i<=n; i++)    cout<<a[i]<<"\n";
}


Measured memory_bytes: 43336
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll H, W, K; cin >> H >> W >> K;
  vector<string> S(H);
  rep(i, H) cin >> S[i];

  ll cmin = INFll;
  rep(bit, 1<<(H-1)) {
    int m = __builtin_popcount(bit);
    VV x(m+1, V(W));

    int b = bit;
    int i = 0;
    rep(j, H) {
      rep(k, W) x[i][k] += S[j][k] - '0';
      if (b % 2 == 1) i++;
      b /= 2;
    }

    bool ng = false;
    rep(i, m+1) rep(j, W) {
      if (x[i][j] > K) ng = true;
    }
    if (ng) continue;

    ll ans = 0;
    V sum(m+1);
    rep(i, W) {
      bool cut = false;
      rep(j, m+1) if (sum[j] + x[j][i] > K) cut = true;
      if (cut) {
        rep(j, m+1) sum[j] = x[j][i];
        ans++;
      }
      else rep(j, m+1) sum[j] += x[j][i];
    }
    chmin(cmin, ans + m);
  }
  cout << cmin << endl;
  return 0;
}


Measured memory_bytes: 384
function main(input) {
  var x = 0;
  for (i = 0; i < input.length; i++)
    {
      if (input[i] == 1)
      {
        x += 1;
      }
    }
  console.log(x);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7752
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
#define lr rt<<1
#define rr rt<<1|1
using namespace std;
const int N=2e5+10;
int n,m;
int a[N],b[N];
struct SegTree{
    struct node{
        ll f,sum;
    }tree[N<<2];
    void pushdown(int rt)
    {
        tree[lr].f+=tree[rt].f;
        tree[rr].f+=tree[rt].f;
        tree[lr].sum+=tree[rt].f;
        tree[rr].sum+=tree[rt].f;
        tree[rt].f=0;
    }
    void upd(int rt,int l,int r,int L,int R,ll val)
    {
        if(r<L||l>R)
            return;
        if(L<=l&&r<=R)
        {
            tree[rt].f+=val;
            tree[rt].sum+=val;
            return;
        }
        pushdown(rt);
        int m=(l+r)>>1;
        upd(lr,l,m,L,R,val);
        upd(rr,m+1,r,L,R,val);
        tree[rt].sum=min(tree[lr].sum,tree[rr].sum);
    }
    ll qry(int rt,int l,int r,int L,int R)
    {
        if(r<L||l>R)
            return 1e18;
        if(L<=l&&r<=R)
            return tree[rt].sum;
        pushdown(rt);
        int m=(l+r)>>1;
        return min(qry(lr,l,m,L,R),qry(rr,m+1,r,L,R));
    }
    void upd(int L,int R,long long val)
    {
        upd(1,1,m,L,R,val);
    }
    long long qry(int L,int R)
    {
        return qry(1,1,m,L,R);
    }
}t1,t2;
int main(void)
{
    sync;
    cin>>n>>m;
    for(int i=1;i<=m;++i)
        t2.upd(i,i,-i);
    for(int i=0;i<n;++i)
    {
        cin>>a[i]>>b[i];
        int r=b[i]+1;
        if(r<=m)
        {
            ll minx=t2.qry(1,b[i]);
            ll now=t1.qry(r,r);
            if(now>minx+r)
            {
                t1.upd(r,r,minx+r-now);
                t2.upd(r,r,minx-t2.qry(r,r));
            }
        }
        t1.upd(a[i],b[i],1e9);
        t2.upd(a[i],b[i],1e9);
        t1.upd(1,m,1);
        t2.upd(1,m,1);
        ll res=t1.qry(1,m);
        if(res>=1e9)
            cout<<-1<<endl;
        else
            cout<<res<<endl;
    }
    return 0;
}

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

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

    if (b % a == 0){
        cout << a + b << endl;
    }else{
        cout << b - a << endl;
    }

    return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(" ").map(Number);
console.log(function(a, b, c) {
  var count = c % a == 0 ? 1 : 0;
  if (a == b) {
    return count;
  } else {
    return count + arguments.callee(a + 1, b, c);
  }
}(input[0], input[1], input[2]));

Measured memory_bytes: 19800
n = int(input())
a_list = [int(x) for x in input().split()]
ans = 30
for a in a_list:
    temp = 0
    while True:
        a, mod = divmod(a, 2)
        if mod == 0:
            temp += 1
            if temp >= ans:
                break
        else:
            if temp < ans:
                ans = temp
            break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  int ans=0;
  int tar=2;
  while(1){
    if(tar>n){
      ans=tar/2;
      break;
    }
    tar*=2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Double> list = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			list.add(sc.nextDouble());
		}
		Collections.sort(list);
		double ans = 0;
		ans += list.get(0) / Math.pow(2, n - 1);
		double div = n - 1;
		for(int i = 1; i < n; i++) {
			ans += list.get(i) / Math.pow(2, div);
			div--;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()

int check(int x){
	string s;
	cout << x << endl << flush;
	cin >> s;
	if(s == "Vacant")return 0;
	else if(s == "Male")return 1;
	else return 2;
}

int main(void){
	int N;cin >> N;
	int left = 0;
	int right = N;
	int x = check(0);
	if(x == 0)return 0;
	else if(x == 1){
		while(true){
			int mid = (left+right)/2;
			int next = check(mid);
			if(mid%2==0){
				if(next==0)return 0;
				else if(next==1)left = mid;
				else right = mid;
			}else{
				if(next==0)return 0;
				else if(next==2)left = mid;
				else right = mid;
			}
		}
	}else{
		while(true){
			int mid = (left+right)/2;
			int next = check(mid);
			if(mid%2==0){
				if(next==0)return 0;
				else if(next==2)left = mid;
				else right = mid;
			}else{
				if(next==0)return 0;
				else if(next==1)left = mid;
				else right = mid;
			}
		}
	}
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define suma (a+b+c)
const int SIZE = 304;


double dp[SIZE][SIZE][SIZE];
bool vis[SIZE][SIZE][SIZE];

int licz1 = 0, licz2 = 0, licz3 = 0;
int n, a;

    void input(){
        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> a;
            if(a == 1) licz1++;
            if(a == 2) licz2++;
            if(a == 3) licz3++;
        }
    }

    double policz(int a, int b, int c){
        if(a == 0 && b == 0 && c == 0)  return 0;
        if(a < 0 || b < 0 || c < 0)     return 0;
        if(vis[a][b][c])                return dp[a][b][c];
        
        vis[a][b][c] = true;

        dp[a][b][c]=((double)n/suma)+policz(a-1,b,c)*((double)a/suma)+policz(a+1,b-1,c)*((double)b/suma)+policz(a,b+1,c-1)*((double)c/suma); 
        return dp[a][b][c];
    }

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    input();

    cout << setprecision(10) << policz(licz1, licz2, licz3);
    return 0;
}

Measured memory_bytes: 246016
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    
}


Measured memory_bytes: 23124
/*
I just got lost in thought. It was unfamiliar territory.
- Steven Wright
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1234567891;
//g++ -std=c++11 your_file.cpp -o your_program

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
    int n, t;
    cin >> n >> t;
    vi vec;
    REP(i, n){
        int a, b;
        cin >> a >> b;
        if (b > t) continue;
        else {
            vec.pb(a);
        }
    }
    if (SZ(vec) == 0){
        cout << "TLE" << endl;
        return 0;
    }
    sort(ALL(vec));
    cout << vec[0] << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split(" ")))
b1 = 0
b2 = 0
b4 = 0
for i in range(len(a)):
    if a[i]%4 == 0:
        b4 += 1
    elif a[i]%2==0:
      b2 += 1
    else:
        b1 +=1
b1 += b2 % 2
if b1==1:
  if b4>=1:
    print("Yes")
  else:
    print("No")
elif b4 >= b1 - 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
import numpy as np

a = []
for i in range(3):
    val = list(map(int, input().split()))
    a.append(val)
a = np.array(a)

n = int(input())

for j in range(n):
    val2 = int(input())
    if np.any(a == val2):
        a = np.where(a==val2, -1, a)

bingo = False
for i in range(3):
    if np.all(a[i,:] == -1):
        bingo = True
        break
    if np.all(a[:,i] == -1):
        bingo = True
        break
if a[0,0] == -1 and a[1,1] == -1 and a[2,2] == -1:
    bingo = True
if a[0,2] == -1 and a[1,1] == -1 and a[2,0] == -1:
    bingo = True

if bingo:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 12516
#include <bits/stdc++.h>
 
using namespace std;
 
int n, ta;
long long ans;
set< int > s;
multiset< int > ss;
multiset< int >::iterator it;
 
int main() {
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &ta);
		if (s.find(ta) != s.end())
			ss.insert(ta), s.erase(ta);
		else
			s.insert(ta);
	}
	if (ss.size() < 2)
		printf("0\n");
	else {
		ans = *ss.rbegin();
		it = ss.end();
		it--;
		ss.erase(it);
		printf("%lld\n", ans * *ss.rbegin());
	}
}

Measured memory_bytes: 4992
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	String st;
	try{
	    while(true){
		st=sc.readLine();
		if(st.equals("#"))
		    break;
		char[] c = st.toCharArray();
		int count=0, t = check(c[0]);
		for(int i=1; i<c.length; i++)
		    if(t != check(c[i])){
			count++;
			t = check(c[i]);
		    }
		System.out.println(count);
	    }
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
    private static int check(char c){
	if(c=='q'||c=='w'||c=='e'||c=='r'||c=='t'||c=='a'||c=='s'||c=='d'||c=='f'||c=='g'||c=='z'||c=='x'||c=='c'||c=='v'||c=='b')
	    return 1;
	else
	    return 2;
    }
}

Measured memory_bytes: 9616
#include<bits/stdc++.h>
#define M 51
#define LL long long
using namespace std;
const LL mod=1e9+7;
int n,K;
LL dp[M][M][M*M+M];
void Add(LL &x,LL y){
	x+=y;
	if(x>=mod)x-=mod;
}
int main(){
	scanf("%d%d",&n,&K);
	if(K&1)return puts("0"),0;
	K>>=1;
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<i;j++)
			for(int q=0;q<=K;q++){
				Add(dp[i][j][q+j],dp[i-1][j][q]);
				Add(dp[i][j+1][q+j+1],dp[i-1][j][q]);
				Add(dp[i][j][q+j],dp[i-1][j][q]*2*j%mod);
				if(j)Add(dp[i][j-1][q+j-1],dp[i-1][j][q]*j*j%mod);
			}
	printf("%lld\n",dp[n][0][K]);
	return 0;
}

Measured memory_bytes: 51840
use std::io::{BufRead, Write};

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

    let (k, q): (usize, usize) = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let d: Vec<usize> = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    for _ in 0..q {
        let (n, x, m): (usize, usize, usize) = {
            let mut buf = String::new();
            reader.read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
            )
        };
        let x = x % m;
    
        let mut res = 0;
        let (mut quo, mut rem) = (0, x);
        for i in 0..(std::cmp::min(n - 1, k)) {
            let c = 1 + ((n - 1) - (i + 1)) / k;
            let d = d[i] % m;
            if d == 0 {
                res += c;
            } else {
                quo += (rem + d * c) / m;
                rem = (rem + d * c) % m;
            }
        }

        let ans = (n - 1) - (res + quo - x / m);
        writeln!(writer, "{}", ans).unwrap();
    }
}

Measured memory_bytes: 2288
/* h-ex9_2
   Ohshima */

#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node{
  char elem;
  struct node *next;
}node;

//スタックにデータを追加
void push(node **first, char elem){
  //追加する分の領域を確保
  node *new = calloc(1, sizeof(node));
  if(new == NULL) exit(1);
  new->elem = elem;
  new->next = *first;
  *first = new;
}

//スタックからデータを取り出す
void pop(node **first){
  node *tmp = *first;
  if(tmp == NULL) exit(1);
  *first = tmp->next;
  //取り出したノードのメモリを解放
  free(tmp);
}

int main(void){
  char tmp;
  //最初のノードの指す先
  node *first = NULL;
  int ans = 0;
  //1文字ずつ標準入力から受け取り以下を実行
  while(scanf("%c", &tmp) != EOF && tmp != '\n'){
    //まずスタックにノードを追加
    push(&first, tmp);
    //2個以上のキューブが積まれており、かつ、上から2個のキューブの色が異なるとき
    if((first->next != NULL) && (first->elem != first->next->elem)){
      //スタックから2つのデータを取り出し、取り除いたキューブの個数をカウントする
      pop(&first);
      pop(&first);
      ans += 2;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 4720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define Jrep(j,n) for(int j=0;j<(n);j++)
#define Jreps(j,n) for(int j=1;j<=(n);j++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
  
using namespace std;    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin>>x;
    if(x%100<=5*(x/100)) cout<<1<<'\n';
    else cout<<0<<'\n';
    return 0;
}


Measured memory_bytes: 256
module Main where

import qualified Data.Vector as Vector
import Data.List as List
import Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as BS
import Data.Maybe as Maybe

main :: IO ()
main =
    print =<< (\n -> (n - 2) * 180) <$> getInt

getInt :: IO Int
getInt = read <$> BS.unpack <$> BS.getLine

splitLine :: IO [BS.ByteString]
splitLine = BS.words <$> BS.getLine

getInts :: IO (V.Vector Int)
getInts = V.fromList <$> List.map fst <$> Maybe.mapMaybe BS.readInt <$> splitLine

solve :: V.Vector Int -> IO ()
solve v = print (if (v V.! 0 == 1) && (v V.! 1 == 1) then 1000000 else V.foldl (\a b -> a + (prize b)) 0 v)

prize :: Int -> Int
prize 1 = 300000
prize 2 = 200000
prize 3 = 100000
prize _ = 0


Measured memory_bytes: 508
#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;
typedef pair<lint, lint> pll;
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 = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int K;

void solve(){
    string s, t;
    cin >> s >> t;
    if(s == t){
        printf("%d\n", 0);
        return;
    }
    map<string, int> dist;
    queue<string> que;
    dist[s] = 0;
    que.push(s);
    while(!que.empty()){
        auto a = que.front();
        que.pop();
        int cur = 0;
        while(a[cur] == t[cur]) ++cur;
        int add = (t[cur] - a[cur] + 10) % 10;
        int sub = (a[cur] - t[cur] + 10) % 10;
        string b = a;
        For(i, cur, K){
            b[i] = (b[i] - '0' + add) % 10 + '0';
            if(b == t){
                printf("%d\n", dist[a] + 1);
                return;
            }
            if(dist.find(b) == dist.end()){
                dist[b] = dist[a] + 1;
                que.push(b);
            }
        }
        b = a;
        For(i, cur, K){
            b[i] = (b[i] - '0' - sub + 10) % 10 + '0';
            if(b == t){
                printf("%d\n", dist[a] + 1);
                return;
            }
            if(dist.find(b) == dist.end()){
                dist[b] = dist[a] + 1;
                que.push(b);
            }
        }
    }
}

int main(){
    while(scanf("%d", &K) && K){
        solve();
    }
}


Measured memory_bytes: 3960
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    s = input()
    a = ["Sunny", "Cloudy", "Rainy"]
    hoge = dict(zip(a,[1,2,0]))
    print(a[hoge[s]])

if __name__ == '__main__':
    main()


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(string s){
	bool isEven = s.size() % 2 == 0;
  bool isEqual = s[0] == s[s.size()-1];
  
  bool ans = isEven ^ isEqual;
  
  cout << (!ans?"First":"Second") << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	solve(s);
	return 0;
}


Measured memory_bytes: 512
def main():
    X, K, D = map(int, input().split())

    r = X // D
    if abs(r) > K:
        print(abs(X) - K * D)
        exit()
    a = X - r * D
    if (K - r) % 2 == 0:
        print(a)
    else:
        print(abs(D - a))
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 61672
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;
#define ALL(a)  (a).begin(),(a).end()


int main(){
  ll n,m,k;cin>>n>>m>>k;
  vector<ll> a(n),b(m);
  ll ans = 0;
  for (auto && i : a) {
    cin >> i;
  }
  for (auto && i : b) {
    cin >> i;
  }
  vector<ll> ruisekiwa(n),ruisekiwb(m);
  ruisekiwa.at(0) = a.at(0);
  ruisekiwb.at(0) = b.at(0);
  for (int i = 1; i < n; i++) {
    ruisekiwa.at(i) = ruisekiwa.at(i-1) + a.at(i);
  }
  for (int i = 1; i < m; i++) {
    ruisekiwb.at(i) = ruisekiwb.at(i-1) + b.at(i);
  }
  for (int i = 0; i < m; i++) {
    if( ruisekiwb.at(i) > k)
    {
      ans = i;
      break;
    }
    if (i == m-1)
    {
      ans = m;
    }
  }

  for (int i = 0; i < n; i++) {
    ll tmp = ruisekiwa.at(i);
    ll j = (int)(upper_bound(ALL(ruisekiwb),k-tmp)-ruisekiwb.begin());
    //cout << "i = " << i << "j = " <<  j << endl;
    if (j > 0) {
      //cout << ruisekiwa.at(i) << " + " << ruisekiwb.at(j-1) << " < " << k << endl;

      ans = max(i+j+1,ans);
    }
    else if (tmp <= k)
    {
      ans = max((ll)i+1,ans);
    }
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 9520
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n, p;
int a[N], odd;
ll c[51][51];

int main(){
  scanf("%d %d", &n, &p);
  for(int i = 1; i <= n; ++i){
    scanf("%d", a + i);
    odd += a[i] % 2 == 1;
  }
  for(int i = 0; i <= n; ++i){
    c[i][0] = c[i][i] = 1;
    for(int j = 1; j < i; ++j){
      c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
    }
  }
  ll ans = 0;
  for(int cnt = p; cnt <= odd; cnt += 2){
    ans += c[odd][cnt] * 1ll * (1LL << (n - odd));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,n;
    cin >> h >> n;
    int sum=0;
    rep(i,n){
        int m;
        cin >> m;
        sum+=m;
    }
    if(sum>=h){
        cout <<"Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3620
// include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

// repetition
// ----------------------------------------------------------------------------
#define FOR(i, a, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGINT(x) printf("%d\n", x);
#define DEBUGFLOAT(x) printf("%f\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORINT(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORFLOAT(i, a, b,x ) FOR(i, a, b){ printf("%f ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPINT(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPFLOAT(i, n, x) REP(i, n){ printf("%f ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    bool ly[3000];
    bool flag;
    bool put;
    int i;
    int a, b;

    memset(ly, false, sizeof(ly));

    for (i = 1; i < 3001; ++i){
        if ((i % 4) == 0){
            if ((i % 100) == 0){
                if ((i % 400) == 0){
                    ly[i] = true;
                }
            }else {
                ly[i] = true;
            }
        }
    }
    
    put = false;

    while (1){
        scanf("%d %d", &a, &b);

        if (a == 0 && b == 0){
            break;
        }

        flag = false;

        if (put == true){
            printf("\n");
        }

        for (i = a; i <= b; ++i){
            if (ly[i] == true){
                printf("%d\n", i);
                flag = true;
            }
        }

        if (flag == false){
            printf("NA\n");
        }
        
        put = true;
        
    }

    return 0;  

}

Measured memory_bytes: 0
using System;

class Program
{
 static void Main(String[] args)
 {
   var num = int.Parse(Console.ReadLine());
   var cnt = 0;
   long power = 1;
   
   for( cnt = 1; cnt <= num; cnt++ )
   {
     power = (power * cnt) % 1000000007;
   }
   
   Console.WriteLine(power);
 }
}

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

using namespace std;

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

  int sum = 0;
  for (int i = 1; i <= N; i++) {
    string s = to_string(i);
    if (s.length() % 2 == 1) sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
R, G, B, N = map(int, input().split())

box = sorted([R,G,B],reverse=True)

count = 0
for x in range(0,N+1,box[0]):
    for y in range(0,N+1 - x ,box[1]):
        z = (N - x - y) / box[2]
        if z >= 0 and z.is_integer():
            count += 1
print(count)

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

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

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

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

    if (a > b) {
        temp = a;
        a = b;
        b = temp;
    }

    if (b > c) {
        temp = b;
        b = c;
        c = temp;
    }

    if (a > b) {
        temp = a;
        a = b;
        b = temp;
    }

    cout << a << ' ' << b << ' ' << c << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,m;
    cin>>n>>m;
    ll res=1;
    if(abs(n-m)>1)res=0;
    if(n==m)res*=2;
    rep(i,n){
        res*=i+1;
        res%=MOD;
    }
    rep(i,m){
        res*=i+1;
        res%=MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }
    cout << s;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long double a,b;
	cin>>a>>b;
	cout<<fixed<<setprecision(0)<<floor(a*b);
		
	return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 
#define CERR if(false) cerr

using namespace std;

int main(){

    int h,w;
    cin >> h >> w;

    vector<string> s;
    vector<vector<int>> l;

    vector<int> tmpv;

    int white = 0;

    rep(i,w){
        tmpv.pback(INT_MAX);
    }

    rep(i,h){
        string tmp;
        cin >> tmp;
        s.pback(tmp);
        l.pback(tmpv);

        rep(j,w){
            if(tmp[j] == '.') white++;
        }
    }

    queue<pair<int,pair<int,int>>> q;
    q.push(mpair(1, mpair(0,0)));

    while(!q.empty()){

        int tmpl = q.front().first;
        int tmpy = q.front().second.first;
        int tmpx = q.front().second.second;

        if(0 <= tmpy && tmpy < h && 0 <= tmpx && tmpx < w && s[tmpy][tmpx] == '.' && l[tmpy][tmpx] > tmpl){
            l[tmpy][tmpx] = tmpl;

            q.push(mpair(tmpl + 1, mpair(tmpy + 1, tmpx)));
            q.push(mpair(tmpl + 1, mpair(tmpy - 1, tmpx)));
            q.push(mpair(tmpl + 1, mpair(tmpy, tmpx + 1)));
            q.push(mpair(tmpl + 1, mpair(tmpy, tmpx - 1)));
            
        }

        q.pop();
    }

    if(l[h - 1][w - 1] == INT_MAX){
        cout << -1 << endl;
    }else{
        cout << white - l[h - 1][w - 1] << endl;
    }

    return 0; 
}

Measured memory_bytes: 256
def main():
  N=int(input())
  a = [int(s) - 1 for s in input().split()]
  result = 0
  for i in range(N):
    if a[i] != (i - result):
      result += 1

  if result == N:
    print(-1)
  else:
    print(result)  

if __name__=='__main__':
  main()

Measured memory_bytes: 77644
#include <stdio.h>
#define N 36

void bubbleSort(int V[N],char S[N],int n){
	
	int temp;
	char ctemp;
	for(int i = 0; i < n-1; i++){
		for(int j = n-1; j > i; j--){
			if( V[j] < V[j-1]){
				temp = V[j]; ctemp = S[j];
				V[j] = V[j-1]; S[j] = S[j-1];
				V[j-1] = temp; S[j-1] = ctemp;
			}
		}
	}
	
}

void selectionSort(int V[N],char S[N],int n){
	
	int temp,min;
	char ctemp;
	for( int i = 0; i < n; i++){
		min = i;
		for( int j = i; j < n; j++){
			if( V[j] < V[min] ) min = j;
		}
		if( min != i ){
			temp = V[i]; ctemp = S[i];
			V[i] = V[min]; S[i] = S[min];
			V[min] = temp; S[min] = ctemp;
		}
	}
	
}

int check_stable(int v[N], char s[N], int v1[N], char s1[N], int n){
	
	char unsorted[4], sorted[4];
	
	for(int i = 1; i < 10; i++){
		int unsorted_c = 0, sorted_c = 0;
		for(int j = 0; j < n; j++){
			if( v[j] == i ){
				unsorted[unsorted_c] = s[j];
				unsorted_c++;
			} 
			if( v1[j] == i ){
				sorted[sorted_c] = s1[j];
				sorted_c++;
			} 
		}
		for(int j = 0; j < unsorted_c; j++){
			if( unsorted[j] != sorted[j] ) {
				return -1;
			}
		}
	}
	
	return 1;
	
}

int main(void){
	
	int n;
	char suit[N],suit1[N],suit2[N];
	int value[N],value1[N],value2[N];
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf(" %c", &suit[i]);
		scanf("%d", &value[i]);
		suit1[i] = suit[i]; suit2[i] = suit[i];
		value1[i] = value[i]; value2[i] = value[i];
	}
	
	bubbleSort(value1, suit1, n);
	selectionSort(value2, suit2, n);
	for(int i = 0; i < n; i++){
		printf("%c", suit1[i]);
		printf("%d", value1[i]);
		if( i != n-1 ) printf(" ");
	}
	printf("\n");
	if( check_stable(value, suit, value1, suit1, n) == 1 ){
		printf("Stable\n");
	} else {
		printf("Not Stable\n");
	}
	for(int i = 0; i < n; i++){
		printf("%c", suit2[i]);
		printf("%d", value2[i]);
		if( i != n-1 ) printf(" ");
	}
	printf("\n");
	if( check_stable(value, suit, value2, suit2, n) == 1 ){
		printf("Stable\n");
	} else {
		printf("Not stable\n");
	}
	
}


Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s; cin >> s;
  	int n=s.length();
  	int a[26]={}; char answ;
  	for(int i=0;i<n;i++) a[s[i]-'a']=1;
  	string ans="None";
  	for(int i=0;i<26;i++){
      answ=i+97;
      if(a[i]!=1) {ans=answ; break;}
    }
  	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
	int H,W;
	cin >> H >> W;
	while(H != 0 || W != 0){
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i == 0 || i == H-1 || j == 0 || j == W-1) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	return 0;
}


Measured memory_bytes: 3100
MOD = 10 ** 9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))

dp = [0 for _ in range(k + 1)]
dp[0] = 1
b = [1 for _ in range(k + 2)]
b[0] = 0

for ai in a:
    for i in range(k, -1, -1):
        dp[i] += (b[i] - b[i - min(ai, i)]) % MOD
        dp[i] %= MOD
    for i in range(1, k + 2):
        b[i] = (b[i - 1] + dp[i - 1]) % MOD
        b[i] %= MOD
print(dp[-1])


Measured memory_bytes: 49360
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

void Main() {
    // input
    string s;
    cin >> s;


    // translate
    reverse(s.begin(), s.end());
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    for (int i = 0; i < 4; i++) {
        reverse(divide[i].begin(), divide[i].end());
    }

    bool isDeivided = false;
    for (int i = 0; i < s.length();) {
        isDeivided = false;
        for (int j = 0; j < 4; j++) {
            if (s.substr(i, divide[j].length()) == divide[j]) {
                i += divide[j].length();
                isDeivided = true;
                break;
            }
        }
        if (isDeivided) {
            continue;
        }
        
        cout << "NO" << endl;
        return;
    }

    cout << "YES" << endl;

    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;
struct edge
{
    int a,b,c;
};
vector<vector<pair<int,int> > >adj1,adj2;
edge s[5005];
int dp[2505];
int n,m,p;
int ans=0;
int vis1[2505],vis2[2505];
int mm[2505];

void solve()
{
    for (int i = 0; i < n-1; ++i) {
        for (int j = 0; j < m; ++j) {
            if(dp[s[j].a]!=1e17)
            {
                dp[s[j].b]=min(dp[s[j].b],dp[s[j].a]+s[j].c);
            }
        }
    }

    bool flag=true;
    for (int j = 0; j < m; ++j) {
        if(dp[s[j].a]!=1e17)
        {
            if(dp[s[j].b]>dp[s[j].a]+s[j].c)
            {
                if(mm[s[j].b]==2)
                {
                   flag=false;
                    break;
                }
                dp[s[j].b]=dp[s[j].a]+s[j].c;
            }
        }
    }

    if(!flag)
    {
        ans=-1e17;
    }
    else
    {
        ans=-dp[n-1];
    }
}

void dfs1(int i)
{
    vis1[i]=1;
    mm[i]++;
    for(auto j:adj1[i])
    {
        if(vis1[j.first]==0)
        {
            dfs1(j.first);
        }
    }
}

void dfs2(int i)
{
    vis2[i]=1;
    mm[i]++;
    for(auto j:adj2[i])
    {
        if(vis2[j.first]==0)
        {
            dfs2(j.first);
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>p;

    fill_n(dp,2505,1e17);
    dp[0]=0;
    int x,y,z;
    adj1.resize(n);
    adj2.resize(n);
    for (int i = 0; i < m; ++i) {
        cin>>x>>y>>z;
        x--;
        y--;
        z=p-z;
        adj1[x].push_back({y,z});
        adj2[y].push_back({x,z});
        s[i].a=x;
        s[i].b=y;
        s[i].c=z;
    }

    dfs1(0);
    dfs2(n-1);

    solve();
    if(ans==-1e17)
        cout<<-1;
    else
        cout<<max(0LL,ans);

}

Measured memory_bytes: 896
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define cin_desync()                                                           \
    do {                                                                       \
        ios_base::sync_with_stdio(false);                                      \
        cin.tie(0);                                                            \
    } while (0)

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int sumdigits(int A)
{
    int sum = 0;
    for (; A; A /= 10) {
        sum += A % 10;
    }

    return sum;
}

int main() {
    int N;
    cin >> N;
    int best = 10000000;
    for (int A = 1; A < N; ++A) {
        best = min(best, sumdigits(A) + sumdigits(N - A));
    }

    cout << best << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cctype>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
// for (int i = 0; i < N; ++i) cin >> A[i];
typedef vector<int> vint;
typedef vector<long> vl;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef map<string, int> mapstri;
typedef map<string, int> mapii;

int main () {
    long long k,n;
    cin >> k >> n;
    int A[300000];
    int dis[300000];
    long long max_dis = 0;
    int j;
    long long ans;
    for (int i = 0; i < n; ++i) cin >> A[i];
    for (int i = 0; i < n; ++i) {
        if (i == n-1) {
            dis[i] = k - A[i] + A[0];
        } else {
            dis[i] = A[i + 1] - A[i];
        }
        ans += dis[i];
        if (dis[i] >= max_dis) {
            max_dis = dis[i];
            j = i;
        }
    }
    ans -= dis[j];
    out(ans)
    

    return 0;
}

Measured memory_bytes: 2560