akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vector<vi> abc(n+5, vi(3));
    rep(i, n) rep(j, 3) cin >> abc[i][j];
    vector<vi> dp(n+5, vi(3));
    rep(i, n) rep(j, 3) {
        rep(k, 3) if (k != j) dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i][k]);
    }
    int ans = 0;
    rep(i, 3) ans = max(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14024
#include <stdio.h>

int main()
{
    int a;
    int b;
    int c;
    int k;
    int i;

    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &k);

    if(a >= b && a >= c) {
        for(i = 0; i < k; i++) {
            a <<= 1;
        }
    } else if(b >= c) {
        for(i = 0; i < k; i++) {
            b <<= 1;
        }
    } else {
        for(i = 0; i < k; i++) {
            c <<= 1;
        }
    }
    printf("%d\n", a + b + c);

    return 0;
}

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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    long long int N,M,i;
    cin >> N >> M;
    long long int a[N],b[N];
    map<long long int,long long int>m;
    for(i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        if(b[i] == N) {
            m[a[i]] = N;
        }
    }

    for(i = 0; i < M; i++) {
        if (a[i] == 1) {
            if (m[b[i]] == N) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 15872
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();
            if(n == 0 && x == 0) break;

            int val = 0;
            int count = 0;
            for(int i = 1 ; i < n ; i++){
                for(int j = i + 1 ; j < n ; j++){
                    for(int k = j + 1 ; k < n + 1 ; k++){
                       val = (i + j + k);
                       if(val == x) count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}



Measured memory_bytes: 26784
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll a, b, n;
	cin >> a >> b >> n;
	ll ans = 0;
	ll i = min(n, b- 1);
		ll x = (a*i)/b - a*(i/b);
		umax(ans, x);
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3596
#第二問　make a rectangle
import collections
n=int(input())
lists=list(map(int,input().split()))
A=dict(collections.Counter(lists))
dictdict=[]


for j in A.keys():
    for _ in range(A[j]//2):
        dictdict.append(j)

dictdict=sorted(dictdict,reverse=True)
if len(dictdict)>=2:
    print(dictdict[0]*dictdict[1])
else:
    print(0)

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

#define MX 100000
#define MX_N 100
const int INF=1e9+5;

int n, w, res=INF;
pair<int,int> tab[MX_N+5];
int dp[MX+5];

int main( )
{
	cin>>n>>w;
	for( int i=0; i<n; i++ )
		cin>>tab[i].first>>tab[i].second;

	for( int i=1; i<=MX; i++ )
		dp[i]=INF;

	for( int i=0; i<n; i++ )
	{
		pair<int,int> p=tab[i];
		for( int j=MX; j-p.second>=0; j-- )
		{
			dp[j]=min( dp[j-p.second]+p.first, dp[j] );
		}
	}

	for( int i=1; i<=MX; i++ )
	{
		if( dp[i]<=w ) res=i;
	}

	cout<<res<<"\n";

}


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

const ll INF = ll(1e18)+1;

ll binary_search(ll x, ll ai, vector<ll> a){
    int n = a.size();
    int l = -1;
    int r = n;
    if(ai < 0){
        while(l+1<r){
            int c = (l+r)/2;
            if (ai*a[c] < x) r=c; else l = c;
        }
        return n-r;
    } else {
        while(l+1<r){
            int c = (l+r)/2;
            if (ai*a[c] < x) l=c; else r = c;
        }
        return r;
    }
}

int main(){
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(),a.end());
    ll l = -INF, r = INF;
    while(l+1<r){
        ll x = (l+r)/2;
        bool ok = [&]{
            ll tot = 0;
            rep(i, n) {
                if (a[i] < 0){
                    int l = -1, r = n;
                    while(l+1<r){
                        int c = (l+r)/2;
                        if (a[c]*a[i] < x) r = c; else l = c;
                    }
                    tot += n - r;
                } else {
                    int l = -1, r = n;
                    while(l+1<r){
                        int c = (l+r)/2;
                        if (a[c]*a[i] < x) l = c; else r = c;
                    }
                    tot += r;
                }
                if (a[i]*a[i] < x) tot--;
            }
            tot /= 2;
            return tot < k;
        }();
        if (ok) l = x; else r = x;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1792
a,b,n= list(map(int, input().split()))
if b==1:
    print(0)
    exit(0)
ma=(a*n/b)//1-a*((n/b)//1)
for i in range(b-1,n+1,b):
    tmp=(a*i/b)//1-a*((i/b)//1)
    ma=max(tmp,ma)
print(int(ma))

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 

#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 pb push_back

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<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

map<ll,ll> mp;

const int INF=INT_MAX;
vpi v[55];
ll dp[1<<20];
ll x[100];

bool dfs(int a,int b,int c, int d){
    if(a==c){
        return 1;
    }else{
        for(auto it:v[a]){
            if(it.first!=b&&dfs(it.first,a,c,d)){
                x[it.second]^=(1<<d);
                return 1;
            }
        }
    
    return 0;
    }

}



int main(){
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int ta,tb;
        cin>>ta>>tb;
        v[ta].emplace_back(tb,i);
        v[tb].emplace_back(ta,i);
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int ta,tb;
        cin>>ta>>tb;
        dfs(ta,0,tb,i);
    }
    dp[0]=1;
    for(int i=1;i<n;i++){
        for(int j=(1<<m)-1;j>=0;j--){
            dp[j|x[i]]+=dp[j];
        }
    }
    out(dp[(1<<m)-1]);

    return 0;
}


Measured memory_bytes: 8576
#include<iostream>
#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
#include <iomanip>//setprecision
#include<math.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
long long int a;
 long long int b,c;
    cin>>a>>b>>c;
    if(a==1)cout<<"Hello World";
    else cout<<c+b;
}


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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int n;
    cin>>n;
    vi h(n+1);
    Fo(i,1,n+1)cin>>h[i];
    vi dp(n+1);
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    Fo(i,3,n+1){
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAXV = 10005;
vector<int> to[MAXV];
vector<int> out;

bool visited[MAXV];
void dfs(int v)
{
  if (visited[v])
  {
    return;
  }
  visited[v] = true;
  for (int u : to[v])
  {
    dfs(u);
  }
  out.push_back(v);
}

int main()
{
  int V, E, s, t;
  cin >> V >> E;
  for (int i = 0; i < E; i++)
  {
    cin >> s >> t;
    to[s].push_back(t);
  }
  for (int i = 0; i < V; i++)
  {
    dfs(i);
  }
  reverse(out.begin(), out.end());
  for (int v : out)
  {
    cout << v << endl;
  }
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    int m = min(x, y);
    x -= m, y -= m;

    int ans = min(2 * m * c, m * (a + b));

    ans += min(x * a, 2 * c * x) + min(y * b, 2 * c * y);

    cout << ans << '\n';
    return 0;
}


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

const int INF = 1e9 + 5; 

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

    int n, k;
    cin >> n >> k; 
    vector<int> h(n+1); 
    for (int i = 1; i <= n; i++) cin >> h[i]; 
    vector<int> dp(n+1, INF); 
    dp[1] = 0; 
    for (int i = 1; i <= n; i++) {
        for (int j = i+1; j <= i+k; j++) {
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j])); 
        }
    }

    cout << dp[n] << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S);
  int i = S.length() - 1;
  while (i > 0) {
    string s5 = S.substr(max(i - 4, 0), 5);
    string s6 = S.substr(max(i - 5, 0), 6);
    string s7 = S.substr(max(i - 6, 0), 7);
    if (s6 == "eraser") {
      i -= 6;
    } else if (s5 == "erase") {
      i -= 5;
    } else if (s7 == "dreamer") {
      i -= 7;
    } else if (s5 == "dream") {
      i -= 5;
    } else {
      print("NO");
      return;
    }
  }
  print("YES");
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<int>())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  cin>>N;

  cout<< "ABC"<<N<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if((a*b)%2==0)
	{
		cout<<"No";
		return 0;
	}
	if((a*b)%2!=0)
	{
		cout<<"Yes";
		return 0;
	}
    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int n,x,tmp=0;
    in n>>x;
    vector<int> m(n);
    int ans=n;
    rep(i,n){
        in m[i];
        tmp+=m[i];
    }
    int hako = x-tmp;
    sort(m.begin(), m.end());
    while(hako>=0)
    {
        hako-=m[0];
        ans++;
    }

    cout<<ans-1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> A(n),B;
    for(auto& i:A) cin >> i;
    sort(A.begin(), A.end());
    B = A;
    for (int i = 1; i < n;++i) B[i] += B[i-1];
    const vector<int> a(A), b(B);

    auto f = [&](int mid) {
        int lwc = upper_bound(a.begin(), a.end(), a[mid]) - a.begin() - 1; // 自身以下の個数
        int mv = m * (v - (lwc + p));
        int cons = (n - p - mid) * (a[mid] + m) - (b[n - p] - b[mid]);
        return mv <= cons && a[mid]+m >= a[n-p];
    };

    int l = 0, r = n - p;
    while(l+1<r){
        int mid = (l + r) / 2;
        if(f(mid)) r = mid;
        else l = mid;
        cerr << "[" << mid << "]: " << (f(mid) ? "true" : "false") << endl;
    }
    if(r==1&&f(0)) r = 0;
    cout << n - r << endl;
}

Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>; 

