akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include "stdlib.h"
using namespace std;

int S[1000];
int top;

void push(int x){
	S[++top]=x;
}
int pop(){
	return S[top--];
}

int main(){
	int a,b;
	top=0;
	char s[100];
	while(cin>>s){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		} else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	cout<<pop()<<endl;
	return 0;
} 


Measured memory_bytes: 3100
defmodule Main do
  def main do
    [n, _m, x] =
      IO.gets("") |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)

    list =
      Enum.reduce(1..n, [], fn _, acc ->
        [IO.gets("") |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)] ++
          acc
      end)

    Enum.reduce(1..n, [], fn i, acc ->
      combination(list, i) ++ acc
    end)
    |> Enum.filter(&pass?(&1, x))
    |> Enum.map(&bill/1)
    |> Enum.min(fn -> -1 end)
    |> IO.puts()
  end

  defp pass?(list_of_lists, x) do
    List.zip(list_of_lists)
    |> tl()
    |> Enum.map(fn tuple ->
      tuple |> Tuple.to_list() |> Enum.sum()
    end)
    |> Enum.all?(fn sum -> sum >= x end)
  end

  defp bill(list_of_lists) do
    List.zip(list_of_lists) |> hd() |> Tuple.to_list() |> Enum.sum()
  end

  defp combination(_, 0), do: [[]]
  defp combination([], _), do: []

  defp combination([x | xs], n) do
    for(y <- combination(xs, n - 1), do: [x | y]) ++ combination(xs, n)
  end
end

Measured memory_bytes: 32932
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int pos = -1;
  rep(i,S.size()){
    if(i+T.size()>S.size()) continue;
    bool flg = true;
    rep(j,T.size()){
      if(S[i+j] == '?') continue;
      if(S[i+j] != T[j]) flg = false;
    }
    if(flg){
      pos = i;
    }
  }

  if(pos < 0){
    cout << "UNRESTORABLE" << endl;
  }else{
    rep(j,T.size()){
      S[pos+j] = T[j];
    }
    rep(i,S.size()){
      if(S[i] == '?') S[i] = 'a';
    }

    cout << S << endl;
  }
  
  return 0;
}


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

using namespace std;

int main() {
	int n, m;
	scanf("%d", &n);
	m = 3 * n;
	vector<int> a(m);
	for(int i = 0; i < m; i++){
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end());
	long long ans = 0;
	for(int i = 0; i < n; i++){
		ans += a[m - 2 * (i + 1)];
	}
	printf("%lld\n", ans);
	return 0;
}

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

int  main(){
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n){cin>>v[i]; v[i]--;}
  int x=0,ans=0;
  while(true){
    if(v[x]==0){ans=-1;break;}
    else if(v[x]==1){ans++;break;}
    else{ans++;x=v[x];}
    if(ans>n){ans=-1;break;}
  }
  cout<<ans;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A+B>=10){
			System.out.println("error");
		} else{
			System.out.println(A+B);
		}
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

const ll mod=998244353;

ll com(ll a,ll b,ll c) {
  ll d=1, e=(b*c)%mod, m_=mod-2;
  while(m_ != 0) {
    if (m_&1) d=(d*e)%mod;
    e = e*e%mod;
    m_ = m_ >> 1;
  }
  return (a*d)%mod;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,A,B,k,ans=0,j=0;cin>>n>>A>>B>>k;
  lvector f(n+1,0); f[0]=1;
  for (ll i=1;i<=n;++i) f[i]+=f[i-1]*i%mod;
  if(!(k>(A+B)*n)) {
    for(ll i=0;i<=n;++i) {
      if(k-A*i>=0 && (k-A*i)%B==0 && (k-A*i)/B<=n) {
        j=(k-A*i)/B;
        ans+=com(f[n],f[n-i],f[i])*com(f[n],f[n-j],f[j])%mod;
        ans%=mod;
      }
    }    
  }
  print(ans);
  return 0;
}


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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}



int32_t main()
{
	FIO;
	//c_p_c();
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;


}

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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

vector<int> e[114514];
int used[114514];

vector<int> ans;

