akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <string.h>

using namespace std;

int main(){

    string s, c, r, str;

    s = "Sunny";
    c = "Cloudy";
    r = "Rainy";

    cin >> str;


    if(str.compare(s) == 0){
        cout << "Cloudy" << endl;
    }
    else if(str.compare(c) == 0){
        cout << "Rainy" << endl;
    }
    else if(str.compare(r) == 0){
        cout << "Sunny" << endl;
    }

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    string s; cin >> s;
    if(n % 2 == 1) No;
    else{
        if(s.substr(0,n/2) == s.substr(n/2,n/2)) Yes;
        else No;
    } 
    
    return 0;
}

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

int main() {
  int n, k; cin >> n >> k;
  int ans = 0;
  vector<int>x(n); for(int i = 0; i < n; i++) cin >> x[i];
  for(auto it = x.begin(); it != x.end(); ++it) ans += min(*it, k-*it);
  cout << ans * 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<assert.h>
#include<vector>
#include<string.h>
#include<algorithm>
#include<memory.h>
#include<cmath>
#include<string>
#include<iostream>
#include<set>
#include<unordered_set>
#include<map>
#include<queue>
#include<functional>
#include<list>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1<<17;
const int MM = 1000000007;

int main()
{
	string D, E = "";
	cin >> D;
	for(char c : D){
		if( E.size() && E.back() == 'S' && c == 'T' ) E.pop_back();
		else E += c;
	}
	printf("%d\n", E.size());
}


Measured memory_bytes: 776
n,m=map(int,input().split())
L=list(map(int,input().split()))
K=[0]*n

for i in range(1,m+1):
  a,b=map(int,input().split())
  if L[a-1]>L[b-1]:
    K[b-1]-=1
  if L[a-1]<L[b-1]:
    K[a-1]-=1
  if L[a-1]==L[b-1]:
    K[a-1]-=1
    K[b-1]-=1
    
print(K.count(0))

Measured memory_bytes: 20116
#include<bits/stdc++.h>、
#include<set> 
using namespace std;
int main(){ 
	int a,b,c;
	cin>>a>>b>>c;
	set<int> s;
	s.clear();
	s.insert(a),s.insert(b),s.insert(c); 
	cout<<(int)s.size()<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000
#define NIL -1
 
struct node{ 
  int p, l, r;
};
struct node T[MAX];

void depth(int);
void print(int);

int n, H, D[MAX];

int main()
{
  int i, j, d, v, c, l, r;
 
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
 
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      T[c].p = v;
      if(j >= 1)
	T[r].r = c;
      if(j == 0)
	T[v].l = c;
      r = c;
      }
  }
   
 
  for ( i = 0; i < n; i++ ){
    if(T[i].p == NIL) {
      D[i] = 0; 
      depth(i); 
      break;
    }
  }
 
  for ( i = 0; i < n; i++ ) {
    print(i);
  }
  return 0;
}

void depth(int u)
{
  int d = 0;

  if(T[u].r != NIL){   
    D[T[u].r] = D[u];
    depth(T[u].r);
  }
  if(T[u].l != NIL){ 
    D[T[u].l] = D[u]+1;
    depth(T[u].l);
  }
}
 