ll N, K;
bool check(ll bit, vl &arr){
    ll seen = 1; //すでに見えているビルのbit列
    ll s = arr[0];
    FOR(i, 1, N){
        if(s < arr[i]){
            seen += 1<<i;
            s = arr[i];
        }
    }
    if((bit & seen) == seen){
        return true;
    }
    return false; 
}

int main() {
    cin >> N >> K;
    vl a(N);
    rep(i, N){
        cin >> a[i];
    }

    ll ans = LONG_LONG_MAX;
    //見える建物をbit列で管理、1が見える建物
    rep(bit, 1<<N){
        if(__builtin_popcount(bit) >= K && check(bit, a)){
            ll tmp = 0;
            ll s = a[0];
            FOR(i, 1, N){
                if(bit & (1<<i)){
                    if(s < a[i]){
                        s = a[i];
                    }else{
                        s++;
                        tmp += s - a[i];
                    }
                }
            }
            ans = min(ans, tmp);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program{
	static void Main(){
		int[] n = new int[10];

		for(int i=0; i<10; i++)
			n[i] = int.Parse(Console.ReadLine());

		Array.Sort(n);

		for(int i=0; i<3; i++)
			Console.WriteLine(n[9-i]);
	}
}

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     int n;
     cin>>n;
     if(n==1)
     {
         cout<<"Hello World";
         return 0;
     }
    int a,b;
    cin>>a>>b;
    cout<<a+b;   
} 

Measured memory_bytes: 764
#include <iostream>
# include <algorithm>
using namespace std;
int main() {
    int a,b,x;
    cin>>a>>b>>x;
    for(int i=0;i<b;i++){
        if(a==x){
            cout<<"YES";
            return 0;
        }
        else{
            a++;
        }
    }
    cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    long long n, m; cin >> n >> m;
    long long ans = 1;
    for (long long d = 1; d*d <= m; d++) {
        if (m % d != 0) continue;
        if (d * n <= m) ans = max(ans, d);
        if ((m/d) * n <= m) ans = max(ans, m/d);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<map>
using namespace std;

typedef long long LL;

struct MyInt64 {
	LL X;
	MyInt64(LL X = 0LL): X(X) {}
};

const LL Base = 1926081719260847LL, BaseInv = 696411651951639283LL, Mod = 999999999999999989LL;

inline bool operator < (MyInt64 P1, MyInt64 P2) {
	return P1.X < P2.X;
}

inline MyInt64 operator + (MyInt64 P1, MyInt64 P2) {
	
	P1.X += P2.X;
	if(P1.X >= Mod)
		P1.X -= Mod;
	
	return P1;
}

inline MyInt64 operator - (MyInt64 P1, MyInt64 P2) {
	
	P1.X -= P2.X;
	if(P1.X < 0)
		P1.X += Mod;
	
	return P1;
}

inline MyInt64& operator += (MyInt64&P1, MyInt64 P2) {
	
	P1.X += P2.X;
	if(P1.X >= Mod)
		P1.X -= Mod;
	
	return P1;
}

inline MyInt64 operator * (MyInt64 P1, MyInt64 P2) {
	
	MyInt64 Ans;
	
	while(P2.X) {
		
		if(P2.X & 1)
			Ans += P1.X;
		
		P2.X >>= 1;
		P1.X <<= 1;
		if(P1.X >= Mod)
			P1.X -= Mod;
		
	}
	
	return Ans;
}

int N;
char str[250005];

MyInt64 H[250005], P[250005];

map<MyInt64, int> MyMap;

LL Ans;

int main() {
	
	scanf("%d", &N);
	scanf("%s", str + 1);
	
	H[0] = MyInt64(0), P[0] = MyInt64(1);
	
	for(int i = 1; i <= N; ++i) {
		
		if(str[i] == '+')
			H[i] = H[i-1] + P[i-1],
			P[i] = P[i-1];
		
		if(str[i] == '-')
			H[i] = H[i-1] - P[i-1],
			P[i] = P[i-1];
		
		if(str[i] == '<')
			H[i] = H[i-1],
			P[i] = P[i-1] * BaseInv;
		
		if(str[i] == '>')
			H[i] = H[i-1],
			P[i] = P[i-1] * Base;
		
//		printf("%lld %lld\n", H[i].X, P[i].X);
		
	}
	
	for(int i = N; i >= 0; --i) {
		
		Ans += MyMap[H[N] * P[i] + H[i]];
		
		++MyMap[H[i]];
		
	}
	
	printf("%lld\n", Ans);
	
	return 0;
}

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

string S, T;
int dp[3010][3010];

int main()
{
    cin >> S >> T;
    for(int i = 1; i <= S.size(); i++)
    {
        for(int j = 1; j <= T.size(); j++)
        {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if(S[i - 1] == T[j - 1])dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    }

    string ans;
    int y = S.size(), x = T.size();
    while(y > 0 && x > 0)
    {
        if(S[y - 1] == T[x - 1])
        {
            ans += S[y - 1];
            y--;
            x--;
        }
        else if(dp[y - 1][x] >= dp[y][x - 1]) y--;
        else x--;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,cnt=0,sum=0;
     string str;
     cin>>str;
     for(int i=0;i<str.size();i++)
     {
         if(str[i]=='B')
            cnt++;
         else
            sum+=cnt;
     }
     cout<<sum<<endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  reverse(data.begin(), data.end());
  int a = 0, b = 0, flag = 0;
  for(int i = 0; i < N - 1; i++) {
    if(data.at(i) == data.at(i + 1) && flag == 0) {
      a = data.at(i);
      flag++;
      i++;
      continue;
    }
    if(data.at(i) == data.at(i + 1) && flag == 1) {
      b = data.at(i);
      break;
    }
    
  }
  cout <<(long) a * b << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include<stdlib.h>
int main()
{
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if (A <=C)
	{
		if (C <=B)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	else
	{
		printf("No\n");
	}
	system("pause");
}

Measured memory_bytes: 504
import math
n,k = map(int,input().split())

def ncr(n,r):
    f = math.factorial
    return (f(n) // f(r) // f(n-r))


for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    else:
        print(ncr(n-k+1, i) * ncr(k-1,i-1) % (10**9+7))

Measured memory_bytes: 3316
import copy

S = list(map(int, list(input()))) # str型だと書き換えの方法がスライスしかなくて面倒
N = len(S)
#print(S)
T = copy.copy(S)

ans1 = 0
ans2 = 0

for i in range(N-1):
    if S[i] == S[i+1]:
        S[i+1] = 1 ^ S[i+1]
        ans1 += 1
        #print(S)

T[0] = 1 ^ T[0]
ans2 += 1
for i in range(N-1):
    if T[i] == T[i+1]:
        T[i+1] = 1 ^ T[i+1]
        ans2 += 1
        #print(T)

ans = min(ans1, ans2)
print(ans)

Measured memory_bytes: 5160
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  
  	ll ans = 0;
  	for(int i = 1; i < n; i++){
    	if(a[i-1] > a[i]){
          ans += a[i-1] - a[i];
          a[i] = a[i-1];
        }
    }
  
    cout << ans << endl;
}

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

Measured memory_bytes: 256
arr = []
temp = []
for i in range(3):
    t = list(map(int, input().split()))
    arr.append(t)
    temp.extend(t)
    
n = int(input())
for i in range(n):
    a = int(input())
    if a in temp:
        for i in range(3):
            for j in range(3):
                if arr[i][j] == a:
                    arr[i][j] = 'X'
                if arr[0][j] == arr[1][j] == arr[2][j] or  arr[0][0] == arr[1][1] == arr[2][2] or arr[0][2] == arr[1][1] == arr[2][0] or set(arr[i]) == {'X'}:
                    print('Yes')
                    exit()
        
print('No')

Measured memory_bytes: 9248
#include <iostream>
using namespace std;
int main(void){
  long n,m;
  cin >> n >> m;
  
  long ans = 0;
  
  if(n * 2 >= m)
    ans = m / 2;
  else{
    ans += n;
    m -= n * 2;
    ans += m / 4;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
        import java.math.BigDecimal;
        import java.math.BigInteger;
        import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int X = in.nextInt();
        int Y = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int[] p = new int[A];
        int[] q = new int[B];
        int[] r = new int[C];
        for (int i = 0; i < A; i++)
            p[i] = in.nextInt();
        for (int i = 0; i < B; i++)
            q[i] = in.nextInt();
        for (int i = 0; i < C; i++)
            r[i] = in.nextInt();
        Arrays.sort(p);
        Arrays.sort(q);
        Arrays.sort(r);
        int[] apples = new int[X + Y];
        for (int i = 0; i < X; i++)
            apples[i] = p[A - 1 - i];
        for (int i = 0; i < Y; i++)
            apples[i + X] = q[B - 1 - i];
        Arrays.sort(apples);
        for (int i = 0; i < C && i < X + Y; i++)
            if (apples[i] < r[C - 1 - i])
                apples[i] = r[C - 1 - i];
            else
                break;
        long ans = 0;
        for (int i = 0; i < X + Y; i++)
            ans += apples[i];
        out.println(ans);
        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}

Measured memory_bytes: 62920
N, Y = map(int, input().split())

i,j,k = 0,0,0
for x in range(N + 1):
    for y in range((N + 1) - x):
        if 4 * y == int(Y / 1000) - N - 9 * x:
            i = x
            j = y
            k = N - x - y
            break
        else:
            continue
if i == 0 and j == 0 and k == 0:
    print(-1,-1,-1)
else:
    print(i,j,k)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long ans,now=10;
int main()
{
    long long n;
    now=10;
    cin>>n;
    if(n%2==0)
    {
    	while(now<=n)
    	{
    		ans+=n/now;
	        now=now*5;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

biggest = max(a)

a.remove(biggest)
#print(a)
b = [abs(x-biggest/2) for x in a]

smol = min(b)
#print(b)
index = -1
for i in range(len(b)):
  if b[i] == smol:
    index = i
    break


r = a[index]

print(biggest, r)

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

int main(void){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x>=r && x<=W-r && y>=r && y<=H-r){
    cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}



Measured memory_bytes: 3084
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class Data
{
public:
    int w, s;
    long long v;
    bool operator< (const Data& d) const{
        return min(s, d.s - w) < min(d.s, s - d.w);
    }
};

const long long INF = LLONG_MAX / 2;

int main()
{
    int n;
    cin >> n;
    vector<Data> d(n);
    for(int i=0; i<n; ++i)
        cin >> d[i].w >> d[i].s >> d[i].v;
    sort(d.begin(), d.end());

    vector<long long> dp(10001, -INF);
    for(int i=0; i<n; ++i){
        for(int a=1; a<=10000; ++a){
            int b = min(d[i].s, a - d[i].w);
            if(b >= 0)
                dp[b] = max(dp[b], dp[a] + d[i].v);
        }
        dp[d[i].s] = max(dp[d[i].s], d[i].v);
    }

    long long ans = *max_element(dp.begin(), dp.end());
    cout << ans << endl;

    return 0;
}


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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    char c[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < 1<<h; i++){
        for(int j = 0; j < 1<<w; j++){
            int count = 0;
            for(int I = 0; I < h; I++){
                if(i>>I&1)  continue;
                for(int J = 0; J < w; J++){
                    if(j>>J&1)  continue;
                    count += c[I][J]=='#';
                }
            }
            ans += (count==k);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int N,ans=1;
    string S;
    cin >> N;
    cin >> S;

    for(int i=0;i<N-1;i++){
        if(S[i] != S[i+1]){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
int main(){
	int N,a[100000];
	ll sum=0;
	scan(N);
	rep(i,N){
		scan(a[i]);
		sum+=a[i]-1;
	}
	prin(sum);
	return 0;
}


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

bool solve(){
    int n, p, r;
    cin >> n >> p;
    if(n == 0) return false;
    vector<int> a(n);
    r = p;
    for(int i=0;;i=(i+1)%n){
        if(r>0){
            a[i]++;
            r--;
        }else{
            r += a[i];
            a[i] = 0;
        }
        if(a[i] == p){
            cout << i << endl;
            break;
        }
    }
    return true;
}

int main(){
    while(solve());
    return 0;
}


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

int main(){
	int N;
	cin>>N;
	
	long long int a[3*N];
	for(int i=0;i<N*3;i++)
		cin>>a[i];
	
	sort(a,a+N*3,greater<int>());

	long long int ans=0;
	for(int i=1;i<2*N;i+=2){
			ans+=a[i];
			//cout<<a[i]<<endl;
		}
	
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
 
int main(){
	char str[102];
  	int out=0;
  	fgets(str,sizeof(str),stdin);
   	for(int i=0;str[i]!='\n';i++){
      if(i%2==0){
      	if(str[i]=='R'||str[i]=='U'||str[i]=='D'){
			;     
        }else{
          out = 1;
          break;
        }
      }else{
        if(str[i]=='L'||str[i]=='U'||str[i]=='D'){
			;     
        }else{
          out = 1;
          break;
        }
      }
    }
      if(out==0){ printf("Yes");}
      else{ printf("No");}
	  return 0; 
    }

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

int main(){
    int n;
    cin>>n;
    vector<P> dat(n);
    rep(i,n) cin>>dat[i].second>>dat[i].first;
    sort(dat.begin(),dat.end());
    int now=0;
    rep(i,n){
        now+=dat[i].second;
        if(now>dat[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 4776
import java.io.*;
  
class Main{
	public static void main(String[] args) throws IOException{

		int x,y,i,j;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] str = br.readLine().split(" ");
			x = Integer.parseInt(str[0]);
			y = Integer.parseInt(str[1]);

			if(x == 0 && y ==0){
				break;
			}

			for(i = 0; i < x; i++){
				for(j = 0; j < y; j++){
					if(i == 0 || i+1 == x){
						System.out.printf("#");
					}else if(j ==0 || j+1 == y){
						System.out.printf("#");
					}else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
  	}
}

Measured memory_bytes: 45868
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
typedef long long Long;
typedef double Double;

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

bool isSet(Long n, int b) { return (n >> b) & 1LL; }

void printRow(int x) { cout << bitset<5>(x).to_string() << endl; }

void printMat(const vector<Long>& mat) {
  for (auto& x : mat) {
    printRow(x);
  }
}

vector<Long> getRREF(const vector<Long>& mat) {
  vector<Long> res = mat;
  int rank = 0;
  for (int row = 0, col = 63; row < res.size() && col >= 0; --col) {
    for (int i = row; i < res.size(); ++i) {
      if (isSet(res[i], col)) {
        swap(res[row], res[i]);
        break;
      }
    }
    if (!isSet(res[row], col)) continue;
    ++rank;
    for (int i = 0; i < res.size(); ++i) {
      if (i == row) continue;
      if (isSet(res[i], col)) {
        res[i] ^= res[row];
      }
    }

    ++row;
  }

  return {begin(res), begin(res) + rank};
}

int getRank(const vector<Long>& mat) {
  int res = 0;
  for (auto& x : mat) {
    res += (x != 0);
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int t;
  cin >> t;

  vector<Long> a;

  string s;
  while (t--) {
    int n;
    cin >> n;
    a.resize(n);
    cin >> a;
    cin >> s;
    vector<Long> zeroes;
    vector<Long> all;
    bool winner = 0;
    for (int i = sz(s) - 1; i >= 0; --i) {
      if (s[i] == '0') {
        zeroes.emplace_back(a[i]);
      }
      all.emplace_back(a[i]);
      zeroes = getRREF(zeroes);
      all = getRREF(all);
      if (getRank(zeroes) != getRank(all)) {
        winner = 1;
        break;
      }
    }
    cout << winner << endl;
  }

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 998244353;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
mint dp[3010][3010];
void input() { cin >> a >> b >> c >> d; }
void solve() {
    dp[a][b] = 1;
    rep(i, c - a + 1) {
        rep(j, d - b + 1) {
            x = i + a;
            y = j + b;
            dp[x + 1][y] += dp[x][y] * y;
            dp[x][y + 1] += dp[x][y] * x;
            dp[x + 1][y + 1] -= dp[x][y] * x * y;
            // cout << dp[x][y].a << endl;
        }
    }

    cout << dp[c][d].a << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 74084
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int sum;
	
	sum = 0;
	cin >> n;
	if (n<10)
	{
	  sum = n;
	}
	else if (n>=10 && n <= 99)
	{
	  sum = 9;
	}
	else if (n>=100 && n<1000)
	{
	  sum = (n-100)+1+9;
	}
	else if (n>=1000 && n<10000)
	{
	  sum = 909;
	}
	else if (n>=10000 && n<100000)
	{
      sum = (n-10000)+1+909;
	}
	else if (n==100000) sum = 90909;
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
//小さい順にソート
int c[102];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,i;
  scanf("%d",&n);
  int a[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  merge(0,n-1,a);
  printf("%d\n",a[n-1]-a[0]);
  return 0;
}


Measured memory_bytes: 128
//abc063_a.cpp
//Sun Sep 30 18:53:45 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (a+b>=10){
		cout << "error" << endl;
	}else {
		cout << a+b << endl;
	}

}

Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    a.append(list(map(int,input().split())))
ans = 0
for i in range(1,n+1):
    c = (a[-i][0]+ans)%a[-i][1]
    if c == 0:
        continue
    else:
        ans += a[-i][1]-c
print(ans)


Measured memory_bytes: 27508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

const int M = 1000005;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> cnt(M);
	for(int x:a){
		if(cnt[x]!=0){
			cnt[x]=2;
			continue;
		}
		for(int i=x;i<M;i+=x) cnt[i]++;
	}
	int ans = 0;
	for(int x:a){
		if(cnt[x]==1) ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 7980
n=int(input())
vec=list(map(int,input().split()))
mod=10**9+7
wa=[i for i in vec]
for i in range(n-1):
  wa[i+1]+=wa[i]
ans=0
for i in range(n):
  ans += vec[i]*((wa[n-1]-wa[i])%mod)%mod
  ans %= mod
print(ans)

Measured memory_bytes: 31564
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int n,max_num = -1000001,min_num = 1000001,tmp;
	long long int sum = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		sum += tmp;
		max_num = max(max_num,tmp);
		min_num = min(min_num,tmp);
	}
	printf("%d %d %lld\n",min_num,max_num,sum);
}


Measured memory_bytes: 2716
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<numeric>

using namespace std;

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

    int P = 0, Q = 0;
    for(int i = N - 1; i >= 0; i--) {
        int num;
        cin >> num;
        P += num * (int)(pow(10, i));
    }
    for(int i = N - 1; i >= 0; i--) {
        int num;
        cin >> num;
        Q += num * (int)(pow(10, i));
    }

    vector<int> v(N);
    iota(v.begin(), v.end(), 1);

    vector<int> perm;

    do {
        int num = 0;
        for (int i = 0; i < v.size(); i++) {
            num += v[i] * (int)(pow(10, i));
        }
        perm.push_back(num);
    } while( next_permutation(v.begin(), v.end()));

    sort(perm.begin(), perm.end());

    int small = P < Q ? P : Q;
    int big = P < Q ? Q : P;
    int smallIndex, bigIndex;
    for(int i = 0; i < perm.size(); i++) {
        if(small == perm[i]) {
            smallIndex = i + 1;
        }
        if(big == perm[i]) {
            bigIndex = i + 1;
        }
    }

    cout << bigIndex - smallIndex << endl;

    return 0;
}


Measured memory_bytes: 640
# import sys
# sys.setrecursionlimit(200000)

N = list(map(int, input().split(" ")))[0]

rs = []
for i in range(1, 10):
    for j in range(1, 10):
        rs.append(i * j)
rs = set(rs)

if N in rs:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
// coding on smartphone
#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	if(n == 0){
		cout << 0 << endl;
		return 0;
    }
    
    string res = "";
  
	while(n != 0){
		if (n % 2 == 0) res = "0" + res;
		else            n--, res = "1" + res;
		n /= -2;
	}

    cout << res << endl;
    
    return 0;
}


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

using namespace std;

long long calc(vector<long long> &a, long long a0) {
	long long op = abs(a[0] - a0);

	long long sum = a0;

	for (int i = 1; i < a.size(); i++) {
		auto prev = sum;
		sum += a[i];

		if ((sum > 0 && prev < 0) || (sum < 0 && prev > 0)) {
			continue;
		}

		op += abs(sum) + 1;

		if (sum > 0) {
			sum = -1;
		} else {
			sum = 1;
		}
	}
	return op;
}

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

	vector<long long> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	long long ans = min({calc(a, 1), calc(a, -1)});
	if (a[0] != 0) {
		ans = min(ans, calc(a, a[0]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#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 < (int)(n); i++)
typedef long long ll;

int main()
{
    int n, k; cin >> n >> k;
    int d[110], a[110][110];
    vector<int> b(n);
    rep(i, k){
        cin >> d[i];
        rep(j, d[i]) {
            cin >> a[i][j];
            ++b[a[i][j] - 1];
            
        };
    };

    int c = 0;
    rep(i, n) if (b[i] == 0) ++c;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3680
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort (a,a+3);
	cout<<a[2]*10+a[1]+a[0];
	return 0;
}

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

namespace AtCoderCSharp {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine().Split(' ');
            var n = int.Parse(input[0]);
            var sum = int.Parse(input[1]);

            if (n * 500 < sum) {
                Console.WriteLine("No");
            } else {
                Console.WriteLine("Yes");
            }
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Linq;
class program{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    var ar = Console.ReadLine().Split(' ');
    long[] a = new long[n];
    long ans = 1;
    for(int i = 0;i<n;i++){
      a[i] = long.Parse(ar[i]);
      if(a[i] == 0){
        Console.Write(0);
        return;
      }
    }
    for(int i = 0;i<n;i++){
      if(ans > 1000000000000000000/a[i]){
        Console.Write(-1);
      	return;
      }
      ans *= a[i];
    }
    Console.Write(ans);
  }
}

Measured memory_bytes: 40612
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count1=0;
    for(int i=0;i<s.size();i++){
    	if(s[i]=='W')
    	count1++;
	}
	int ans=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='W'&&count1>0){
			count1--;
		}
		else{
			if(count1>0){
				ans++;
				count1--;
			}
		}
	}
	ans+=count1;
   cout<<ans<<"\n";
}

Measured memory_bytes: 3756
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut l = 0usize;
    let mut r = 0usize;
    let mut res = 1000;
    while r < n && l < n {
        if a[r] == a[l] {
            r += 1;
        } else if a[r] > a[l] {
            res += (res / a[l]) * (a[r] - a[l]);
            l = r;
        } else {
            l = r;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2200