akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI = 2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  string s,t; cin >>s >>t;
  int n = s.size(), m = t.size();
  vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
  // dp[i][j]...sの1..i文字目、tの1..j文字目の部分列で最長のものの長さ
  for (int i=0; i<n; i++){
    for (int j=0; j<m; j++){
      if (s.at(i) == t.at(j)) chmax(dp[i+1][j+1], dp[i][j] + 1);
      chmax(dp[i+1][j+1], dp[i+1][j]);
      chmax(dp[i+1][j+1], dp[i][j+1]);
    }
  }
  string res = "";
  int i=s.size(), j=m;
  while (i>0 && j>0){
    if (dp[i][j] == dp[i-1][j]) i--;
    else if (dp[i][j] == dp[i][j-1]) j--;
    else{
      res = s.at(i-1) + res;
      i--; j--;
    }
  }
  cout <<res <<endl;
}


Measured memory_bytes: 35584
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  vector<int> A(3);
  loop(i,0,3) cin >> A[i];
  sort(A.begin(), A.end());
  if (A[0] != A[1]) cout << A[0] << endl;
  else cout << A[2] << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define dbg(x) cerr << #x"= " << x << endl
 
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());
 
inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }
 
 
void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}
 
int bf(int n,int m,vi &a){
    int ret=0;
    for(int x=1;x<=m;++x){
        bool doit=true;
        for(int j=0;j<n;++j){
            if (x < a[j]/2) {doit=false;break;}
            if ((x-a[j]/2)%a[j]!=0) {doit=false;break;}
        }
        if (doit) ++ret;
    }
    return ret;
}
int main() {
    READ(1);
    int n,m;cin>>n>>m;
    vi a(n);
    FOR(i,n) {cin>>a[i];}
 //   dbg(bf(n,m,a));
    FOR(i,n) a[i] /= 2;
    ll r=a[0];
    for(int i=1;i<n;++i){
        if (r>m) break;
        r=lcm(r,a[i]);
    }
    if (r>m){cout << 0;return 0;}
    for(int i=0;i<n;++i){
        int y=r/a[i];
        if (y%2==0){cout << 0 ; return 0;}
    }
    ll ret=m/r;
    if (ret%2==0) ret/=2;
    else ret = ret/2+1;
    cout << ret << endl;
 
    return 0;
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 200500;

ll ans;
stack < int > st;
int n, p[N], l[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n;

	st.push(0);

	for (int i = 1; i <= n; i++) {
		cin >> p[i];
		while (!st.empty() && p[st.top()] > p[i])
			st.pop();
		l[i] = st.top();
		st.push(i);
	}

	while (!st.empty())
		st.pop();
	st.push(n + 1);

	for (int i = n; i >= 1; i--) {
		while (!st.empty() && p[st.top()] > p[i])
			st.pop();
		ans += p[i] * (st.top() - i + 0ll) * (i - l[i] + 0ll);
		st.push(i);
	}

	cout << ans;
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


Measured memory_bytes: 2688
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt(),m=nxt();
    ll maxi=4*n;
    if(m>maxi or m<2*n)
    {
        cout<<"No\n";
    }
    else
    {
        ll left=maxi-m;
        if(left%2==0)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    
	printclock;
	return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		if( Character.isUpperCase( str.charAt( 0 ) ) ) {
		    System.out.println( "A" );
		}else {
			System.out.println("a");
		}
	}
}


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

int main(){
	char road[100]={0};
	int tmp;
	int flag;
	int i;
	gets(road);
	/*for(i=0;i<10;i++){
		printf("%d\n",road[i]);
	}
	if(road[0]=='0'){
	printf("yes\n");
	}*/
	while(road[0]!='#'){
		i=0;
		flag=-1;//a==-1 x==1 y==2 z==3 w==4 b==5
		while(road[i]!=0){
			if(flag==-1){
				if(road[i]=='0'){
					flag=1;
					//printf("%d\n",flag);
				}
				else{
					flag=2;
					//printf("%d\n",flag);
				}
			}
			else if(flag==1){
				if(road[i]=='0'){
					flag=-1;
					//printf("%d\n",flag);
					break;
				}
				else{
					flag=3;
					//printf("%d\n",flag);
				}
			}
			else if(flag==2){
				if(road[i]=='0'){
					flag=1;
					//printf("%d\n",flag);
				}
				else{
					//printf("%d\n",flag);
					break;
				}
			}
			else if(flag==3){
				if(road[i]=='0'){
					flag=4;
					//printf("%d\n",flag);
				}
				else{
					flag=5;
					//printf("%d\n",flag);
				}
			}
			else if(flag==4){
				if(road[i]=='0'){
					flag=5;
					//printf("%d\n",flag);
				}
				else{
					flag=2;
					//printf("%d\n",flag);
				}
			}
			else if(flag==5){
				if(road[i]=='0'){
					flag=2;
					//printf("%d\n",flag);
				}
				else{
					flag=1;
					//printf("%d\n",flag);
				}
			}
			i++;
		}
		if(flag==5){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
		memset(road,0,sizeof(road));
		gets(road);
	}
	return 0;
}

Measured memory_bytes: 916
n = int(input())
a_list = [int(a) for a in input().split(' ')]
a_list = sorted(a_list, reverse=True)
alice = list()
bob = list()
for i, a in enumerate(a_list):
    if i % 2 == 0:
        alice.append(a)
    else:
        bob.append(a)
print(sum(alice) - sum(bob))

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

int main() {
  int a,b;
  cin>>a>>b;
  long long takasa=0;
  long long takasa2=0;
  for(int i=1;i<=999;i++){
    takasa+=i;
    takasa2=takasa+i+1;
    if(takasa-a==takasa2-b){
      cout<<takasa-a<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3644
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)

Measured memory_bytes: 72792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

vector<int> simulate(vector<int>& as, int start)
{
	vector<int> result;
	set<int> s;

	for(int i = start; i < (int)as.size(); i++) {

		int a = as[i];

		if(s.count(a) == 0) {
			s.insert(a);
			result.push_back(a);
			continue;
		}

		int last = -1;

		while(last != a) {
			last = result.back();
			s.erase(last);
			result.pop_back();
		}
	}

	return result;
}

int main()
{
	int n;
	i64 k;
	vector<int> as;
	int max_a = 0;

	scanf("%d%lld", &n, &k);
	as.resize(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &as[i]);
		max_a = max(max_a, as[i]);
	}

	vector<int> last_pos(max_a + 1, -1);
	vector<int> head_item(n, -1);

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

		int a = as[i];
		int lp = last_pos[a];

		last_pos[a] = i;
		if(lp != -1) {
			head_item[i] = (lp + 1 < n) ? head_item[lp + 1] : -1;
		} else {
			head_item[i] = a;
		}
		//printf("%d: %d, %d, %d\n", i, a, lp, head_item[i]);
	}

	vector<int> head, loop;
	set<int> in_head;

	int c = 0;

	while(true) {

		if(in_head.count(c) > 0) {

			int last = -1;
			while(last != c) {
				last = head.back();
				loop.push_back(last);
				head.pop_back();
			}
			reverse(loop.begin(), loop.end());

			break;
		}

		head.push_back(c);
		in_head.insert(c);

		if(c == n) {
			c = 0;
			continue;
		}

		int h = head_item[c];
		c = (h == -1) ? 0 : (last_pos[h] + 1);
	}

	/*/for(auto h : head) {
		printf("head: %d\n", h);
	}
	for(auto h : loop) {
		printf("loop: %d\n", h);
	}*/

	int start = -1;
	k = k - 1;
	i64 ls = loop.size(), hs = head.size();

	if(k < hs) {
		start = head[k];
	} else {
		start = loop[(k - hs) % ls];
	}

	//printf("start: %d\n", start);

	vector<int> ans = simulate(as, start);

	for(int i = 0; i < (int)ans.size(); i++) {
		printf("%s%d", i > 0 ? " " : "", ans[i]);
	}
	if(ans.size() > 0) {
		printf("\n");
	}

	return 0;
}

/* waffle */


Measured memory_bytes: 24948
class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = n

    def root(self, x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            self.components -= 1
    
    def same(self, x,y):
        return (self.root(x) == self.root(y))
N, M = map(int,input().split())

UF = UnionFind(N)

for _ in range(M):
    X, Y, Z = map(int,input().split())
    X, Y = X-1, Y-1
    UF.unite(X,Y)

print(UF.components)

Measured memory_bytes: 13024
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= W)))