void print(int u)
{
  int a;

  printf("node %d: parent = %d, depth = %d,", u, T[u].p, D[u]);
  if(T[u].p == NIL)
    printf(" root, ");
  else if(T[u].l == NIL) 
    printf(" leaf, ");
  else 
    printf(" internal node, ");
  printf("[");
  a = u;
  if(T[a].l != NIL) { 
    printf("%d", T[a].l);   
    if(T[T[a].l].r == NIL) 
      printf("]\n");
    else 
      printf(", ");
    a = T[a].l;
    while(T[a].r != NIL){
      printf("%d", T[a].r);
      if(T[T[a].r].r == NIL) 
	printf("]\n");
      else 
	printf(", ");
      a = T[a].r;
    }
  }
  else
    puts("]"); 
}

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    ll A = 0;
    bool ok = false;
    REP (i, 0, s.size()) {
        if (s.substr(i, 3) == "ABC") {
            ok = true;
            A++;
        } else if (ok && s.substr(i, 2) == "BC") {
            ans += A;
            i++;
        } else if (s[i] == 'A') {
            ok = true;
            A++;
        } else {
            ok = false;
            A = 0;
        }
        /*
        dump(A);
        dump(ans);
        dump(i + 1);
        //*/
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 720
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	LLONG N, A, B; cin >> N >> A >> B;
	vector<LLONG> xs(N); REP(i, N) cin >> xs[i];
	LLONG ans = 0;
	REP(i, N - 1)
	{
		ans += min(B, A * (xs[i + 1] - xs[i]));
	}
	cout << ans << endl;
}

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


int num[100005] = {0};
int red[100005] = {0,1};


void debug(int n)
{
  for (int i = 1; i <= n; i++) {
    cout << num[i];
  }
  cout << endl;
  for (int i = 1; i <= n; i++) {
    if (red[i])
    {
      cout << 'r';
    }
    else
    {
      cout << ' ';
    }
  }
  cout << endl;
}


