akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  lint N,A,B;
  cin >> N >> A >> B;
  if(N==1){
    if(A==B) cout << "1" << endl;
    else cout << "0" << endl;
  }
  else{
    lint ans=(B*(N-1)+A)-(A*(N-1)+B);
    if(ans<0) cout << "0" << endl;
    else cout << ans+1 << endl;
  }
}

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

vector<long> test(100);

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

long pfz(long n) {
  long ans = 1;
  for (long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      ans++;
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) ans++;
  return ans;
}

int main() {
  long a, b;

  cin >> a >> b;

  long ans = pfz(gcd(a, b));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
int main()
{
  int n;
  std::cin >> n;
  n /= 2;

  std::vector<int> e(n);
  std::vector<int> o(n);

  for (int i = 0; i < n; i++) {
    std::cin >> e[i];
    std::cin >> o[i];
  }

  std::sort(std::begin(e), std::end(e));
  std::sort(std::begin(o), std::end(o));

  int es = 0;
  std::vector<std::pair<int, int>> emode;
  for (int i = 1; i <= n; i++) {
    if (i == n || e[i - 1] != e[i]) {
      emode.push_back(std::make_pair(i - es, e[i - 1]));
      es = i;
    }
  }

  es = 0;
  std::vector<std::pair<int, int>> omode;
  for (int i = 1; i <= n; i++) {
    if (i == n || o[i - 1] != o[i]) {
      omode.push_back(std::make_pair(i - es, o[i - 1]));
      es = i;
    }
  }

  std::sort(std::begin(emode), std::end(emode), std::greater<std::pair<int, int>>());
  std::sort(std::begin(omode), std::end(omode), std::greater<std::pair<int, int>>());

  int ans = 0;

  if (emode[0].second != omode[0].second) {
    ans = (n - emode[0].first) + (n - omode[0].first);
  }
  else {
    if (emode.size() == 1 && omode.size() == 1) {
        ans = n;
    }
    else if (emode.size() == 1) {
      ans = (n - emode[0].first) + (n - omode[1].first);
    }
    else if (omode.size() == 1) {
      ans = (n - omode[0].first) + (n - emode[1].first);
    }
    else {
      if (emode[0].first > omode[0].first) {
        ans = (n - emode[0].first) + (n - omode[1].first);
      }
      else if (emode[0].first < omode[0].first) {
        ans = (n - omode[0].first) + (n - emode[1].first);
      }
      else {
          if (emode[1].first >= omode[1].first) {
              ans = (n - omode[0].first) + (n - emode[1].first);
          }
          else {
              ans = (n - emode[0].first) + (n - omode[1].first);
          }
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 1784
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...

    
    int n;
    
    cin >> n;
    
    int d[n+1];
    
    d[0] = 0;
    
    for(int i=1; i<n+1; i++)
        cin >> d[i];

    sort(d, d+n+1);
    
    int cnt =0;
    
    
    
    for(int i=1; i<n+1; i++){
        if(d[i-1]==d[i]){
            //cout << "d[" << i << "] : " << d[i] << endl;
            cnt++;
        }
    }
    
    int ans=n -cnt;
    
    if(ans)
        cout << (n-cnt) << endl;
    else
        cout << 1 << endl;

    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[302],c1,c2,c3;
double f[302][302][302];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==1)
			c1++;
		if(a[i]==2)
			c2++;
		if(a[i]==3)
			c3++;
	}
	for(int k=0;k<=n;k++)
	{
		for(int j=0;k+j<=n;j++)
		{
			for(int i=0;i+j+k<=n;i++)
			{
				if(i+j+k!=0)
				{
					f[i][j][k]=n;
					if(i)
						f[i][j][k]+=f[i-1][j][k]*i;
					if(j)
						f[i][j][k]+=f[i+1][j-1][k]*j;
					if(k)
						f[i][j][k]+=f[i][j+1][k-1]*k;
					f[i][j][k]/=i+j+k;
				}
			}
		}
	}
	cout<<fixed<<setprecision(10)<<f[c1][c2][c3]<<endl;
	return 0;
}

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

int main(){
    int N,r;
    vector<int> ans;
    while(cin>>N>>r,N != 0 && r != 0){

        stack<int> card;
        for(int i = 1;i <= N;i++) card.push(i);

        for(int i=0;i<r;i++){
            int P,C;
            stack<int> p;
            stack<int> c;
            cin>>P>>C;
            
            for(int i=0;i<P-1;i++){
                p.push(card.top());
                card.pop();
            }

            for(int i=0;i<C;i++){
                c.push(card.top());
                card.pop();
            }

            while(!p.empty()){
                card.push(p.top());
                p.pop();
            }

            while(!c.empty()){
                card.push(c.top());
                c.pop();
            }
            
        }
        ans.push_back(card.top());
    }
    for(int i : ans) cout<<i<<endl;
}


Measured memory_bytes: 3036
from fractions import *
from decimal import *
n, m = [int(i) for i in input().split()]
a = 0
s = m * 1900 + (n - m) * 100
kek = Decimal(2) ** -m
cur = 0
for i in range(1, 10000):
	cur1 = Decimal(1) - (Decimal(1) - cur) * (1 - kek)
	a += Decimal(i * s) * (cur1 - cur)
	cur = cur1
print(round(a))



Measured memory_bytes: 5304
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 9223372036854775807
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,m;
  cin >> n >> m;
  
  if(n+m == 15) cout << "+" << endl;
  else if(n*m == 15) cout << "*" << endl;
  else cout << "x" << endl;


  return 0;
}

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

int main() {
	int n,x;
    cin>>n>>x;
    vector<int> lol;
int ans =1,sum=0;;
    for(int i = 0; i < n; i++)
    {
         int p; 
cin>>p;
sum+=p; 
if(sum<=x)
ans++;
 else 
 break;
     }
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int K;
  cin >> K;
  string ans = "";
  for (int i = 0; i < K; i++) {
    ans += "ACL";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
typedef long long ll;
typedef int64_t in;

using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    bool flag = false;
    ll n = (ll) s.size();
    rep(i,n){
        if(s[0] != t[i]){
            continue;
        }else{
            flag = true;
            REP(j,i,n){
                if(s[j-i] != t[j]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                rep(j,i){
                    if(s[n-i+j] != t[j]){
                        flag = false;
                        break;
                    }
                }
            }
        }
        if(flag) break;
    }
    if(flag) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}


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

#define rep(X,N) for(ll 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 INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;


int main(){

    int n;
    cin >> n;

    vector<int> a(n + 1);
    vector<int> ans(n + 1);
    int count = 0;

    rep(i, n){
        cin >> a[i + 1];
    }

    for(int i = n; i >= 1; i--){

        int tmp = 0;

        for(int j = i + i; j <= n; j = j + i){
            tmp += ans[j];
        }

        if(a[i] == 0){
            if(tmp % 2 == 0){
                
            }else{
                ans[i] = 1;
                count++;
            }
        }else{
            if(tmp % 2 == 0){
                ans[i] = 1;
                count++;
            }else{
                
            }
        }
    }

    cout << count << endl;
    rep(i, ans.size()){
        if(ans[i + 1] == 1) cout << i + 1 << endl;
    }


    return 0;
}


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

using namespace std;

int limit;
int ans = 0;
int denkyu = 0;
vector<set<int>> ccond;   // 電球のスイッチ接続条件
vector<int> parr;         // スイッチの個数のparity

void dfs(vector<int> &v, int i) {
    if (i == limit) {
        //   電球毎に調べる
        int num_on = 0;
        for (int j = 0; j < ccond.size(); j++) {
            //  現在の電球
            set<int> cur_cond = ccond[j];  // 現在の電球の条件
            int curp = parr[j];  // スイッチの個数のparity
            //  スイッチの状態
            int num = 0;
            for (int i = 0; i < limit; i++) {
                if (v[i] == 1) {
                    if (cur_cond.find(i + 1) != cur_cond.end()) {
                        num++;
                    }
                }
            }
            if (num % 2 == curp) {
                num_on++;
            }
        }
        if (num_on == denkyu) {
            ans++;
        }
        return;
    }

    //  ON
    v.push_back(1);
    dfs(v, i+1);
    v.pop_back();

    //  OFF
    v.push_back(0);
    dfs(v, i+1);
    v.pop_back();
    return;
}

int main(int argc, char *argv[]) {
    //
    //  N個のスイッチの状態を全探索する 
    //   
    int N, M;
    cin >> N >> M;
    limit = N;
    denkyu = M;

    for (int i = 0; i < M; i++) {
        int n;
        cin >> n;
        set<int> tarr;
        for (int j = 0; j < n; j++) {
            int k;
            cin >> k;
            tarr.insert(k);
        }
        ccond.push_back(tarr);
    }

    for (int k = 0; k < M; k++) {
        int c;
        cin >> c;
        parr.push_back(c);
    }

    vector<int> v;
    dfs(v, 0);

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(ll i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(ll i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007

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


int main(){
	ll a,b;
	while(cin>>a>>b){
		cout<<gcd(a,b)<<endl;
	}
	
}

Measured memory_bytes: 1156
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n, m1, m2, h1, h2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 - h1) * 60 + m2 - m1 - k << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(B/A>=C) cout<<C<<endl;
  else cout<<B/A<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
class Program
{
    static void Main(string[] args)
    {
        string[] temp = Console.ReadLine().Split(' ');
        int A = int.Parse(temp[0]);
        int B = int.Parse(temp[1]);
        int K = int.Parse(temp[2]);
        int a = 0;
        for(int i = 100; i >= 1; i--)
        {
            if (A % i == 0 && B % i == 0)
            {
                a++;
                if (a == K)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	long long int n,sum,S,temp;
	priority_queue<int, vector<int>,greater<int> > que;
	while(cin >> n, n){
		S = 0;
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> temp;
			que.push(temp);
		}
		while(!que.empty()){
			sum += S;
			S +=  que.top();
			que.pop();
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	string s;cin>>s;
	bool f=true;
	int sl=s.length();
	for(int i=sl-1;i>=0;i--){
		if(i>=4&&s.substr(i-4,5)=="dream"){
			i-=4;
		}else if(i>=6&&s.substr(i-6,7)=="dreamer"){
			i-=6;
		}else if(i>=4&&s.substr(i-4,5)=="erase"){
			i-=4;
		}else if(i>=5&&s.substr(i-5,6)=="eraser"){
			i-=5;
		}else{
			f=false;
		}
	}
	if(f){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}


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

int main(){
   char s[200001];
   int i,l;
   long a;
    
   gets(s);
   for (l=strlen(s)-1;l>=0 && s[l]=='B';l--) ;
   if (l<0) {
      puts("0");
      return 0;
   }
   for (i=a=0;i<l;i++)
      if (s[i]=='B') {
         a+=l-i;
         for (l--;l>i && s[l]=='B';l--) ;
         if (l==i) break;
      }
   printf("%ld\n",a);
   return 0;
}


Measured memory_bytes: 384
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int S = sc.nextInt();
    int count = 0;
    for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
        if (0 <= S-(x+y) && S-(x+y) <= K) {
          count++;
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>t(n);
    vector<long long>a(n+1,0);
    for(int i=0; i<n; i++){
        cin >> t[i];
        a[t[i]]++;
    }
    long long sum=0;
    for(int i=1; i<n+1; i++){
        if(a[i]>0) sum += a[i] * (a[i]-1) / 2;
    }
    for(int i=0; i<n; i++){
        cout << sum - a[t[i]] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> p(n);rep(i,n)cin>>p[i];
    ll m = 200001;
    ll ans = 0;
    for(int i=0; i<n; i++){
        if(p[i]<m)ans++;
        m=min(m,p[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
import sys
res = []
t_lis = []
first = None
second = None
third = None
for i, line in enumerate(sys.stdin):
    n = int(line.rstrip().split(' ')[0])
    t = float(line.rstrip().split(' ')[1])
    if first == None or first[1] > t:
        first, second, third = (n,t), first, second
    elif second == None or second[1] > t: 
        second, third = (n,t), second
    elif third == None or third[1] > t:
        third = [n,t]
    if (i+1) % 8 == 0:
        res.append(first)
        res.append(second)
        t_lis.append(third)
        first = None
        second = None
        third = None
else:
    res.extend(sorted(t_lis, key=lambda x:x[1])[:2])
    for v in res:
        print '%s %.2f' % (v[0], v[1])

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int a,b;cin>>a>>b;
    int ans=0;
    for(int i=a;i<=b;i++){
        string s=to_string(i);
        int n=(int)s.size();
        int half=n/2;
        bool flag=true;
        rep(j,half){
            if(s[j]!=s[n-j-1])flag=false;
        }
        if(flag)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    string s;
    
    cin >> s;
    
    s.at(3) = '8';
    
    cout << s << endl;
    
    
    

    
/////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 256
n = gets.chomp.to_i
rooms = Array.new(4).map! { Array.new(3).map! { Array.new(10, 0) }}
(1..n).each {
  b, f, r, v = gets.chomp.split(' ').map { |i| i.to_i }
  rooms[b-1][f-1][r-1] += v
}

rooms.each_with_index { |b,bi|
  b.each_with_index { |f,fi|
    f.each_with_index { |r,ri|
      if ri < f.size-1
        print " #{rooms[bi][fi][ri]}"
      else
        print " #{rooms[bi][fi][ri]}\n"
      end
    }
  }
  if bi < b.size
    puts '####################'
  end
}

Measured memory_bytes: 6116
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

n = lines[0][0]
m = lines[0][1]
a = lines[1]

total_votes = 0
for i in 1..n
  total_votes += a[i-1]
end

result = 0

for i in 1..n do
  if a[i-1] >= total_votes / (4.0 * m) then
    result += 1
  end
end

if result >= m then
  print "Yes"
else
  print "No"
end

Measured memory_bytes: 1788
N = int(input())
h = list(map(int, input().split()))

def minus(l,x):
    for i in range(len(l)):
        l[i] = l[i] - x
    

count = 0
count += min(h)
minus(h, min(h))


for i in range(N-1):
    if h[i] > h[i+1]:
        count -= h[i+1]-h[i]
        
count += h[-1]
print(count)
    



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

int main() {
  int ans = 0;
  int N,D;

  cin >> N >> D;
  for(int i=0;i<N;++i){
    long x,y;
    cin >> x >> y;
    if(pow(x,2) + pow(y,2) <= pow(D,2)){
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll A[N]; F0R(i, N) cin >> A[i];

    ll dp[N+1]; F0R(i, N+1) dp[i] = -1e18;
    dp[0] = 1000;
    F0R(i, N) {
        ckmax(dp[i+1], dp[i]);
        FOR(j, i+1, N) {
            ckmax(dp[j+1], A[j] * (dp[i] / A[i]) + dp[i] % A[i]);
        }
    }
    cout << dp[N] << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned long ul;

int main() {
    string s;
    cin >> s;
    ull ans = 0;
    size_t count = 0;
    REP(i, s.size()) {
        if(s[i] == 'W') {
          ans += (i - count);
          count++;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
val = input().split(' ')
n = int(val[0])
x = int(val[1])
y = int(val[2])

dists = {}
for i in range(1, n):
    dists[i] = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        len1 = j - i
        len2 = abs(j - y) + abs(x - i) + 1
        len3 = abs(y - i) + abs(j - x) + 1
        dist = len1 if len1 < len2 else len2
        dist = dist if dist < len3 else len3
        dists[dist] += 1

for i in range(1, n):
    print(dists[i])


Measured memory_bytes: 3572
N = int(input())
S = input()
T = input()
cnt = 0
ans = 0
tateyoko = ''
if S[0] == T[0]:
  ans += 3
  cnt += 1
  tateyoko = 'tate'
else:
  ans += 6
  cnt += 2
  tateyoko = 'yoko'
while cnt < N:
  if tateyoko == 'tate':
    if S[cnt] != T[cnt]:
      ans *= 2
      cnt += 2
      tateyoko = 'yoko'
    else:
      ans *= 2
      cnt += 1
  else:
    if S[cnt] != T[cnt]:
      ans *= 3
      cnt += 2
    else:
      cnt += 1
      tateyoko = 'tate'
print(ans%1000000007)

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


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	//sort(a.begin(),a.end());
	int r;
	cin >> r;
	cout << 3 * r * r;
	

	return 0; 
}









Measured memory_bytes: 256
import sys

def main():
    S = list(input())
    S.reverse()
    words = ['resare', 'esare', 'remaerd', 'maerd']
    while len(S) > 0:
        deleted = False
        for word in words:
            if len(S) >= len(word) and ''.join(S[0:len(word)]) == word:
                del S[0:len(word)]
                deleted = True
        if deleted is False:
            print('NO')
            sys.exit()

    print('YES')

main()


Measured memory_bytes: 3956
from typing import List


def reconstruct_trees(preordered_list: List[int],
                      inordered_list: List[int], node: int) -> None:
    global trees
    in_node_index = inordered_list.index(node)
    in_left_list = inordered_list[:in_node_index]
    in_right_list = inordered_list[in_node_index + 1:]
    _ = preordered_list.index(node)
    pr_left_list = preordered_list[1: 1 + len(in_left_list)]
    pr_right_list = preordered_list[1 + len(in_left_list):]

    if 0 == len(in_left_list):
        pass
    else:
        next_node = pr_left_list[0]
        trees[next_node]['parent'] = node
        trees[node]['left-child'] = next_node
        if 1 < len(in_left_list):
            reconstruct_trees(pr_left_list, in_left_list, next_node)
    if 0 == len(in_right_list):
        pass
    else:
        next_node = pr_right_list[0]
        trees[next_node]['parent'] = node
        trees[node]['right-child'] = next_node
        if 1 < len(in_right_list):
            reconstruct_trees(pr_right_list, in_right_list, next_node)


def create_postorder(node: int) -> None:
    global trees
    global postordered_list
    left_child = trees[node]['left-child']
    right_child = trees[node]['right-child']
    if -1 != left_child:
        create_postorder(left_child)
    if -1 != right_child:
        create_postorder(right_child)
    postordered_list.append(node)


if __name__ == "__main__":
    node_num = int(input())
    trees = {idx + 1:
             {"parent": -1, "left-child": -1, "right-child": -1}
             for idx in range(node_num)}
    preordered_list = list(map(lambda x: int(x), input().split()))
    inordered_list = list(map(lambda x: int(x), input().split()))
    postordered_list = []  # type: ignore

    root_node = preordered_list[0]

    reconstruct_trees(preordered_list, inordered_list, root_node)
    create_postorder(root_node)

    print(" ".join([str(elem) for elem in postordered_list]))



Measured memory_bytes: 7180
#include <bits/stdc++.h>
    using namespace std;
    #define el "\n"
    #define ll long long
    #define ull unsigned long long int
    #define pb push_back
    #define mp make_pair
    #define X first
    #define Y second
    #define M 1000000007
    #define all(v) v.begin(), v.end()
    long long pow(long long int a,long long int b,long long int MOD)
    {
        long long x=1,y=a; 
        while(b > 0)
        {
            if(b%2 == 1)
            {
                x=(x*y);
                if(x>MOD) x%=MOD;
            }
            y = (y*y);
            if(y>MOD) y%=MOD; 
            b /= 2;
        }
        return x;
    }
    long long InverseEuler(long long int n, long long int MOD)
    {
        return pow(n,MOD-2,MOD);
    }
   
    int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll n;
      cin>>n;
      ll a[n]={0};
      for(int i=0;i<n;i++)cin>>a[i];
      ll cnt=0;
      for(int i=1;i<n-1;i++){
          vector<int> v;
          v.pb(a[i-1]);
          v.pb(a[i]);
          v.pb(a[i+1]);
          sort(all(v));
          if(v[1]==a[i])cnt++;
          v.clear();
      }
      cout<<cnt<<el;
      return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(long long int i = 0; i < n; i ++)
#define forn1(i, n)            for(long long int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 5010
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
#define p 31

ll powp[range];
void init(){
    powp[0] = 1;
    forn1(i, range - 1) powp[i] = (1LL * powp[i - 1] * p) % MOD;
}


bool is_possible(string &s, int len) {
    if(len == 0) return true;
    ll curr = 0;
    map <ll , vector <ll > > total_arrangment;
    forn(i, len) {
        curr += 1LL * (s[i] - 'a' + 1) * powp[len - 1 - i];
        curr %= MOD;
    }

    total_arrangment[curr].pb(0);
    forn1(i, s.size() - len ) {
        curr -=  1LL * (s[i - 1] - 'a' + 1) * powp[len - 1];
        curr %= MOD;
        if(curr < 0) curr += MOD;
        curr *= p;
        curr %= MOD;
        curr += s[i + len - 1] - 'a' + 1; 
        curr %= MOD;
        total_arrangment[curr].pb(i);
    }
    for(auto t : total_arrangment){
        if(t.se.size() < 2) continue;
        ll x1 = t.se[0];
        ll x2 = t.se.back();
        if(x2 - x1 >= len) return true; 
    }

    return false;
}


ll binary(string &s, ll x , ll y ) {

    // cout << x << " " << y << endl;
    ll mid = (x + y + 1) >> 1;
    if(x == y) return x;
    if(is_possible(s, mid)) return binary(s, mid, y);
    else return binary(s, x, mid - 1);
}



int main(){

  //  freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
    init();
    int n; cin >>n;
    string s; cin >> s;

    cout << binary(s, 0, n / 2);


    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define endl '\n' 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
const ld eps=(ld)1e-9;
const ld PI=(ld)acos(-1.0);
const int inf=1e9+5;
const ll linf=1e18L+5;
const int mod=1e9+7;

void solve(){
	int h,w;
	cin>>h>>w;
	char c[h][w];
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cin>>c[i][j];
		}
	}
	for (int i = 0; i < 2*h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			cout<<c[(i+2)/2-1][j];
		}
		cout<<endl;
	}
}
int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var L = double.Parse(Console.ReadLine());
            double r = L / 3;
            Console.WriteLine(Math.Pow(r,3));
        }
    }
}

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

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

  T = T.substr(0,S.size());

  if(S==T){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }




}


Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node {int id,l,r,p;};
struct Node T[MAX];

void preParse(int u){
    if (u==NIL) return;
    cout<<" "<<u;
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if (u==NIL) return;
    inParse(T[u].l);
    cout<<" "<<u;
    inParse(T[u].r);
}

void postParse(int u){
    if (u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    cout<<" "<<u;
}

int main(){
    int n,v,l,r,root;
    cin>>n;
    for(int i=0;i<n;i++){
        T[i].p=T[i].l=T[i].r=NIL;
    }
    for(int i=0;i<n;i++){
        cin>>v>>l>>r;
        T[v].id=v;
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL)T[T[v].l].p=v;
        if(r!=NIL)T[T[v].r].p=v;
    }
    for(int i=0;i<n;i++){
        if(T[i].p==NIL) root=i;
    }
    
    
    
    cout<<"Preorder"<<endl;
    preParse(root);
    cout<<endl;
    cout<<"Inorder"<<endl;
    inParse(root);
    cout<<endl;
    cout<<"Postorder"<<endl;
    postParse(root);
    cout<<endl;
    
    return 0;
    
}



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

int main()
{
	string s;
	cin >> s;
	int r = 0, b = 0;
	for(auto c : s){
		if(c == '0') ++r;
		else ++b;
	}
	cout << min(r, b) * 2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int N,T;
  cin >> N >> T;
  
  vector<int> c(N); vector<int> t(N);
  for (int i=0; i<N; i++) cin >> c[i] >> t[i];
  
  int minimum = 10000;
  
  for (int i=0; i<N; i++) {
    if (t[i] <= T) {
      minimum = min(minimum,c[i]);
    }
  }
  if (minimum == 10000) {
    cout << "TLE" << endl;
  }
  else cout << minimum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;
 
long long mergecount(vector<long long> &a) {
  long long count = 0;
  int n = a.size();
  if (n > 1) {
    vector<long long> b(a.begin(), a.begin() + n/2);
    vector<long long> c(a.begin() + n/2, a.end());
    count += mergecount(b);
    count += mergecount(c);
    for (int i = 0, j = 0, k = 0; i < n; ++i)
      if (k == c.size())       a[i] = b[j++];
      else if (j == b.size())  a[i] = c[k++];
      else if (b[j] <= c[k])   a[i] = b[j++];
      else                   { a[i] = c[k++]; count += n/2 - j; }
  }
  return count;
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    string S;
    cin >> S;
    int N = S.size();
    map<char, long long> mp;
    for(char c : S) mp[c]++;
 
    int od = 0;
    for(int i=0; i<26; i++){
        char c = 'a' + i;
        if(mp[c] % 2 == 1) od++;
    }
    if(od >= 2){
        cout << -1 << endl;
        return 0;
    }
    char c0 = ' ';
    if(N % 2 == 1){
        for(int i=0; i<26; i++){
            char c = 'a' + i;
            if(mp[c] % 2 == 1)
                c0 = c;
        }
    }
 
    vector<long long> pos(N, 0);
    map<char, long long> mp2;
    for(int i=0; i<N; i++){
        char c = S[i];
        if(mp2[c] < mp[c] / 2) pos[i] = -1;
        else pos[i] = 1;
        if(c == c0){
            if(mp2[c0] == mp[c0] / 2)
                pos[i] = 0;
        }
        mp2[c]++;
    }
 
    int cnt1 = 0, cnt2 = N/2, cnt3 = (N+1)/2;
    vector<long long> pos2(N);
    for(int i=0; i<N; i++){
        if(pos[i] == -1){
            pos2[i] = cnt1;
            cnt1++;
        }else if(pos[i] == 0){
            pos2[i] = cnt2;
        }else{
            pos2[i] = cnt3;
            cnt3++;
        }
    }
 
    long long ans = mergecount(pos2);
 
    int M = N / 2;
    vector<char> le(M), ri(M);
    cnt1 = 0; cnt2 = 0;
    for(int i=0; i<N; i++){
        if(pos[i] == -1){
            le[cnt1] = S[i];
            cnt1++;
        }
        else if(pos[i] == 1){
            ri[cnt2] = S[i];
            cnt2++;
        }
    }
    reverse(ri.begin(), ri.end());
 
    map<pair<char, long long>, long long> mp3;
    map<char, long long> mp4;
    int cnt = 1;
    for(int i=0; i<M; i++){
        char c = ri[i];
        long long num = mp4[c];
        mp3[make_pair(c, num)] = cnt;
        mp4[c]++;
        cnt++;
    }
    map<char, long long> mp5;
    vector<long long> le2(M);
    for(int i=0; i<M; i++){
        char c = le[i];
        le2[i] = mp3[make_pair(c, mp5[c])];
        mp5[c]++;
    }
    ans += mergecount(le2);
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 12436
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N,T,tmp_cost,tmp_time;
  	int cost_min=20000;
	std::vector<int> time,cost;
  
 	cin >> N >> T;
	for(int i=0;i<N;i++){
    	cin >> tmp_cost >> tmp_time;
      	cost.push_back(tmp_cost);
      	time.push_back(tmp_time);
    }
  	for(int j=0;j<N;j++){
    	if(cost[j] < cost_min && time[j] <= T){
        	cost_min = cost[j];
        } 
    }
  	if(cost_min!=20000){
    	cout << cost_min <<endl;
    }else{ cout << "TLE" << endl;}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n,x=0,ans=0;
	char s[101];
	scanf("%d %s",&n,s);
	for(int i=0;i<n;i++){
		if(s[i]=='I')x++;
		else x--;
		if(x>ans)ans=x;
	}
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define inf 0x3f3f3f3f
typedef long long LL;
#define cls(x) memset(x,0,sizeof(x))
#define For(i,j,k) for(register int i=(j);i<=(k);++i)
#define Rep(i,j,k) for(register int i=(j);i>=(k);--i)
#define rint register int
#define il inline

il int read(int x=0,int f=1,char ch='0')
{
    while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return f*x;
}

const int N=1e5+5,mod=1e9+7;
int n,m,t=3;
int a[N];


struct node{
    int w[5][5];
    node(){cls(w);}
    node operator *(const node &n2)const
    { 
        node ret; For(i,0,2) For(j,0,2) For(k,0,2) 
            (ret.w[i][j]+=1ll*w[i][k]*n2.w[k][j]%mod)%=mod;
        return ret;
    }

    node operator ^(int x)
    {
        node ret,now=*this; For(i,0,2) ret.w[i][i]=1;
        // cout<<x<<endl;
        for(;x;x>>=1) { if(x&1) ret=ret*now; now=now*now; }
        return ret;
    }
}f,g,h; 

int main()
{
    n=read(); m=read();
    For(i,1,m) a[i]=read();
    h.w[0][0]=h.w[1][1]=1; h.w[1][0]=2;
    h.w[2][0]=h.w[2][1]=h.w[2][2]=1;

    g=h; g.w[0][0]=2; g.w[0][1]=g.w[0][2]=1;
    f.w[0][0]=f.w[0][1]=f.w[0][2]=1;

    For(i,1,m) f=f*(g^(a[i]-a[i-1]-1))*h;
    // printf("%d\n",n-a[m]-1);
    f=f*(g^(n-a[m]-1));
    // f=f*g;
    printf("%d\n",f.w[0][0]);


    return 0;
}

Measured memory_bytes: 640
import sys, math
from collections import deque

S = deque(input())
Q = int(input())

count_reverse = 0
for i in range(Q):
  q = [j for j in input().split()]
  if len(q) == 1:
    count_reverse += 1
  else:
    if q[1] == '1':
      if count_reverse % 2 == 0:
        S.appendleft(q[-1])
      else:
        S.append(q[-1])
    else:
      if count_reverse % 2 == 0:
        S.append(q[-1])
      else:
        S.appendleft(q[-1])
        
ret = ''
if count_reverse % 2:
  for s in list(S)[::-1]:
    ret = ret + s
else:
  for s in S:
    ret = ret + s
    
print(ret)

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

lint dp[105][MAX+5];

int main(){
    // dp[i][j]:=(i番目の品物まで使い, 価値をj以上にした時の重さの最小値)
    lint n, W; cin >> n >> W;
    rep(i, n+1){
        rep(j, MAX+5) dp[i][j] = INF;
        dp[i][0] = 0;
    }

    repn(i, n){
        lint w, v; cin >> w >> v;
        rep(j, MAX){
            int k = MAX-j;
            dp[i][k] = min(dp[i-1][k], dp[i][k+1]);
            if(k-v>=0) dp[i][k] = min(dp[i][k], dp[i-1][k-v]+w);
        }
    }
    lint ans = 0;
    rep(j, MAX){
        if(dp[n][j] <= W) ans = j;
    }
    out(ans);
}

Measured memory_bytes: 80128
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define rep(i,n) for(int i = 0;i < (n);i++)
#define MAX_N 405
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll dp[MAX_N][MAX_N];
int N;
ll a[MAX_N];
ll sum[MAX_N];

ll rsum(int l,int r){
    return sum[r]-sum[l];
}

ll dfs(int l,int r){    //[l,r)
    if(dp[l][r]>=0)
        return dp[l][r];
    if(r-l<=1){
        dp[l][r]=0;
        return dp[l][r];
    }
    ll ret = -1;
    for(int mid = l+1;mid < r;mid++){
        if(ret<0)
            ret = dfs(l,mid)+dfs(mid,r)+rsum(l,r);
        else
            ret = min(ret,dfs(l,mid)+dfs(mid,r)+rsum(l,r));
    }
    dp[l][r]=ret;
    return ret;
}

int main() {
    cin>>N;
    sum[0]=0;
    rep(i,N){
        cin>>a[i];
        sum[i+1]=a[i]+sum[i];
    }
    rep(i,MAX_N){
        rep(j,MAX_N){
            dp[i][j]=-1;
        }
    }
    cout<<dfs(0,N)<<endl;
}



Measured memory_bytes: 1536
#include<iostream>
    using namespace std;
    int main()
    {
        int a[3];
        int b =0;
        int c =0;

        for (size_t i = 0; i < 3; i++) {
          std::cin >> a[i];
          if (a[i] == 5) {
            b++;
          }
          else if (a[i] == 7) {
            c++;
          }
        }

        if (b == 2 && c == 1) {
          std::cout << "YES" << '\n';
        }
        else{
          std::cout << "NO" << '\n';
        }
        
        return 0;
    }


Measured memory_bytes: 256