Measured memory_bytes: 14932
a = int(input())
b = int(input())
c = int(input())
x = int(input())
i1, i2, i3, p = 0, 0, 0, 0
while i1 <= a:
  while i2 <= b:
    while i3 <= c:
      m = 500 * i1 + 100 * i2 + 50 * i3
      if m == x:
        p += 1
      i3 += 1
    i3 = 0
    i2 += 1
  i2 = 0
  i1 += 1
print(p)

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(n, m);
  cout << (n - 1) * (m - 1) << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int v2[40010];
int t[110],v[110],ts[110];
int main()
{
	int n;
	ts[0]=0;
	cin>>n;
	rep(i,n){
		cin>>t[i];t[i]*=2;ts[i+1]=ts[i]+t[i];
	}
	rep(i,n){
		cin>>v[i];v[i]*=2;
	}
	rep(i,ts[n]+1){
		int ma=min(i,ts[n]-i);
		rep(j,n){
			if(i>=ts[j] && i<=ts[j+1]) ma=min(ma,v[j]);
			ma=min(ma,v[j]+abs(i-ts[j]));
			ma=min(ma,v[j]+abs(i-ts[j+1]));
		}
		v2[i]=ma;
		//cout<<i<<' '<<v2[i]<<endl;
	}
	double out=0.0;
	rep(i,ts[n]) out+=0.5*(v2[i]+v2[i+1]);
	printf("%.12f\n",0.25*out);
}