void dfs(int p) {
  ans.push_back(p);
  used[p] = 1;
  for(auto i : e[p]) {
    if(used[i] < 0) {
      dfs(i);
      return;
    }
  }
}

signed main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  rep(i, n) {
    used[i] = -1;
  }
  dfs(0);
  used[0] = -1;
  auto answ = ans;
  ans = vector<int>();
  dfs(0);
  cout << ans.size() + answ.size() - 1 << endl;
  rrep(i, ans.size()) {
    cout << ans[i] + 1 << " ";
  }
  mfor(i, 1, answ.size()) {
    if(i < answ.size() - 1) {
      cout << answ[i] + 1 << " ";
    }
    else {
      cout << answ[i] + 1 << endl;
    }
  }
}


Measured memory_bytes: 11252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, a = 0, x, y, ans = 0;
	cin >> num >> x;
	for (i = 0; i < num - 1; i++) {
		cin >> y;
		if (x >= y)
			a++;
		else
			a = 0;
		ans = max(a, ans);
		x = y;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
def main():
  while True:
    n = int(input())
    if not n:
      break
    ps = [list(map(int,input().split())) for i in range(n)]
    dic = set()
    for t in ps:
      dic.add((t[0],t[1]))
    ans = 0
  
    for i in range(n):
      p1 = ps[i]
      p1x = p1[0]
      p1y = p1[1]
      for j in range(n):
        p2 = ps[j]
        p2x = p2[0]
        p2y = p2[1]
        vx = p2x - p1x
        vy = p2y - p1y
        if (p1x + vy, p1y - vx) in dic and (p2x + vy, p2y - vx) in dic:
          ans = max(ans, vx ** 2 + vy ** 2)
    

    print(ans)
main()  





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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

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

    ll N, M;
    cin >> N >> M;

    vector<ll> con(M);
    REP(i, M){
        ll K;
        cin >> K;
        ll c = 0;
        REP(j, K){
            ll s;
            cin >> s;
            s--;
            c |= (1<<s);
        }
        con[i]=c;
    }

    vector<ll> P(M);
    REP(i, M){
        cin >> P[i];
    }

    ll ans = 0;
    for(int s =0; s < (1<<N); s++){
        ll count = 0;
        for(int i = 0; i < M; i++ ){
            ll on = s & con[i];
            if( __builtin_popcount(on) % 2 == P[i] ){
                count++;
            }else{
                break;
            }
        }

        if( count == M ){
          ans++;
        }

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


Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int n;
  cin >> n;
  for(int i=1;i<n;i++){
    for(int j=i+1;j<n+1;j++){
      int i2 = i;
      int j2 = j;
      int k = 0;
      while(1){
        k++;
        if((i2%2) != (j2%2)) break;
        i2/=2;
        j2/= 2;
      }
      if(j == n) cout << k;
      else cout << k << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
    #include<string>
    #include<cstring>
    using namespace std;
    int ans[27],t[27];
    int main()
    {
    	string s;
    	int n;
    	cin>>n;
    	memset(ans,0x3f,sizeof(ans));
    	while(n--)
    	{
    		cin>>s;
    		memset(t,0,sizeof(t));
    		for(int i=0;i<s.length();i++)
    		t[s[i]-'a'+1]++;
    		for(int i=1;i<=26;i++)
    		if(t[i]<ans[i]) ans[i]=t[i];
    	}
    	for(int i=1;i<=26;i++)
    	for(int j=0;j<ans[i];j++)
    	cout<<(char)('a'+i-1);
    	return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    string a;
    cin >> a;

    bool s[3];
    s[0]=false;
    s[1]=false;
    s[2]=false;
    for(int i=0;i<3;i++){
        if(a[i]=='a'){
            s[0]=true;
        }else if(a[i]=='b'){
            s[1]=true;
        }else if(a[i]=='c'){
            s[2]=true;
        }

    }

    if(s[0]==true&&s[1]==true&&s[2]==true){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

 int main(){

	 int N,M,common,limit;
	 scanf("%d %d",&N,&M);

	 if(N >= M)common = calc(N,M);
	 else{
		 common = calc(M,N);
	 }
	 limit = (N*M)/common;

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

	 int count = 0,ans = 0,maximum,minimum,index = 0;

	 while(count < limit){
		 minimum = 101;
		 maximum = -1;
		 for(int i = 0; i < M; i++){
			 maximum = max(maximum,table[index%N]);
			 minimum = min(minimum,table[index%N]);
			 index++;
		 }
		 ans += abs(maximum-minimum);
		 count += M;
	 }

	 printf("%d\n",ans);

	 return 0;
}

Measured memory_bytes: 2744
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    while (cin >> a >> b) {
        if (a >= b) cout << 10 << endl;
        else cout << 0 << endl;
    }
}














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

int main(void){
    int N;
    int a, b, c , d;
    cin >> a >> b >> c >> d;
    
    if(abs(a - c) <= d) cout << "Yes" << endl;
    else if ( abs(a - b) <= d &&abs(b - c) <= d)  cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
    ll N,K; SCLLD2(N,K);
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }

    ll ans = 0;

    FORqr(d,-1,50){
        if (d != -1 && (not(K & (1LL << d)))) continue; //そもそもKにたってないとだめ
        ll nans = 0;
        FORqr(e,0,50){
            ll onenum = 0;
            ll conc = 1LL << e;
            REP(i,N){
                if (A[i] & conc) onenum++;
            }
            
            if (e > d){
                if (K & conc) nans += conc * (N-onenum);
                else nans += (conc * onenum);
            }else if (e == d){
                // K = 1 , X = 0となるべきところ
                // XとのXORで1の部分を数える
                nans += (conc * onenum);
            }else{
                //Greedy
                nans += conc * max(onenum,N-onenum);
            }
        }
        chmax(ans,nans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

/*
long long func(long long n,long long k){
	//k個でいくつからいくつが作れるか
	long long min;
	min = (k-1)*k/2;
	long long max;
	max = (2*n+1-k)*k/2;
	return max-min+1;
}
*/
int main(void)
{
	long long ans = 0;
	long long n,k;
	cin>>n>>k;
	long long min;
	long long max;
	long long w;
	for(long long i = k; i <= n+1; i++){
		//ans+=func(n,i);
		min = (i-1)*i/2;
		max = (2*n+1-i)*i/2;
		w = max-min+1;
		w = w % mod;
		ans += w;
		ans = ans % mod;
		//cout<<"i = "<<i<<", ans = "<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}



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

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<int> P(A), Q(B), R(C);
    for (int i = 0; i < A; ++i) cin >> P[i];
    for (int i = 0; i < B; ++i) cin >> Q[i];
    for (int i = 0; i < C; ++i) cin >> R[i];

    sort(P.begin(), P.end(), greater<int>());
    sort(Q.begin(), Q.end(), greater<int>());

    priority_queue<int> PP;
    for (int i = 0; i < X; ++i) {
        PP.push(-1 * P[i]);
    }

    priority_queue<int> PQ;
    for (int i = 0; i < Y; ++i) {
        PQ.push(-1 * Q[i]);
    }

    for (int i = 0; i < C; ++i) {
        if ((-1 * PP.top()) >= (-1 * PQ.top())) {
            if ((-1 * PQ.top()) < R[i]) {
                PQ.pop();
                PQ.push(-1 * R[i]);
            }
        } else {
            if ((-1 * PP.top()) < R[i]) {
                PP.pop();
                PP.push(-1 * R[i]);
            }
        }
    }

    long long ans = 0;
    while (!PP.empty()) {
        ans = (-1 * PP.top()) + ans;
        PP.pop();
    }

    while (!PQ.empty()) {
        ans = (-1 * PQ.top()) + ans;
        PQ.pop();
    }

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

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

int main(void) {
    int N;
    int h[100001];
    int dp[N];
    int tmp, tnp;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        tmp = dp[i-2] + abs(h[i] - h[i-2]);
        tnp = dp[i-1] + abs(h[i] - h[i-1]);
        dp[i] = min(tmp, tnp);
    }

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

    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

n, m = map(int, raw_input().split())

lst = []
for i in range(m):
    lst.append(input())

lst = list(reversed(lst))
flag = [True for i in range(n + 1)]

for num in lst:
    if flag[num]:
        print num
        flag[num] = False

for i in range(1, n + 1):
    if flag[i]:
        print i



Measured memory_bytes: 15876
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main(void){
   long long N;
   cin>>N;
   int ans=0;
   for(int i=2;i<=sqrt(N);i++){
      if(N%i!=0) continue;
      int exp=0;
      while(N%i==0){
         N=N/i;
         exp++;
      }
      for(int j=1;j<=100;j++){
         if(exp>=j){
            exp-=j;
            ans++;
         }else{
            break;
         }
      }
   }
   if(N!=1) ans++;
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int children = scan.nextInt();
		int fact = 0;
		for(int i = 1; i<=children; i++){
			fact += i;
		}
		System.out.println(fact);

	}

}


Measured memory_bytes: 21332
#coding:utf-8
#1_3_C
from collections import deque
n = int(input())
ary = deque()
for i in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        ary.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            ary.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        ary.popleft()
    elif cmd[0] == "deleteLast":
        ary.pop()

print(" ".join(ary))

Measured memory_bytes: 71860
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>x(n);
    rep(i,n)cin>>x[i];
    int ans=1e9;
    rep(i,100){
        int sum=0;
        rep(j,n){
            sum+=(x[j]-i)*(x[j]-i);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector <int> n(3); 
	for (int i=0; i<3; i++)
		cin>>n[i];
	sort (n.begin(),n.end());
	cout<<(n[0]==5&&n[1]==5&&n[2]==7?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter

def factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N = int(input())
arr = dict(Counter(factorize(N)))
ans = 0

for v, c in arr.items():
    z = 0
    for i in range(1, c+1):
        z += i
        if c - z < 0:
            break
        ans += 1
print(ans)

Measured memory_bytes: 9468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <unordered_map>

#define MIN(a,b) (a)>(b)?(b):(a)

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	priority_queue<long> Q;
	for (int i = 0; i < N; i++) {
		long a;
		cin >> a;
		Q.push(a);
	}
	for (int i = 0; i < M; i++) {
		long t = Q.top();
		t /= 2;
		Q.pop();
		Q.push(t);
	}
	long long ans = 0;
	while (!Q.empty()) {
		ans += Q.top();
		Q.pop();
	}

	cout << ans;
	return 0;
}


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

int ReverseDegits(int n)
{
    int rev = 0;
    while (n > 0)
    {
        rev = rev * 10 + n % 10;
        n = n / 10;
    }
    return rev;
}

int main()
{
    int A, B;
    cin >> A >> B;

    int count = 0;

    for (int i = A; i <= B; i++)
    {
        int rev = ReverseDegits(i);
        if (i == rev)
            count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
def solve():
    n,a,b,c,d = map(int,input().split())
    s = input()
    # aからcに到達可能か
    flag1 = True
    # bからcに到達可能か
    flag2 = True
    # 反転しているとき、到達可能な範囲に...は存在するか
    flag3 = False
    cnt = 0
    for i in range(a-1,c):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag1 = False
    cnt=0
    for i in range(b-1,d):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag2 = False
    l = max(a,b)
    r = min(c,d)
    if r<n and s[r]!='#':
        r+=1
    if l-2>=0 and s[l-2]!='#':
        l-=1
    for i in range(l-1,r):
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
        if cnt>=3:
            flag3 = True

    if flag1 and flag2:
        if c<d:
            print('Yes')
        else:
            if flag3:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl
int main(void) {
    int n;
    cin >> n;
    vector<ll> a(100001);
    ll s;
    REP(i,n) {
        cin >> s;
        a[i] = s;
    }
    ll oddcount = 0, evencount = 0;
    ll oddsum = 0, evensum = 0;
    bool odd = true;
    REP(i,n) {
        oddsum += a[i];
        evensum += a[i];
        if(odd && oddsum <= 0) {                                                                                                    
            oddcount += 1 - oddsum;
            oddsum = 1;
        }
        if(!odd && oddsum >= 0) {
            oddcount += 1 + oddsum;
            oddsum = -1;
        }
        if(!odd && evensum <= 0) {
            evencount += 1 - evensum;
            evensum = 1;
        }
        if(odd && evensum >= 0) {
            evencount += 1 + evensum;
            evensum = -1;
        }
        odd = !odd;
        //debug(a[i]);
        //debug(oddsum);
        //debug(oddcount);
        //debug(evensum);
        //debug(evencount);
        //cout << endl;
    }
    cout << min(oddcount, evencount) << endl;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int N = in.nextInt();
            out.printLine(Integer.toString(N, in.nextInt()).length());
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(in.readLine());
                }
                return tokenizer.nextToken();
            } catch (IOException e) {
                return null;
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter {
        PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}



Measured memory_bytes: 22612
#include <stdio.h>

int main(void){
    int K,X;
    scanf("%d %d",&K, &X);
    
    int A[K*2-1];

    for(int i=0;i<K*2-1;i++)
        A[i]=X-K+1+i;
    
    for(int i=0;i<K*2-1;i++)
        printf("%d ",A[i]);

    printf("\n");
}

Measured memory_bytes: 128
<?php
 
 
$input =trim(fgets(STDIN));

$input=explode(" ",$input);

$w=$input[0];
$h=$input[1];
$x=$input[2];
$y=$input[3];
$r=$input[4];

if($x -$r < 0 || $w < $x+$r){
echo "No";
}
elseif($y -$r < 0 || $h < $y+$r){
echo "No";
}
else echo "Yes";
?>

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

using namespace std;

using ll = long long;

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

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

    vector<int> a(n);
    for (auto &&x : a) cin >> x;

    constexpr int MOD = 1e9 + 7;
    vector<vector<int>> dp(2, vector<int>(k + 1));
    auto &cur = dp[0], &nxt = dp[1];
    cur[0] = 1;
    for (int i = 0; i < n; ++i) {
        ll sum = 0;
        for (int j = 0; j <= k; ++j) {
            sum = (sum + cur[j]) % MOD;
            if (0 <= j - a[i] - 1)
                sum = (sum - cur[j - a[i] - 1] + MOD) % MOD;
            nxt[j] = sum;
        }
        swap(cur, nxt);
    }

    cout << cur[k] << endl;

    return 0;
}


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

using namespace std;

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int sy,sx;
    cin>>sy>>sx;
    string s,t;
    cin>>s>>t;
    int sl=0,sr=0,su=0,sd=0;
    int tl=0,tr=0,tu=0,td=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]=='L')++sl;
        else if(s[i]=='R')++sr;
        else if(s[i]=='U')++su;
        else if(s[i]=='D')++sd;

        if(t[i]=='L')++tl;
        else if(t[i]=='R')++tr;
        else if(t[i]=='U')++tu;
        else if(t[i]=='D')++td;
    }
    sl-=sx;sr-=w+1-sx;su-=sy;sd-=h+1-sy;
    bool l=true,r=true,u=true,d=true;
    //if(sl>=0&&sl-tr>=0)l=true;
    //if(sr>=0&&sr-tl>=0)r=true;
    //if(su>=0&&su-td>=0)u=true;
    //if(sd>=0&&sd-tu>=0)d=true;

    if(l){
        int ty=sy,tx=sx;
        for (int i = 0; i < n; ++i) {
            if(s[i]=='L')--tx;
            if(tx<=0){
                cout<<"NO"<<endl;
                return 0;
            }
            if(t[i]=='R'&&tx<w)++tx;
        }
    }
    if(r){
        int ty=sy,tx=sx;
        for (int i = 0; i < n; ++i) {
            if(s[i]=='R')++tx;
            if(tx>w){
                cout<<"NO"<<endl;
                return 0;
            }
            if(t[i]=='L'&&tx>1)--tx;
        }
    }
    if(u){
        int ty=sy,tx=sx;
        for (int i = 0; i < n; ++i) {
            if(s[i]=='U')--ty;
            if(ty<=0){
                cout<<"NO"<<endl;
                return 0;
            }
            if(t[i]=='D'&&ty<h)++ty;
        }
    }
    if(d){
        int ty=sy,tx=sx;
        for (int i = 0; i < n; ++i) {
            if(s[i]=='D')++ty;
            if(ty>h){
                cout<<"NO"<<endl;
                return 0;
            }
            if(t[i]=='U'&&ty>1)--ty;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    ll n,m; cin >> n >> m;
    priority_queue<int> pq;
    REP(i,n) {
        int x; cin >> x;
        pq.emplace(x);
    }

    REP(i,m) {
        int x = pq.top() / 2;
        pq.pop();
        pq.emplace(x);
    }

    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi A(N);
	REP(i, N)cin >> A[i];
	int cur = 0;
	ll ans = 0;
	REPR(i, N) {
		if (cur != 0)cur--;
		if (cur > A[i]) {
			cout << -1 << endl;
			return 0;
		}
		if (cur < A[i]) {
			if (A[i] > i) {
				cout << -1 << endl;
				return 0;
			}
			ans += A[i];
			cur = A[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<ll> inv,fact,invfact;
void mod_build(int n=1234567){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}

int main(){
    int n;
    cin>>n;
    mod_build();
    int x,y;
    cin>>x>>y;
    vector<int> c[n];
    rep(i,n){
        int s,t;
        cin>>s>>t;
        c[--s].push_back(t);
    }
    ll ans = 1;
    vector<int> v;
    rep(i,n){
        if(c[i].empty())continue;
        sort(c[i].begin(),c[i].end());
        v.push_back(c[i][0]);
    }
    sort(v.begin(),v.end());
    v.push_back(inf);
    int m = 0;
    rep(i,n){
        if(c[i].empty())continue;
        int mi = (c[i][0]==v[0]?v[1]:v[0]);
        int j = 0;
        if(mi+c[i][0]>y)continue;
        while(j<c[i].size()&&(c[i][j]+mi<=y||c[i][j]+c[i][0]<=x)){
            (ans *= ++m)%=mod;
            (ans *= inv[++j])%=mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 39420
#include <stdio.h>

int main() {

  int m, f, r;
  int x;
  while(1) {

    scanf("%d %d %d", &m , &f , &r);
    x = m + f;
    if(m == -1 && f ==-1 && r == -1) {
      break;
    }

    if(m == -1 || f == -1) {
      printf("F\n");
    } else if(x >= 80) {
      printf("A\n");
    } else if (x >= 65) {
      printf("B\n");
    } else if(x >= 50) {
      printf("C\n");
    } else if ( x >=30) {
      if(r >= 50) {
	printf("C\n");
      } else {
	printf("D\n");
      }
    } else if (x < 30) {
      printf("F\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
<?php

$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
	$out = 0;
	$score = 0;
	$runner = 0;
	while($out < 3){
		$action = trim(fgets(STDIN));
		if($action == "OUT"){
			$out++;
			
		}else if($action == "HIT"){
			if($runner >= 3){
				$score++;
			}else{
				$runner++;
			}
			
		}else if($action == "HOMERUN"){
			$score += $runner + 1;
			$runner = 0;
		}
	}
	
	echo $score."\n";
	
}

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

int main(){
  char A[12],B[12],C[12];
  scanf("%s%s%s",A,B,C);
  if(A[strlen(A)-1] == B[0] && B[strlen(B)-1] == C[0])
    printf("YES\n");
  else printf("NO\n");
}

Measured memory_bytes: 1616
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

double a, b;

int main(){
    cin >> a >> b;
    
    
    for(int i = 0; i < 100002; ++i){
    	double curr = i;
    	
    	if(floor(curr*0.08) == a and floor(curr*0.1) == b){
    		cout << i;
    		break;
		}
		if(floor(curr*0.08) == b and floor(curr*0.1) == a){
			cout << i;
			break;
		}
		
		if(i == 100001){
			cout << -1;
		}
	}


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	
	int N,M;
	cin>>N>>M;
	
	int x=2;
	for(int i=2;i<=M;i++){
		x*=2;
	}
	cout<<x*M*1900+100*(N-M)*x<<endl;
	
	return 0;
}

Measured memory_bytes: 256
a, b, c, d = list(map(int, input().split()))
# Ch, Cw = list(map(int, input().split()))
# Dh, Dw = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(4)]
# k = int(input())
# a = list(map(int, input().split("/")))
# r = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# data = [list(map(int, input().split())) for i in range(n)]
# month = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

data = [b*d, a*c, a*d, b*c]
print(max(data))


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

#define y1 hasjdnasd
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

#define ll long long
#define oo 1e18 + 7
#define int long long

const int N = 17;
const int MASK = (1 << 16) + 5;
int n;
int b[N];
int val[N][N];
int dp[MASK] , f[MASK];

main()
{
    //freopen("U.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
        FOR(j , 1 , n)
            cin >> val[i][j];
    REP(mask , (1 << n))
    {
        int r = 0;
        FORD(j , n , 0)
            if((mask >> j) & 1)
                b[++r] = j + 1;
        FOR(i , 1 , r - 1)
            FOR(j , i + 1 , r)
                f[mask] += val[b[i]][b[j]];
        for(int submask = mask ; submask ; submask = (submask - 1) & mask)
            dp[mask] = max(dp[mask] , dp[mask ^ submask] + f[submask]);
    }
    cout << dp[(1 << n) - 1];
}


Measured memory_bytes: 1280
#include<iostream>
inline void process(unsigned long long& a,unsigned long long& b,unsigned long long& times)
{
	if (times%2==1)
		if (a%2==1)
		{
			a-=1;
			b+=a/2;
			a/=2;
		}
		else
		{
			b+=a/2;
			a/=2;
		}
	else
		if  (b%2==1)
		{
			b-=1;
			a+=b/2;
			b/=2;
		}
		else
		{
			a+=b/2;
			b/=2;
		}
}
int main()
{
	unsigned long long nTakagi,nAoki,times;
	std::cin>>nTakagi>>nAoki>>times;
	for (unsigned long long i{1};i<=times;++i)
		process(nTakagi,nAoki,i);
	std::cout<<nTakagi<<' '<<nAoki;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;

/*
//ABC89 D
int main(void) {
	ll h, w, d;
	cin >> h >> w >> d;
	vector<pair<ll, ll>> a = vector<pair<ll, ll>>(h * w + 1);
	rep(i, 1, h+1) {
		rep(j, 1, w+1) {
			ll num;
			cin >> num;
			a[num] = make_pair(i, j);
		}
	}
	vector<ll> ruiseki = vector<ll>(h * w + 1, 0);
	rep(i, 1, d + 1) {
		for (ll j = i+d; j < h * w + 1; j += d) {
			pair<ll, ll> nowP = a[j - d];
			pair<ll, ll> nextP = a[j];
			ruiseki[j] = ruiseki[j - d] + abs(nowP.first - nextP.first) + abs(nowP.second - nextP.second);
		}
	}
	ll q;
	cin >> q;
	rep(i, 0, q) {
		ll l, r;
		cin >> l >> r;
		cout << ruiseki[r] - ruiseki[l] << endl;
	}
}
*/

//ARC 81 D
int main(void) {
	ll n;
	cin >> n;
	string u, b;
	cin >> u >> b;
	ll ans = 1;
	const ll MOD = 1000000007;
	rep(i, 0, n) {
		if (u[i] == b[i]) {
			if (i == 0) ans = 3;
			else {
				if (u[i - 1] == b[i - 1]) {
					ans *= 2;
					ans %= MOD;
				}
			}
		}
		else {
			if (i == 0) ans = 6;
			else {
				if (u[i - 1] == b[i - 1]) {
					ans *= 2;
				}
				else {
					ans *= 3;
				}			
				ans %= MOD;
			}
			i++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, C = map(int, input().split())
tmp = []

for _ in range(N):
    s, t, c = map(int, input().split())
    tmp.append((s, t, c))
tmp.sort()

# そもそもCが小さいから力技で行けるはず
video = [(0, 0)]  # t,c
for s, t, c in tmp:
    for i, v in enumerate(video):
        ti, ci = v
        if c == ci:
            video[i] = (t, c)
            break
        if s > ti:
            video[i] = (t, c)
            break
    else:
        video.append((t, c))
    video.sort(reverse=True)

ans = len(video)
print(ans)


Measured memory_bytes: 17768
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var d = new int[n];
        var s = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(s[i]);
        }

        var ans = gcd(d);
        Console.WriteLine(ans);
    }

    static int gcd(int[] d)
    {
        var ans = d[0];
        for (int i = 1; i < d.Length; i++)
        {
            ans = gcd(ans, d[i]);
        }
        return ans;
    }

    static int gcd(int x, int y)
    {
        if (x == 0) return y;
        if (y == 0) return x;
        if (x < y) return gcd(x, y % x);
        else return gcd(x % y, y);
    }
}


Measured memory_bytes: 20064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    while(h!=0) {
        for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
        cout<<"#";}
        cout<<endl;
    }
    cout<<endl;
    cin>>h>>w;
    }
  
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

ll inf = 1e9;
int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n,vector<int> (m));
	rep(i,n) {
		cin >> c[i];
		rep(j,m) {
			cin >> a[i][j];
		}
	}

	// N冊の本に対して、買うか買わないか 2^12通りを全探索

	ll ans = inf;
	for(int bit = 0; bit < (1 << n); bit++){
		ll money = 0;
		vector<int> rikai(n,0);
		bitset<12> now(bit);

		debug(now);
		for(int i = 0; i < n; i++){
			if(now.test(i)){
				// i番目の本を買う
				money += c[i];
				for(int j = 0; j < m; j++){
					rikai[j] += a[i][j];
				}
			}
		}
		rep(j,m){
			if(rikai[j] < x){
				money = inf;
			}
		}
		ans = min(money, ans);
	}

	if(ans == inf) cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n, m;
  cin >> n >> m;
  int ll = 0;
  int rr = n-1;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    cmax(ll, l);
    cmin(rr, r);
  }
//  cerr << ll << rr << endl;
  cout << max(0, rr-ll+1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 998244353;

signed main(){
    int n,s; cin >> n >> s;
    ll dp[n+1][3030][3];
    //dp[i][j][k]:=i番目sum=j k=0,1,2でo,l,lr;
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    rep(i,n){
        int a; cin >> a;
        rep(j,3030){
            
            dp[i+1][j][0]+=dp[i][j][0];
            dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1];
            dp[i+1][j][2]+=dp[i][j][0]+dp[i][j][1]+dp[i][j][2];
            
            rep(k,3)dp[i+1][j][k]%=MOD;
            
            if(j+a<3030){
                dp[i+1][j+a][1]+=dp[i][j][0]+dp[i][j][1];
                dp[i+1][j+a][2]+=dp[i][j][0]+dp[i][j][1];
                rep(k,3){
                    dp[i+1][j+a][k]%=MOD;
                }
            }
            
        }
    }
    cout << dp[n][s][2] << endl;
}


Measured memory_bytes: 213376
#include <stdio.h>
 #include <ctype.h>
 #include <string.h>
 int main()
{
 char search[21], word[21];
 int count=0;
 int i;
 scanf("%s", search);
 while(1)
{
 scanf(" %s", word);
 if(strcmp(word, "END_OF_TEXT")==0)break;
 for(i=0;
word[i]!='\0';
i++)
{
 word[i]=tolower(word[i]);
 }
 if(strcmp(word, search)==0)
{
 count++;
 }
 }
 printf("%d\n", count);
 return 0;
 } 


Measured memory_bytes: 2140
S = input()
l, r = int(S[:2]), int(S[2:])
if 0<l<13 and 0<r<13:
    print("AMBIGUOUS")
elif 0<l<13:
    print("MMYY")
elif 0<r<13:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 9056
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a,b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	string s = "No";
	int N,M;
	cin >>N>>M;
	vector<string> A(N);
	vector<string> B(M);


	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	for (int i = 0; i < M; i++) {
		cin >> B.at(i);
	}
	rep(i, N - M + 1) {
		rep(j, N - M + 1) {
			int l = 0;
			rep(h, M) {
				rep(w, M) {
					if (A.at(i + h).at(j + w) != B.at(h).at(w)) {
						l = 1;
					}
				}
			}
			if (l == 0) {
				s = "Yes";
			}
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 256
a,b,k=input().split()
a,b,k=int(a),int(b),int(k)
c=0
for i in range(min(a,b)):
    if a%(min(a,b)-i)==0 and b%(min(a,b)-i)==0:
        #print(i+1)
        c+=1
    if c==k:
        print(min(a,b)-i)
        break


Measured memory_bytes: 3060