int main()
{
  fill(num,num+100005,1);
  int n; cin >> n;
  int m; cin >> m;
  for (int i = 0; i < m; i++) {
    int x,y; cin >> x >> y;
    num[x] -= 1;
    num[y] += 1;
    if (red[x])
    {
      red[y] = 1;
    }
    if (num [x] == 0)
    {
      red[x] = 0;
    }
    //debug(n);
  }
  int sum = 0;
  for (int i = 1; i < 100001; i++) {
    if (red[i])
    {
      sum ++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4376
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main() {
	float n, t, a, ret;
	cin >> n >> t >> a;
	float ans = 1000000;
	rep(i, n) {
		float b;
		cin >> b;
		float de = t - (b * 0.006);
		//cout << de << endl;
		if (abs(a - de) < ans) {
			ans = abs(a - de);
			ret = i + 1;
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  last updated: 2018-10-23 ...maybe
//
//    i hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -ddebug_local'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) reap(i,0,n)
#define reap(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__va_args__,reap,_rep,)(__va_args__)

#define _repr(i,n) reapr(i,n,0)
#define reapr(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define repr(...) _overload3(__va_args__,reapr,_repr,)(__va_args__)

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define coutall(a) {int loop_coutall=0;for(auto e:a) cout<<(loop_coutall++?" ":"")<<e; cout<<endl;}

#define coutyn(a) cout<<((a)?"yes":"no")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int inf=1145141919;
//const long long inf=114514191911451419;
const int mod=(int)1e9+7;
const double eps=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename t> istream &operator >> (istream &is, vector<t> &v){for(t &x:v) is>>x;return is;}
template<typename t> ostream &operator << (ostream &os, vector<t> &v){int i=0;for(t &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool ing(ll x,ll n){return 0<=x && 0<n;}
bool outg(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct arithmetic{arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define debug_local

#ifdef debug_local
template<typename t> void deb(t a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__line__<<"行目だ"<<endl;}
void what_cr(){cout<<__gcc_atomic_char16_t_lock_free<<" ←？"<<endl;}
//ori_func s

//ori_func e
#else
template<typename t>void deb(t a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  arithmetic exception;

  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;

  cout<<min(upper(n,a)*b,upper(n,c)*d)<<endl;

  return 0;

}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define N 50000
#define pb push_back
#define mp make_pair
#define MAP map<ll,ll>
#define INF 1000000000
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define sl set<ll> 
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;
ll a[100000],dp[200000];
int main(){
	fastio;
	ll n,W;
	cin>>n>>W;
	ll x=n;
	vl wt,val;
	while(x--){
		ll v,w;
		cin>>w>>v;
		wt.pb(w);
		val.pb(v);
	}
	memset(dp,0,W);
	foo(i,0,n-1){
		rep(j,W,wt[i]){
				dp[j]=max(dp[j-wt[i]]+val[i],dp[j]);
		}
	}
	cout<<dp[W];
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

const long long len = 100010;
long long n,a[len],s[len],p;
const long long mo = 1e9+7;
long long mi[len];

void extend_gcd(long long a, long long b, long long &x, long long &y) {
    if (!b) {
        x = 1, y = 0;
        return;
    }
    extend_gcd(b, a % b, y, x);
    y -= a / b * x;
}
/*
long long c(long long x,long long y) {
	if (y<x) return 0;
	long long m,n;
	extend_gcd(mi[y-x]*mi[x], mo, n, m);
    return (mi[y]*n%mo+mo)%mo;
}*/

int inv[len];
long long c(int n, int m) {
	if(m < n) return 0;
	return mi[m] * inv[n]% mo * inv[m - n] %mo;
}
int Pow(int a, int b) {
	int ret = 1;
	while(b) {
		if(b & 1) ret = 1LL * ret * a % mo;
		a = 1LL * a * a % mo;
		b >>= 1;
	}
	return ret;
}
int main()
{
	
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    mi[0] = 1;
    mi[1] = 1;
    memset(s,0,sizeof(s));
    for (int i=2;i<=len;i++) {
    	mi[i] = mi[i-1]*i%mo;
    }
    for (int i = 0; i <= len; i++) {
		inv[i] = Pow(mi[i], mo-2);
	}
//	printf("%d %d %d \n", c(2,3), c(2,4), c(1, 2));
    cin >> n;
    for (int i=1;i<=n+1;i++) {
    	cin >> a[i];
    }
    for (int i=1;i<=n+1;i++) {
    	s[a[i]]++;
    	if (s[a[i]] == 2) {p = a[i];break;}
    }
    long long l[2];
    long long k = 0;
    for (int i=1;i<=n+1;i++) {
    	if (a[i] == p) {
    		l[k] = i;k++;
    	}
    }
    long long m = n+1-(l[1]-l[0]+1);
    for (int i=1;i<=n+1;i++) {
    	if (i == 1) cout << n << endl;
    	 else {
    	 if (i == n+1) cout << 1 << endl;
    	 else {
    	 	long long ans = ((c(i,n+1) - c(i-1,m))%mo+mo)%mo;
    	 	printf("%lld\n",ans);
    	   }
    	 }
    }
    return 0;  
}

Measured memory_bytes: 3968
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> Pii;
typedef pair<int,int> Piii;
#define F first
#define S second

int a,b,c,d,e,f;
int memo[3333][3333]={{0}};
Pii mp(0,0);

void rec(int w,int s){
  if(memo[w][s]!=0)return ;

  //printf("%d %d\n",w,s);
  memo[w][s]=1;
  //砂糖水がfより多いなら
  //if(w>f) return ;
  //砂糖が溶け残っていたら
  if(w>0 && (double)s/w > (double)e/(100+e)) return ;

  Pii p(w,s);
  if(mp.F<=0 || w<=0)mp=p;
  else if((double)mp.S/mp.F <= (double)s/w) mp=p;
  
  if(w+(100*a)<=f)
    rec(w+(100*a),s);
  if(w+(100*b)<=f)
    rec(w+(100*b),s);
  if(w>0){
    if(w+c<=f)
      rec(w+c,s+c);
    if(w+d<=f)
      rec(w+d,s+d);
  }
  // memo[w][s]=1;
  
  return ;
}
int main(){
  scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

  for(int i=0;i<=f;i++){
    for(int j=0;j<=f;j++){
      memo[i][j]=0;
    }
  }
  
  //(現在の砂糖水の質量, 溶けてる砂糖の質量)
  rec(0,0);
  int f=mp.F;
  int s=mp.S;

  printf("%d %d\n",f,s);
  
  return 0;
}


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


using namespace std;


using ll = long long;


mt19937 mt(736);


template<class T>
T &remax(T &x, const T &y)
{
	return x = max(x, y);
}


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<pair<int, int>> arr(n);

	int ans = 0;

	for (auto &it : arr)
	{
		cin >> it.first >> it.second;
		it.first--;

		remax(ans, it.second - it.first);
	}

	cerr << ans << endl;

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

	int l = 0, r = 0;

	for (int i = 0; i < arr.size(); i++)
	{
		if (arr[i].second < arr[l].second)
			l = i;
		if (arr[i].first > arr[r].first)
			r = i;
	}

	for (int i = 0; i < arr.size(); i++)
		if (i != l && i != r)
			remax(ans, arr[i].second - arr[i].first + max(0, arr[l].second - arr[r].first));

	cerr << ans << endl;

	vector<int> rb(arr.size() + 1);

	rb.back() = arr[r].second;

	for (int i = (int) arr.size() - 1; i >= 0; i--)
		rb[i] = min(rb[i + 1], arr[i].second);

	for (int i = 0; i <= arr.size(); i++)
	{
		int lb = arr[l].first;

		if (i != 0)
			remax(lb, arr[i - 1].first);

		remax(ans, max(0, arr[l].second - lb) + max(0, rb[i] - arr[r].first));
	}

	cout << ans << endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	solve(fin);

	cout << "clock: " << setprecision(4) << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S= sc.nextLine();
		String T = sc.nextLine();
		sc.close();

		int ans = 0;

		for (int i=0; i<3; i++){
			if (S.charAt(i) == T.charAt(i)){
				ans++;
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 22228
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

long[2][] primeFact(long x)
{
	long[2][] ans;
	for (long i = 2; i*i <= x; ++i)
	{
		if (x % i != 0) continue;

		long r;
		while (x % i == 0)
		{
			++r;
			x /= i;
		}
		ans ~= [i, r];
	}
	if (x != 1)
		ans ~= [x, 1];
	return ans;
}

void main()
{
	auto A = RD;
	auto B = RD;

	auto aa = primeFact(A);
	auto bb = primeFact(B);

	debug writeln(aa);
	debug writeln(bb);

	bool[long] set;
	foreach (e; aa)
	{
		set[e[0]] = true;
	}
	long ans = 1;
	foreach (e; bb)
	{
		if (set.get(e[0], false) == true)
			++ans;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	pair<int, int> p[n];
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		p[i]=make_pair(a, i+1);
	}
	sort(p, p+n);
	for(int i=0; i<n; i++){
		cout << p[i].second << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
 #define rep(i,n) for(int i=0;i<n;i++)
 using namespace std;
  int main(){
      int x;
      cin >> x;
      if(x>=30){
          cout << "Yes" << endl;
      }
      else{
          cout << "No" << endl;
      }
    
  }

Measured memory_bytes: 3632
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int color (int n)
{
  if (1 <= n && n <= 399) return 0;
  if (400 <= n && n <= 799) return 1;
  if (800 <= n && n <= 1199) return 2;
  if (1200 <= n && n <= 1599) return 3;
  if (1600 <= n && n <= 1999) return 4;
  if (2000 <= n && n <= 2399) return 5;
  if (2400 <= n && n <= 2799) return 6;
  if (2800 <= n && n <= 3199) return 7;
  else return 8;
}

int main()
{
  int n, minimum, maximum;
  cin >> n;
  int s[9];
  for (int i = 0; i < 9; i++) s[i] = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (color(a) != 8) s[color(a)] = 1;
    else s[color(a)]++;
  }
  int tmp = 0;
  for (int i = 0; i < 8; i++) tmp += s[i];
  if (s[8] == 0) minimum = maximum = tmp;
  else if (tmp == 0) {
    minimum = 1;
    maximum = tmp + s[8];
  } else {
    minimum = tmp;
    maximum = tmp + s[8];
  }
  cout << minimum << " " << maximum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const int MAXN = 1.1e7;

int N;
ll fac[MAXN];
ll finv[MAXN];

ll cpow (ll b, int e)
{
    if (e == 0) return 1;
    ll v = cpow (b, e / 2);
    v = (v * v) % MOD;
    if (e % 2)
        v = (v * b) % MOD;
    return v;
}

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

    cin >> N;
    fac[0] = 1;
    for (int i = 1; i <= N; i++)
        fac[i] = (fac[i-1] * i) % MOD;
    finv[N] = cpow (fac[N], MOD - 2);
    for (int i = N - 1; i >= 0; i--)
        finv[i] = (finv[i+1] * (i + 1)) % MOD;

    ll p2 = 1;
    ll ans = 0;
    for (int i = 0; i < N / 2; i++)
    {
        // N choose i * 2 ^ i
        ll nadd = (fac[N] * ((finv[i] * finv[N-i]) % MOD)) % MOD;
        ans = (ans + (nadd * p2)) % MOD;

        p2 = (2 * p2) % MOD;
    }
    ans = (2 * ans) % MOD;

    ll p3 = 1;
    for (int i = 0; i < N; i++)
        p3 = (3 * p3) % MOD;
    ans = (p3 - ans + MOD) % MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 162048
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+50;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int a[N],f[N],cnt[N];
int main(){
    int n=gi(),m=gi();
    for (int i=1; i<=n; ++i) ++cnt[a[i]=gi()];
    for (int i=1; i<=n; ++i)
	if (cnt[i])
	    for (int j=max(0,i-cnt[i]); j<i; ++j)
		++f[j];
    int ans=0;
    for (int i=0; i<n; ++i) ans+=(f[i]==0);
    for (int i=1; i<=m; ++i){
	int id=gi(),x=a[id],y=gi();
	a[id]=y;
	if (x-cnt[x]>=0){
	    --f[x-cnt[x]];
	    if (f[x-cnt[x]]==0) ++ans;
	}
	--cnt[x],++cnt[y];
	if (y-cnt[y]>=0){
	    ++f[y-cnt[y]];
	    if (f[y-cnt[y]]==1) --ans;
	}
	printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3960
#include <iostream>
#include <vector>
#include <cassert>
#include <cstring>

using namespace std;

int main(void)
{
	int W, H, N;
	cin >> W >> H >> N;

	int box[W][H];
	memset(&box, 0, sizeof(box));

	while (N-- > 0) {
		int x, y, a;
		cin >> x >> y >> a;
		switch (a) {
		case 1:
			for (auto i = 0; i < x; i++) {
				for (auto j = 0; j < H; j++) {
					box[i][j] = 1;
				}
			}
			break;
		case 2:
			for (auto i = x; i < W; i++) {
				for (auto j = 0; j < H; j++) {
					box[i][j] = 1;
				}
			}
			break;
		case 3:
			for (auto i = 0; i < W; i++) {
				for (auto j = 0; j < y; j++) {
					box[i][j] = 1;
				}
			}
			break;
		case 4:
			for (auto i = 0; i < W; i++) {
				for (auto j = y; j < H; j++) {
					box[i][j] = 1;
				}
			}
			break;
		default:
			assert(false);
			break;
		}
	}

	int r = 0;
	for (auto i = 0; i < W; i++) {
		for (auto j = 0; j < H; j++) {
			if (box[i][j] == 0) r++;
		}
	}

	cout << r << endl;

	return 0;
}

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

using namespace std;
int n,a,b,c;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&a,&b,&c);
		if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
  return 0;
}

Measured memory_bytes: 3136
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    println!("{} {} {}", v[2], v[0], v[1]);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll N=500001;
ll n,q,c[N],l[N],r[N],a[N],b[N],ans[N];
vector<pair<ll,ll>> x[N];

void add(ll x,ll v){
  for(int i=x;i<=n;i+=i&(-i))
    b[i]+=v;
}

int sum(ll x){
  ll v=0;
  for(int i=x;i>0;i-=i&(-i))v+=b[i];
  return v;
}

int main(){
  ios::sync_with_stdio(false),cin.tie(nullptr);
  cin>>n>>q;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=q;i++){
    cin>>l[i]>>r[i];
    x[r[i]].push_back({l[i],i});
  }
  for(int i=1;i<=n;i++){
    if(a[c[i]])add(a[c[i]],-1);
    a[c[i]]=i;
    add(i,1);
    for(auto [d,e]:x[i])ans[e]=sum(i)-sum(d-1);
  }
  for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 51976
#include <iostream>
#include <stack>

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  string s;
  cin >> s;

  int n = s.length();

  stack<char> t;

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (t.empty()) {
      t.push(s[i]);
      continue;
    }

    int l = t.top();
    if (s[i] != l) {
      t.pop();
      ans += 2;
    } else
      t.push(s[i]);
  }

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


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = ll(1e9)+7;
const ll inf = ll(5e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BReverseAndCompare {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;
	    map<char, ll> cnt;
	    for(int i=0; i<s.length(); i++){
	        cnt[s[i]]++;
	    }

	    ll slen = s.length();
	    ll res = slen*(slen-1) / 2;
	    for(auto const& e : cnt){
            res -= e.second * (e.second - 1) / 2;
	    }
	    res++;
	    out << res << endl;
	}
};


int main() {
	BReverseAndCompare solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int getSum(int n){
	int sum=0;
	while(n>0){
		sum+=n%10;
		n/=10;
	}
	return sum;
}

int main(){
	int N,A,B;
	cin>>N>>A>>B;
	
	int ans=0;
	for(int i=1;i<=N;i++){
		if(A<=getSum(i)&&getSum(i)<=B){
			ans+=i;
		}
			
	}
	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;

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

    if (n&1) {
        cout << 0;
        return 0;
    }

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

    cout << a[n / 2] - a[n / 2 - 1];
}


Measured memory_bytes: 3772
a = []
b = []
c = []
ans = []
n = (int)(input())
for i in range(10,30001):
	if i % 2 != 0 and i % 3 == 0:
		a.append(i);
for i in range(10,30001):
	if i % 2 == 0 and i % 3 != 0:
		b.append(i);
for i in range(10,30001):
	if i % 6 == 0:
		c.append(i);
b.append(8)
if n >= 5:
	n -= 5
	ans = [2,4,3,9,6]
elif n == 4:
	n = 0
	ans = [2,5,20,63]
elif n == 3:
	n = 0
	ans = [2,5,63]
k = (int)(len(b) / 2)
for i in range(0,k):
	if n >= 2:
		ans.append(b[i * 2])
		ans.append(b[i * 2 + 1])
		n -= 2
k = (int)(len(a) / 2)
for i in range(0,k):
	if n >= 2:
		ans.append(a[i * 2])
		ans.append(a[i * 2 + 1])
		n -= 2
k = len(c)
for i in range(0,k):
	if n >= 1:
		ans.append(c[i])
		n -= 1
print(*ans)

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

int main(){
  string s;
  cin >> s;
  for(int i = 0;i < (int)s.size() - 1;i++){
    if(s[i]==s[i + 1]){
      cout << "Bad" <<endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        int[]A=nai(n);
        int[]dp=new int[n];
        dp[0]=0;
        dp[1]=Math.abs(A[0]-A[1]);
        for(int i=2;i<n;i++)
            dp[i]=Math.min(dp[i-1]+Math.abs(A[i-1]-A[i]),dp[i-2]+Math.abs(A[i-2]-A[i]));
        pn(dp[n-1]);
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj =true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 33096
N = int(input())
T = []
A = []
Nb = 0
for i in range(N):
    a, b = map(int,input().split())
    T.append(a)
    A.append(b)
Tn = 1
An = 1
for i in range(N):
        tmp = max((Tn+T[i]-1) // T[i], (An+A[i]-1) // A[i])
        Tn = T[i] * tmp
        An = A[i] * tmp
print(Tn + An)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int r; cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(string S){
  reverse(S.begin(),S.end());
  vector<ll> sums(S.size()+1);
  {
    ll tmp=1;
    REP(S.size()){
      sums[i+1]=tmp*(S[i]-'0')%2019;
      tmp=tmp*10%2019;
    }
    REP(S.size()){
      sums[i+1]+=sums[i];
      sums[i+1]%=2019;
    }
  }
  dump(sums);
  map<ll,ll> m;
  REP(sums.size()){
    if(m.count(sums[i])){
      ++m[sums[i]];
    }else{
      m[sums[i]]=1;
    }
  }
  ll ans=0;
  for (auto &&i : m)
  {
    ans+=(i.second*(i.second-1))/2;
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    string S;
    cin>>S;
    solve(S);
    return 0;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int x;
  cin >> x;
  if(x == 3 || x == 5 || x == 7) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 256
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
ll a[200005];
int main()
{
    ll n;
    sl(n);
    for(ll i=0;i<n;i++)
    {
        sl(a[i]);
    }
    ll sum=1000,ns=0;
    for(ll i=0;i<n-1;i++)
    {
        if(a[i]<a[i+1])
        {
            if(sum>0)
            {
                ns+=(sum/a[i]);
                ll nu=sum/a[i];
                sum-=(nu*a[i]);
            }
        }
        else if(a[i]>a[i+1])
        {
            sum+=(a[i]*ns);
            ns=0;
        }
    }
    if(ns>0)
    {
        sum+=(a[n-1]*ns);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3720
S = input()
N = len(S)
i = N
while i:
    if S[i-5:i] == 'dream':
        i -= 5
    elif S[i-5:i] == 'erase':
        i -= 5  
    elif S[i-7:i] == 'dreamer':
        i -= 7
    elif S[i-6:i] == 'eraser':
        i -= 6
    else:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 39792
open Printf
open Scanf

let () =
  let (w,h,n) = scanf " %d %d %d" (fun w h n -> w,h,n) in
  let a = Array.init n (fun _ -> scanf " %d %d %d" (fun w h n -> w,h,n)) in
  let (min_x,min_y,max_x,max_y) =
    Array.fold_left (fun (x',y',x'',y'') (x,y,a) ->
        match a with
        | 1 -> (max x' x, y', x'', y'')
        | 2 -> (x', y', min x'' x, y'')
        | 3 -> (x', max y' y, x'', y'')
        | 4 -> (x', y', x'', min y'' y)
        | _ -> assert false
      ) (0,0,w,h) a in
  let dx = max_x - min_x in
  let dy = max_y - min_y in
  if dx >= 0 && dy >= 0
  then printf "%d\n" @@ dx*dy
  else printf "0\n"


Measured memory_bytes: 512
while True:
    h,w = list(map(int, input().strip().split()))
    if h==0 and w==0:
        break
    for i in range (h):
        if i%2==0:
            if w%2==1:
                print("#."*(w//2)+"#")
            else:
                print("#."*(w//2))
        if i%2==1:
            if w%2==1:
                print(".#"*(w//2)+".")
            else:
                print(".#"*(w//2))
        
    print()


Measured memory_bytes: 5608
#include <iostream>

int main() {
    using namespace std;
    int a, b, c;
    int x, y;
    int cost = 0;
    cin >> a >> b >> c >> x >> y;
    if (2 * c < a + b) {
        int minxy = min(x, y);
        cost += minxy * 2 * c;
        x -= minxy;
        y -= minxy;
    }
    if (2 * c < a && x > 0) {
        cost += x * 2 * c;
        y -= x;
        x = 0;
    }
    if (2 * c < b && y > 0) {
        cost += y * 2 * c;
        x -= y;
        y = 0;
    }
    if (x > 0) {
        cost += x * a;
        x = 0;
    }
    if (y > 0) {
        cost += y * b;
        y = 0;
    }
    cout << cost << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N;
    cin >> N;
    lint cur_num = N;
    lint sum_digits = 0;
    while (cur_num) {
        lint lsd = cur_num % 10;
        cur_num /= 10;
        sum_digits += lsd;
    }
    cout << (N % sum_digits ? "No" : "Yes") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int a, p; cin >> a >> p;
    cout << (3 * a + p) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 998244353;

void solve() {
    char x;
    cin >> x;
    if((ll)x >= 65 && (ll)x <= 90) cout << "A";
    else cout << 'a';
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	int l = 0, r = 0;
	for( char c : s ){
		if( c == '(' ) ++r;
		else if( c == ')' ){
			if ( r > 0 ) --r;
			else ++l;
		}
	}
	for( int i = 0; i < l; ++i ) cout << '(';
	cout << s;
	for( int i = 0; i < r; ++i ) cout << ')';
	cout << endl;
	return 0;
}

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

using namespace std;

typedef tuple<int, int, int> line;

int main() {

  while ( true ) {
	int n, m, a;
	cin >> n >> m >> a;

	if ( n == 0 and m == 0 and a == 0 ) break;
	
	vector<line> ls;
	for ( int i = 0; i < m; i++ ) {
	  int h, p, q;
	  cin >> h >> p >> q;
	  ls.push_back( make_tuple( -h, p - 1, q - 1 ) );
	}

	vector<int> vs(n);
	for ( int i = 0; i < n; i++ ) {
	  vs[ i ] = i;
	}
	sort( ls.begin(), ls.end() );
	for ( auto t : ls ) {
	  int i1 = get<1>( t );
	  int i2 = get<2>( t );
	  swap( vs[ i1 ], vs[ i2 ] );
	}

	for ( int i = 0; i < n; i++ ) {
	  if ( vs[ i ] == a - 1 ) {
		cout << i + 1 << endl;
	  }
	}

	
	
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,K;
  string S;
  cin>>N>>S>>K;
  char c[N];
  for(int i=0;i<N;i++){
  	if(S[K-1]!=S[i]) c[i]='*';
    else c[i]=S[K-1];
    cout<<c[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
	int n, x[101], y[101];
	double s1, s2 = 0, s3 = 0, s4 = 0;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
			scanf("%d", &x[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &y[i]);
	}

	for (int i = 0; i < n; i++) {
		s1 += abs(x[i] - y[i]);
		s2 += pow(x[i] - y[i], 2);
		s3 += pow(abs(x[i] - y[i]), 3);
		if (s4 < abs(x[i] - y[i])) {
			s4 = abs(x[i] - y[i]);
		}
	}
	s2 = pow(s2, (double)1/2);
	s3 = pow(s3, (double)1/3);
	printf("%lf\n%lf\n%lf\n%lf\n", s1, s2, s3, s4);

	return 0;
}


Measured memory_bytes: 2104
n=int(input())
m=0
a=0
r=0
c=0
h=0
for i in range(n):
    s=input()
    if s[0]=="M":
        m+=1
    if s[0]=="A":
        a+=1
    if s[0]=="R":
        r+=1
    if s[0]=="C":
        c+=1
    if s[0]=="H":
        h+=1
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)



Measured memory_bytes: 9080
#include <iostream>
#include<vector>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
    string s;
    cin >> s;
  
  int l = s.length();
  
  bool ans = true;
  
  if(l % 2 != 0) ans = false;
  
  for(int i=0;i<l;i+=2){
    if(s[i] != 'h') ans = false;
  }
  
  for(int i=1;i<l;i+=2){
    if(s[i] != 'i') ans = false;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
    
}


Measured memory_bytes: 256
N, X, M = map(int,input().split())
i = X % M
L = [i]
S = set([i])
i = i ** 2 % M
while not i in S:
    L.append(i)
    S.add(i)
    i = i ** 2 % M
index = L.index(i)
k = (N - index) // len(L[index:])
l = (N - index) % len(L[index:])

ans = sum(L[:index]) + (k * sum(L[index:]) + sum(L[index:index + l]))
print(ans)

Measured memory_bytes: 13252