Measured memory_bytes: 384
s = input()[::-1]

count = [0]*2019
count[0] = 1  # そもそもあまりが0ってことは2019の倍数確定なので

num, d = 0, 1  # 初期化

for char in s:
    num += int(char)*d
    num %= 2019
    d *= 10
    d %= 2019
    count[num] += 1  # 2019で割ったあまりをキーとして値を追加していく

ans = 0
for c in count:
    ans += c*(c-1)//2
print(ans)


Measured memory_bytes: 9188
loop do
    n = gets.to_i
    break if n == 0
    steps = gets.split
    c = [0,0,0]
    count = 0
    steps.each do |s|
        case s
        when "lu"
            c[1] = 1
            if c[0] == 0 && c[2] == 1
                count += 1
                c[0] = 1
            end
        when "ru"
            c[2] = 1
            if c[0] == 0 && c[1] == 1
                count += 1
                c[0] = 1
            end
        when "ld"
            c[1] = 0
            if c[0] == 1 && c[2] == 0
                count += 1
                c[0] = 0
            end
        when "rd"
            c[2] = 0
            if c[0] == 1 && c[1] == 0
                count += 1
                c[0] = 0
            end
        end
    end
    puts count
end

Measured memory_bytes: 6108
S = input()
T = input()

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 回です
for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Measured memory_bytes: 9068
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    T = SS()
    P = SS()

    def contain(a, b):
        a = [ord(i) for i in a]
        b = [ord(i) for i in b]
        B = 10000007
        H = 100000007
        al = len(a)
        bl = len(b)
        if al>bl:
            return False

        t = pow(B, al, H)

        ah = 0
        bh = 0
        for i in range(al):
            ah = (ah * B + a[i]) % H
            bh = (bh * B + b[i]) % H

        for i in range(bl-al+1):
            if ah==bh:
                print(i)
            if i+al < bl:
                bh = (bh * B + b[i+al] - b[i] * t) % H

        return True

    contain(P, T)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 16392
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
  long h;
  long enemy;
  int count = 0;

  cin >> enemy;

  while (enemy > 0)
  {
    enemy = enemy / 2;
    count++;
  }
  long res = 0;
  for (int i = 0; i < count; i++)
  {
    res += pow(2, i);
  }
  cout << res << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55 - rank 3
// 69 12 19 - rank 3
// 70 12 34

ull gcd(ull a, ull b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int n;
    cin >> n;
    ull ans;
    cin >> ans;
    for (int i = 1; i < n; ++i) {
        ull a;
        cin >> a;
        a /= gcd(a, ans);
        ans *= a;
    }
    cout << ans << "\n";

}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,ans;
int main()
{
	cin>>n;
	while(n--)
	{
		int tmp;
		cin>>tmp;
		while(tmp%2==0)
		{
			ans++;
			tmp>>=1;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

I,O,T,J,L,S,Z = map(int,read().split())

del T,S,Z

x = O
# (II), (JIL), (JJ), (LL)
# (JIIJ), (JIIIL) などは使わないとしてよい
# (JIL) は高々1回としてよい

# (JIL) なし
y = ((J//2) + (I//2) + (L//2)) * 2
# (JIL) 1回
z = 3; J -= 1; I -= 1; L -= 1
if J < 0 or I < 0 or L < 0:
    z = -10 ** 18
z += ((J//2) + (I//2) + (L//2)) * 2
answer = x + max(y,z)
print(answer)

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

int main() {
  int value[10] = {};
  int A, B;
  cin >> A >> B;

  int ans = 0;

  for (int i = A; i <= B; i++) {
    int x = i;
    for (int i = 0; i < 5; i++) {
      value[4 - i] = x % 10;
      x /= 10;
    }
    if (value[0] == value[4] && value[1] == value[3]) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    int h[100010];
    h[0]=pow(10,9);
    for(int i=1;i<=N;i++)cin>>h[i];

    int dp[100010];

    //初期化
    dp[0]=pow(10,9);dp[1]=0;

    //漸化式
    for(int i=2;i<=N;i++)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    
    cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int i, j, row, column;
    char **ptr;
    int remain_row[100]={}, remain_column[100]={};

    scanf("%d %d\n", &row, &column);

    //各行の配列へのポインタ分のメモリ領域を確保
    ptr = (char**)calloc(row, sizeof(char*));
    if(ptr == NULL){
        fprintf(stderr, "calloc error.\n");
        exit(1);
    }
    //各行の要素分のメモリ領域を確保
    for(i = 0; i < row; i++){
        ptr[i] = (char*)calloc(column, sizeof(char));
        if(ptr[i] == NULL){
            fprintf(stderr, "calloc error.\n");
            exit(1);
        }
    }

    //マス目の配色の入力
    //'#'を含む行および列を記憶しておく
    for(i = 0; i < row; i++){
        for(j = 0; j < column; j++){
            scanf(" %c", &ptr[i][j]);
            if(ptr[i][j] == '#'){
                remain_row[i] = 1;
                remain_column[j] = 1;
            }
        }
    }

    //'#'を含む行および列のみ出力する
    for(i = 0; i < row; i++){
        if(remain_row[i] == 1){
            for(j = 0; j < column; j++){
                if(remain_column[j] == 1){
                    printf("%c", ptr[i][j]);
                }
            }
            printf("\n");
        }
    }
    
    //メモリ領域の解放，各行の要素分の領域を解放し，
    //各行の配列へのポインタの領域を解放
    //（メモリ領域の確保と逆順）
    for(i = 0; i < row; i++){
        free(ptr[i]);
    }
    free(ptr);

    return 0;
}


Measured memory_bytes: 1672
using System;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long ans=0;
		if(s[0]*2<=s[1]){
			ans+=s[0];
			s[1]-=s[0]*2;
			s[1]/=4;
			ans+=s[1];
		}
		else{ans=s[1]/2;}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define PB push_back
#define LL long long
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int a[200005];
int l[200005];
int r[200005];
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;	
	vector<pair<int , int> > vPos;
	for(int i = 0; i < n; i++)
	{
		l[i] = r[i] = i;
		cin >> a[i];
		vPos.PB({a[i] , i});
	}
	sort(vPos.begin() , vPos.end());
	//reverse(vPos.begin() , vPos.end()); 
	LL ans = 0;
	set<int> s;
	s.insert(n - 1);
	s.insert(-1);
	for(auto x : vPos)
	{
		int pos = x.second;
		int val = x.first;	
		int nd = *s.lower_bound(pos);
		int prev = *(--s.lower_bound(pos));
		s.insert(pos - 1);
		s.insert(pos);
		ans += val * (LL)(nd - pos + 1) * (LL)(pos - prev);
	}
	cout << ans;
}

Measured memory_bytes: 13552
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	ans = min(N % K, (K - N) % K)
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)
#define N 100003

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int n, m, res;
vi a[N];
int d[N];
bool visit[N];

void dfs(int u) {
    visit[u] = 1;
    for (int &v : a[u]) {
        if (!visit[v]) dfs(v);
        d[u] = max(d[u], d[v] + 1);
    }
}

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    while (m--) {
        int u, v;
        cin >> u >> v;
        a[u].pb(v);
    }
    fort(i, 1, n) if (!visit[i]) dfs(i);
    fort(i, 1, n) res = max(res, d[i]);
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 7552
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
ans = 0
nom = defaultdict(int)
for i in range(n):
    nom[a[i]]+=1
ans = 0
a = set(a)
a = list(a)
m = len(a)
for i in range(m):
    b = nom[a[i]] + nom[a[i]-1]+ nom[a[i]+1]
    ans = max(ans,b)
print(ans)

Measured memory_bytes: 18380
using System;
using AtCorder;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var input1 = Console.ReadLine();
            var input2 = Console.ReadLine();

            if (input1 == "1")
            {
                if (input2 == "2")
                {
                    Console.WriteLine("3");
                }
                else
                {
                    Console.WriteLine("2");
                }
            }
            else if (input1 == "2")
            {
                if (input2 == "1")
                {
                    Console.WriteLine("3");
                }
                else
                {
                    Console.WriteLine("1");
                }
            }
            else
            {
                if (input2 == "1")
                {
                    Console.WriteLine("2");
                }
                else
                {
                    Console.WriteLine("1");
                }
            }
        }
    }
}

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

#include "bits/stdc++.h"

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = 1e18;
const int mod = 1e9+7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

int dp[100005][105][2];

class SDigitSum {
public:
    void solve(std::istream& cin, std::ostream& cout){
        string s; cin >> s;
        int n = s.length();
        int d; cin >> d;

        memset(dp,0,sizeof dp);
        dp[0][0][0] = 1;
        for(int i=0;i<n;i++){
            for(int j=0;j<d;j++){
                for(int k=0;k<2;k++){
                    int r=9;
                    if(k==0) r=s[i]-'0';
                    for(int cd=0;cd<=r;cd++){
                        int ck=k;
                        if(cd < s[i]-'0') ck=1;
                        dp[i+1][(j+cd)%d][ck] = add(dp[i+1][(j+cd)%d][ck],dp[i][j][k]);
                    }
                }
            }
        }

        //cout << dp[n][0][0] << " " << dp[n][0][1] << endl;
        int ans = add(dp[n][0][0],dp[n][0][1]);
        ans = sub(ans,1LL);
        cout << ans << endl;
    }
};


int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    SDigitSum solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 164352
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  vector<int> dp(N + 1, 1e7); dp[0] = 0;
  for (int i = 0; i < N; ++i)
    {for (auto j : {6, 9})
      {for (auto k = 1; i + k <= N; k *= j) dp[i + k] = min(dp[i + k], dp[i] + 1);}}
  cout << dp[N] << endl;}

Measured memory_bytes: 640
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

r1,c1,r2,c2=map(int,input().split())

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6*2+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def g(r,c):
    tmp=cmb(r+1+c+1,r+1)-1
    return tmp%mod

ans=0
ans+=g(r2,c2)
ans-=g(r2,c1-1)
ans-=g(r1-1,c2)
ans+=g(r1-1,c1-1)
ans%=mod
print(ans)

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

int main(void) {
  int N;
  scanf("%d", &N);
  int A[N];
  map<int, int> given;
  for (int i = 0; i < N; i++) {
    scanf("%d", A+i);
    given[A[i]]++;
  }

  long long all_patterns = 0;
  for (const pair<int, int> &p : given) all_patterns += (long long)(p.second - 1) * p.second / 2;

  for (int i = 0; i < N; i++) {
    cout << all_patterns - given[A[i]] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 8320
str = input()
cntl = []
cnt = 1
for i in range(len(str)-1):
    if str[i] == str[i+1]:
        cnt += 1
    else:
        cntl.append(cnt)
        cnt = 1
else:
    cntl.append(cnt)
s = 0
for i in range(len(cntl)):
    s += cntl[i]*(cntl[i]+1)//2
r = 0
if str[0] == "<":
    for i in range(len(cntl)//2):
        r += min(cntl[2*i],cntl[2*i+1])
if str[0] == ">":
    for i in range(1,(len(cntl)+1)//2):
        r += min(cntl[2*i-1],cntl[2*i])
print(s-r)


Measured memory_bytes: 6300
import itertools
N,K=[int(i) for i in input().split()]
seq=[i for i in range(K)]
lst=[]
'''for i in itertools.product(seq, repeat=N):
    lst.append(i)

ans=[]
for tup in lst:
    f=0
    for ind,color in enumerate(tup):
        if(ind==len(tup)-1):
            break
        if(tup[ind+1]==color):
            f=1
            break
    if(f==0):
        ans.append(tup)
print(len(ans))'''

print(K*(K-1)**(N-1))

Measured memory_bytes: 3060
#include<stdio.h>

#define MAX 100000

int parent(int i);
int left(int i);
int right(int i);


int main(void)
{
  int H;
  int A[MAX+1];
  int i;
    
  scanf("%d",&H);

  for(i=1;i<=H;i++)
    {
      scanf("%d",&A[i]);
    }

  for(i=1;i<=H;i++)
    {
      printf("node %d: key = %d, ",i,A[i]);

      if(parent(i)>=1)
	{
	  printf("parent key = %d, ",A[parent(i)]);
	}
      
      if(left(i)<=H)
	{
	  printf("left key = %d, ",A[left(i)]);
	}

      if(right(i)<=H)
	{
	  printf("right key = %d, ",A[right(i)]);
	}
      
      putchar('\n');
      
    }

  return 0;
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return 2*i+1;
}



Measured memory_bytes: 2036
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m;
ll a , b , c; 
int A[MAXN];

void solve() {
	cin >> n;
	a = 1;
	rep( i , 1 , n ) {
		scanf("%lld",&b);
		if( b == 0 ) c = -1;
		else if( c != -1 && ( ( ( ll )1e18 ) / b < a || a * b > 1e18 ) ) c = 1;
		else if( c != -1 ) a *= b;
	}
	if( c == -1 ) puts("0");
	else if( c ) puts("-1");
	else cout << a << endl;
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}



Measured memory_bytes: 3692
A, B, C = input().split()
#ABC
#ABC
#BAC
#BCA 
#CAB
#CBA 
print(max(int(A+B)+int(C), int(A+C)+int(B), int(B+A)+int(C), int(B+C)+int(A), int(C+A)+int(B),int(C+B)+int(A)))

Measured memory_bytes: 3188
from collections import Counter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

# Union-Findデータ構造
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        if x == y: return
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
        else:
            self.pars[y] = x
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)


N, M = map(int, input().split())
UF = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    A, B = A-1, B-1
    UF.merge(A, B)

UF.updatePars()
#print('# UF.pars:', UF.pars, file=sys.stderr)

cnt = Counter(UF.pars)
#print('# cnt:', cnt, file=sys.stderr)

ans = max(cnt.values())
print(ans)


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

int lenearSearch(int S[],int n,int key){
  int i=0;
  S[n] = key;
  while(S[i]!=key)i++;
  return n != i;
}
int main(){
  int i,n,S[10001],q,key,sum=0;
  cin>>n;
  for(i=0;i<n;i++)cin>>S[i];
  cin>>q;
  for(i=0;i<q;i++){
    cin>>key;
    if(lenearSearch(S,n,key))sum++;
  }
  cout<<sum<<endl;
}



Measured memory_bytes: 3132
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return ;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),m=read(),ans=0,sum=0;
	for(int i=0;i<=n;i++)
	{
		sum=ad(sum+n-i),sum=dec(sum-i);
		if(i+1>=m)ans=ad(ans+sum),ans=ad(ans+1);
	}pr2(ans);
	return 0;
}

Measured memory_bytes: 1492
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e3 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	LL k;
	cin >> n >> k;
	LL ans = 0;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++)
	{
		LL tot = 0;
		LL rest = 0;
		for (int j = 1; j <= n; j++)
		{
			if (a[i] > a[j]) tot++;
		}
		for (int j = i + 1; j <= n; j++)
		{
			if (a[i] > a[j]) rest++;
		}
		ans += k * rest % INF + k * (k - 1) / 2 % INF * tot % INF;
	}
	cout << ans % INF << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int x, y;
    
    scanf("%d%d", &x, &y);
    
    int a, b;
    
    for (int i=0; i<=x; i++) {
            if (i*2+(x-i)*4==y) {
                printf("Yes");
                return 0;
            }
    }
    
    printf("No");
    
    return 0;
}



Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
using namespace std;
int n;
main()
{
	cin>>n;
	for(;n--;)
	{
		string s,t;
		cin>>t>>s;
		for(int i=t.size();i--;)
		{
			if(t[i]=='J')
			{
				s=s[s.size()-1]+s.substr(0,s.size()-1);
			}
			else if(t[i]=='C')
			{
				s=s.substr(1,s.size()-1)+s[0];
			}
			else if(t[i]=='E')
			{
				if(s.size()%2)
					s=s.substr(s.size()/2+1,s.size()/2)+s[s.size()/2]+s.substr(0,s.size()/2);
				else s=s.substr(s.size()/2,s.size()/2)+s.substr(0,s.size()/2);
			}
			else if(t[i]=='A')
			{
				reverse(s.begin(),s.end());
			}
			else if(t[i]=='P')
			{
				for(int j=0;j<s.size();j++)
					if(s[j]>='0'&&s[j]<='9')
					{
						s[j]--;
						if(s[j]<'0')s[j]='9';
					}
			}
			else if(t[i]=='M')
			{
				for(int j=0;j<s.size();j++)
					if(s[j]>='0'&&s[j]<='9')
					{
						s[j]++;
						if(s[j]>'9')s[j]='0';
					}
			}
		}
		cout<<s<<endl;
	}
}



Measured memory_bytes: 3000
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	int sum = 0;
	rep(i, s.size()) sum = (sum + (int)(s[i] - '0')) % 9;
	if(!sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3776
#include <stdio.h>
const int N=1e6+10;
int min(int a,int b){return a>b?b:a;}
int main(){
    int n,a[N],ans=1e9,now,temp,last;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<=a[0];i++)for(int j=0;j<=a[n-1];j++){
        temp=a[0]-i;
        last=i;
        for(int k=1;k<n-1;k++){
            now=a[k];
            temp+=last*2;
            now-=last;
            if(now<0)now=0;
            last=now;
        }
        now=j;
        temp+=last*2;
        now-=last;
        if(now<0)now=0;
        temp+=now+a[n-1]-j;
        ans=min(ans,temp);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 2772
#include "bits/stdc++.h"

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

using namespace std;

int binarySearch(int num, vector<int> L) {
	int left = -1;
	int right = L.size();
	int mid = (right + left) / 2;
	while (right - left > 1) {
		mid = (right + left) / 2;
		if (L[mid] >= num)right = mid;
		else left = mid;
	}
	return left;

}

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	rep(i, N)cin >> L[i];

	sort(L.begin(), L.end());
	long long ans = 0;
	rep(i, N) {
		rep2(j, i + 1, N) {
			int num = L[i] + L[j];
			ans += (long long)binarySearch(num, L) - j;
			//cout << num << " " << binarySearch(num, L) << endl;
		}
	}
	cout << ans;
}



Measured memory_bytes: 256
N,A,B = map(int, input().split())
X = list(map(int, input().split()))

ans = 0
src = X[0]
for i in range(1,N):
    dst = X[i]
    walk = A * (dst - src)
    warp = B
    ans += min(warp, walk)
    src = dst

print(ans)
        


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>
#include <map>
#include <time.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  cout << (n - 2) * 180 << endl;
}


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

int main()
{
	int n, q;
	cin >> n >> q;
	queue<pair<string, int>> que;
	for (int i = 0; i < n; i++){
		string s; int a;
		cin >> s >> a;
		que.push({s, a});
	}

	int res = 0;

	while (!que.empty()){
		pair<string, int> p;
		p = que.front();
		que.pop();
		if (p.second <= q){
			res += min(p.second, q);
			cout << p.first << " " << res << endl;
		} else {
			p.second -= q;
			res += q;
			que.push(p);
		}
	}

}



Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
    FASTIO
    /*
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust\n";
    }
    else cout << "win\n";
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  string s;
  cin >> s;
  ll u=0, d=0, l=0, r=0;
  bool ok;
  forll(i, 0, s.size()){
	if (s[i] == 'N')
	  u += 1;
	else if (s[i] == 'W')
	  l += 1;
	else if (s[i] == 'S')
	  d += 1;
	else
	  r += 1;
  }
  if ((u > 0 && d > 0) || (u == d))
	if ((l > 0 && r > 0) || (l == r))
	  ok = true;
	else
	  ok = false;
  else
	ok = false;
  if (ok == true)
	cout << "Yes" << endl;
  else
	cout << "No" << endl;
}


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

const string table[] = {"0", "1abcde", "2fghij", "3klmno", "4pqrst", "5uvwxy", "6z.?! "};

int main()
{
  string s;
  while (cin >> s) {
    bool valid = true;
    if (s.size() & 1)
      valid = false;

    string ans = "";
    for (unsigned int i = 0; i < s.size() && valid; i += 2) {
      int row = s[i] - '0', col = s[i+1] - '0';
      if (0 < row && row <= 6 && 0 < col && col <= 5)
	ans += table[row][col];
      else
	valid = false;
    }

    if (valid)
      cout << ans << endl;
    else
      cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 0