akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 999999999
#define MAX_V 100010
#define MAX_E 2019

    /*Solve*/

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
    
int main(){
    ll N,M;
    cin >> N >> M;
    vector<pair<ll,ll>> V;
    ll a,b;
    set<ll> s;
    
    rep(i,M){
        cin >> a >> b;
        V.push_back({a,b});
        s.insert(a);
        s.insert(b);
    }
    UnionFind Tree(100010);
    
    ll c=s.size()*(s.size()-1)/2;
    ll ans[100010];
    bool bl[100010];
    
    repr(i,M-1){
        int x[100010];
        int y[100010];
        x[i-1]=V[i].first;
        y[i-1]=V[i].second;
        

        if(i==M-1){
            ans[M-1]=c;
            bl[i]=1;
            continue;
        }else if(Tree.issame(x[i],y[i])){
            bl[i]=0;
        }else bl[i]=1;
        
        
        if(bl[i]){
            ans[i]=ans[i+1]-Tree.size(x[i])*Tree.size(y[i]);
        }else
            ans[i]=ans[i+1];
        
        Tree.merge(x[i], y[i]);
    }
    rep(i,M){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 9968
// Date: 2020-06-21

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int a[N], n, k;
int main() {
	cin >> n >> k;
	rep(i, 1, n) cin >> a[i];
	sort(a+1, a+1+n);
	int ans = 0;
	rep(i, 1, k) ans += a[i];
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3636
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
int K;
int a[3010];
ll dp[110][114514]={0};
int main(){
	cin>>N>>K;
	rep(i,N)cin>>a[i];
	rep(i,N+1)dp[i][0]=(ll)1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=K;j++){
			dp[i][j]=dp[i-1][j];
			if(j>0)dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
			if(j-1-a[i-1]>=0)dp[i][j]=(dp[i][j]-dp[i-1][j-1-a[i-1]]+MOD)%MOD;
		}
	}
	cout<<dp[N][K]<<endl;
}

Measured memory_bytes: 91392
// Problem : O - Matching
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_o
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
#define range(i, s, t)  for (int (i) = s; (i) <= (int)t; (i)++)
//#define int long long
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int MOD = 1e9 + 7;
long long qread() {
	char c;
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
const int N = 26;
int d[N][N];
int n;
int dp[lsh(N)];
int main() {
	n = qread();
	rep(i, n) rep(j, n) d[i][j] = qread();
	memset(dp, 0, sizeof(dp)); dp[0] = 1;
	rep(s, lsh(n) - 1) {
		int m = __builtin_popcount(s);
		rep(i, n) 
			if (d[m][i] && !(s & lsh(i))) 
				dp[s | lsh(i)] = (dp[s] + dp[s | lsh(i)]) % MOD;
	}
	cout << dp[lsh(n) - 1] << endl;
	return 0;
}


Measured memory_bytes: 265748
#include "iostream"
#include "string"
#include "vector"

using namespace std;

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Max = INF, Min = -1;
ll a = 0, b = 0, c = 0, n = 0, sum = 0;
ll A[500000] = {}, B[500000] = {}, ruiseki[500000] = {}, dp[100][10] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
str S, T;
bool check = false, check2 = false;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	sum = 1;
	//Code Line
	cin >> a >> b;
	
	while (1) {
		if (sum >= b)break;
		sum--;
		sum += a;
		n++;
	}
	cout << n << endl;

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll a,v,b,w,t;cin>>a>>v>>b>>w>>t;
    if(a>b) swap(a,b);
    a+=v*t;
    b+=w*t;
    if(a>=b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

// long long pow_mod(long long a, long long b){
// 	if(a == 0)
// 		return 0ll;
// 	if(b == 0)
// 		return 1ll;
// 	if(b == 1)
// 		return a%MOD;
// 	long long x = pow_mod(a,b/2);
// 	return ((b%2 == 1) ? (((x*x)%MOD)*a)%MOD : (x*x)%MOD);
// }

// long long pow_int(long long a, long long b){
// 	if(a==0)
// 		return a;
// 	if(b==0)
// 		return 1;
// 	if(b==1)
// 		return a;
// 	long long x = pow_int(a,b/2);
// 	return ((b%2 == 1) ? x*x*a : x*x);
// }

// int pow_int(int a, int b){
// 	if(a==0)
// 		return a;
// 	if(b==0)
// 		return 1;
// 	if(b==1)
// 		return a;
// 	int x = pow_int(a,b/2);
// 	return ((b%2 == 1) ? x*x*a : x*x);
// }


// void print_vec(vector<int>& a){
// 	for(int i=0;i<a.size();i++)
// 		cout << a[i] << (i<n-1 ? " ":"\n");
// }

// void print_vec(vector<long long>& a){
// 	for(int i=0;i<a.size();i++)
// 		cout << a[i] << (i<n-1 ? " ":"\n");
// }

// void solve_kick_start(int test_case){

// }

void solve(){
	int n;
	cin>>n;
	string s,ans;
	cin>>s;
	ans = s;
	for(int i=0;i<s.size();i++){
		int x = (int(s[i]-'A') + n)%26;
		ans[i] = char(int('A'+x));
	}
	cout << ans << "\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);

	// // CodeChef Template
	// int t;       
	// cin >> t;
	// while(t--){
	// 	solve();
	// }

	// // Single test case input
	solve();

	// // Kick Start Template	
	// int test_cases;
	// cin >> test_cases;
	// for(int i=1;i<=test_cases;i++){
	// 	solve_kick_start(i);
	// }

	return 0;
}

Measured memory_bytes: 256
require 'prime'

def gcd(m, n)
    if m < n
        gcd(n, m)
    elsif n == 0
        m 
    else
        gcd(n, m % n)
    end 
end

n = gets.to_i
a, b, c = gets.split.map &:to_i
g = (n == 2 ? gcd(a, b) : gcd(a, gcd(b, c)))

hash = Hash.new(0)
Prime.each(Math.sqrt(g).to_i){|p|
    while g % p == 0
        hash[p] += 1
        g /= p
    end
}
hash[g] += 1 if g > 1
puts hash
        .map{|p, k| (0..k).map{|i| p**i}}
        .inject(&:product)
        .map{|a| a.flatten.inject(:*)}
        .sort

Measured memory_bytes: 6260
<>;@a=glob<>;$\=1e9;while($\-$l>1){@b=$N=$c=0;$b[$s=@a]=1;$c+=$N+=2*$_>$l+$\?-$b[++$s]:$b[$s--],$b[$s]++for@a;($c>@a*(@a+1)/4?$\:$l)=$l+$\>>1}print

Measured memory_bytes: 27784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n + 1];
			int[] b = new int[n];
			long result = 0;

			for (int i = 0; i <= n; i++) {
				a[i] = sc.nextInt();
			}
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}

			int before = 0;
			for (int i = 0; i < n; i++) {
				// bがのこり倒せる数
				int tmp = b[i] - (a[i] - before);
				if (tmp < 0) {
					// 全部
					result += b[i];
					before = 0;
				} else {
					// a[i]を全滅
					result += (a[i] - before);
					// 倒したかず
					int tmp2 = a[i + 1] - tmp;
					if  (tmp2 < 0) {
						result += a[i + 1];
						before = a[i + 1];
					} else {
						result += tmp;
						before = tmp;
					}
				}
			}

			System.out.println(result);
		}
	}
}


Measured memory_bytes: 66736
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 21;

int n;
int a[N][N];
int dp[1 << N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  dp[(1 << n) - 1] = 1;
  for (int i = (1 << n) - 2; i >= 0; i--) {
    int p = __builtin_popcount(i);
    for (int j = 0; j < N; j++) {
      if (i & (1 << j) || !a[p][j]) continue;
      dp[i] = (dp[i] + dp[i ^ (1 << j)]) % MOD;
    }
  }
  cout << dp[0] << nl;
  return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstdint>

int main()
{
	std::uint32_t n;
	std::cin >> n;
	for (std::uint32_t i = 0; i < n; ++i) {
		typedef std::vector<char> BigNumArray;
		std::string str;

		std::cin >> str;
		BigNumArray num1(str.rbegin(), str.rend());

		std::cin >> str;
		BigNumArray num2(str.rbegin(), str.rend());

		if (num1.size() < num2.size()) {
			num1.resize(num2.size(), '0');
		}
		else {
			num2.resize(num1.size(), '0');
		}

		std::string result;
		std::uint16_t carry = 0;
		for (std::size_t i = 0; i < num1.size(); ++i) {
			std::uint16_t num = num1[i] - '0' + num2[i] - '0' + carry;
			carry = num / 10;
			result.push_back(num % 10 + '0');
		}
		if (carry == 1) {
			result.push_back('1');
		}

		if (result.size() > 80) {
			std::cout << "overflow" << std::endl;
		}
		else {
			std::copy(result.rbegin(), result.rend(),
					std::ostream_iterator<char>(std::cout, ""));
			std::cout << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
n=int(input())
a=[int(i) for i in input().split()]
a=[a[i]-(i+1) for i in range(n)]
a.sort()
if n%2==0:
    print(sum(a[n//2:])-sum(a[0:n//2]))
else:
    print(sum(a[n//2+1:])-sum(a[0:n//2]))

Measured memory_bytes: 25200
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
 	int n, p;
 	sfd(n);
 	sfd(p);
 	int num, ans = 0, cnt = 1;
	for( int i=0; i<n; i++ ) {
		sfd(num);
		ans += num;
		if( ans<=p ) {
			cnt++;
		}
	}
	pfd(cnt);

	return 0;
}

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

j=0
while True:
  i=0
  for a in A:
    if a%2 == 0:
      A[i]=a//2
    else:
      break
    i+=1
  if i != N:
    break
  j +=1
  
print(j)

Measured memory_bytes: 9152
n, k = map(int, input().split())
s = input()

first = s[0]
end = s[-1]
len_list = []

count = 0
pre = first
for i in range(n):
    if s[i] == pre:
        count += 1
    else:
        len_list.append(count)
        pre = s[i]
        count = 1
len_list.append(count)
sum_list = [0]
sum_tmp = 0
for i in len_list:
    sum_tmp += i
    sum_list.append(sum_tmp)

size = len(len_list)

if size < 2*k + 1:
    print(n)
else:
    ans = 0
    index = 0
    if first == '0':
        index = 1
        ans = sum_list[2*k] - sum_list[0]
    if end == '0':
        ans = max((sum_list[size] - sum_list[size-2*k]), ans)

    while index + 2 * k < size:
        ans = max(ans, (sum_list[index+2*k+1] - sum_list[index]))
        index += 2

    print(ans)

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

int main(){
  string num;
  cin >> num;
  string a = num.substr(num.size()-1);
  if (a == "3"){
    cout << "bon";
  } else if (a == "0" || a == "1" || a == "6" || a == "8"){
    cout << "pon";
  } else {
    cout << "hon";
  }
  cout << endl;
}

Measured memory_bytes: 3628
private fun readInts() = readLine()!!.split(" ").map(String::toInt)

fun main(args: Array<out String>) {
    val (N) = readInts()
    val abc = (0 until N).map { readInts() }

    val happiness = Array(N) { Array(3) { 0 } }
    (0 until 3).forEach { happiness[0][it] = abc[0][it] }

    (1 until N).map { today ->
        (0 until 3).forEach { todayActivity ->
            val yesterdayActivities = (0 until 3) - todayActivity

            happiness[today][todayActivity] = yesterdayActivities
                .map { yesterdayActivity -> happiness[today - 1][yesterdayActivity] }
                .max()!!
                .plus(abc[today][todayActivity])
        }
    }

    println(happiness[N - 1].max())
}

Measured memory_bytes: 98712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x; cin >> x;
  int kosuu = x/100;
  int hasuu = x % 100;
 // cout << kosuu << " " << hasuu << endl;
  if(hasuu >  5 * kosuu)
    cout << 0;
  else
    cout << 1;
}
        
  

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,ans=0;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    if(n%2){
        vector<ll> sum(2);
        for(int i = 0;i < n;i ++){
            if(i < n/2) sum[0] -= 2*a[i];
            else if(i > n/2+1) sum[0] += 2*a[i];
            else sum[0] += a[i];
        }
        for(int i = 0;i < n;i ++){
            if(i < n/2-1) sum[1] -= 2*a[i];
            else if(i > n/2) sum[1] += 2*a[i];
            else sum[1] -= a[i];
        }
        ans = max(sum[0],sum[1]);
    }else{
        for(int i = 0;i < n;i ++){
            if(i < n/2-1) ans -= 2*a[i];
            else if(i > n/2) ans += 2*a[i];
            else if(i == n/2-1)ans -= a[i];
            else ans += a[i];    
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

int main(){
    int n, x, t;
    cin >> n >> x >> t;
    int ans = (n / x) * t;
    if (n % x != 0) ans += t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
    int n,m;
    cin>>n>>m;
    vector< vector<int> > v(n+1);
    vector<int> h(n+1);
    int ans =0;
    for(int i=1; i<=n; i++){
        cin>>h[i];
    }
    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        v.at(a).push_back(b);
        v.at(b).push_back(a);
    }
    for(int i=1; i<=n; i++){
        vector<int> tmp = v.at(i);
        bool ok = true;
        int hig = h.at(i);
        for(int j=0; j<tmp.size(); j++){
            if(h.at(tmp.at(j) )>=hig ) ok = false;
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8800
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int to = 0;
  int max = 0;
  for (int i = 0; i < N; i ++) {
    int k;
    cin >> k;
    to += k;
    if (max < k) max = k;
  }
  to -= max / 2;
  cout << to << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int A[1000];
int p;
void push(int);
int pop();

int main() {
  p=0;
  char A[10];
  while(scanf("%s",A)==1) {
    if(A[0]=='+' || A[0]=='-' || A[0]=='*'){
      int x=pop();
      int y=pop();
      if(A[0]=='+') push(x+y);
      else if(A[0]=='-') push(y-x);
      else push(x*y);
    }
    else {
      int x=0,t=0;
      while(A[t]>='0' && A[t]<='9') {
	x*=10;
	x+=A[t]-'0';
	t++;
      }
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}



void push(int x) {
  A[p]=x;
  p++;
}



int pop() {
  p--;
  return A[p];
}



Measured memory_bytes: 2108
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	static int[][] matrix;
	static boolean[] visited;
	static int[] distance;
	static LinkedList<NumDis> queue;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		matrix = new int[n][n];
		for (int i = 0; i < n; i++) {
			int index = sc.nextInt() - 1;
			int num = sc.nextInt();
			for (int j = 0; j < num; j++) {
				matrix[index][sc.nextInt() - 1] = 1;				
			}
		}
		
		visited = new boolean[n];
		distance = new int[n];
		for(int i = 0; i < n; i++) {
			distance[i] = -1;
		}
				
		queue = new LinkedList<NumDis>();
		queue.offer(new NumDis(0, 0));
		
		while(queue.size() > 0) {
			bfs();
		}
		
		for(int i = 0; i < n; i++) {
			System.out.printf("%1$d %2$d", i+1, distance[i]);
			System.out.println();
		}
	}
	
	public static void bfs() {
		NumDis current = queue.poll();
		int i = current.num;
		int d = current.dis;
		
		if (visited[i]) {
			return;
		}
		
		// to queue
		for(int j = 0; j < matrix[i].length; j++) {
			if (matrix[i][j] == 1) {
				queue.offer(new NumDis(j, d + 1));		
			}
		}
		
		// record
		distance[i] = d;
		visited[i] = true;
	}
	
	
}

class NumDis {
	int num;
	int dis;
	public NumDis(int num, int dis) {
		this.num = num;
		this.dis = dis;
	}
}

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

#define MAX 1000

int main(){

  int i;
  int j;
  int A[MAX];
  int v;
  int length;
 
  scanf("%d",&length);

  if(length > 100){
    printf("too large\n");
    exit(1);
  }

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

    for(j = 0;j < length-1;j++){
      printf("%d ",A[j]);
    }
    printf("%d\n",A[length-1]);

    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;

  }

    for(j = 0;j < length-1;j++){
      printf("%d ",A[j]);
    }
    printf("%d\n",A[length-1]);

  return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(10);
   int sum=0;
  for(int i=0;i<n;i++){
    cin >> p.at(i);
    sum=sum+p.at(i);
  }
  sort(p.begin(),p.end(),greater<>());
  sum=sum-p.at(0)/2;
  cout << sum << endl;

}


Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N=100005;
int a[N],n; 
int gcd (int x,int y)	{return x==0?y:gcd(y%x,x);}
int cnt[2];
bool solve ()
{
	cnt[0]=cnt[1]=0;
	for (int u=1;u<=n;u++) cnt[a[u]&1]++;
	if (cnt[0]&1) return true;
	if (cnt[1]>1) return false;
	int d=0;
	for (int u=1;u<=n;u++)
	{
		if (a[u]&1) 
		{
			if (a[u]==1) return false;
			a[u]--;
		}
		d=gcd(d,a[u]);
	}
	for (int u=1;u<=n;u++) a[u]/=d;
	return solve()^1;
}
int main()
{
	scanf("%d",&n);
	for (int u=1;u<=n;u++) scanf("%d",&a[u]);
	if (solve()) printf("First\n");
	else printf("Second\n");
	return 0;
}


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

ll x, k, d;

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

    cin >> x >> k >> d;

    if (x == 0) {
        if (k & 1) cout << d << "\n";
            else cout << 0 << "\n";
        return 0;
    }

    x = abs(x); 
    ll o = min(k, x / d);
    k -= o;
    x -= d * o;

    if (k == 0)
        return void(cout << x << "\n"), 0;

    ll v1 = abs(x - d);
    ll v2 = x;

    if (k & 1) cout << v1 << "\n";
        else cout << v2 << "\n";
}


Measured memory_bytes: 3632
import java.util.*;

class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int T = sc.nextInt();

        int times = T / A;

        System.out.println(times*B);
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>

int main(){

    long N;
    std::cin >> N;
    long a[200000]={};
    long sum=0;
    for(long i=0; i<N; i++){
        std::cin >> a[i];
        sum=sum^a[i];
    }

    for(long i=0; i<N; i++){
        long result=(sum^a[i]);
        std::cout << result;
        if(i!=N-1){
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
typedef long long ll;
#define vll vector<long long> 
#define pll pair<ll,ll>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define all(v)  (v).begin(),(v).end()
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main(){
	ll n,k,sum=0;cin>>n>>k;
	ll a[n];f(i,0,n) cin>>a[i];
	sort(a,a+n);
	ll i=0;
	while(i<k and i<n){
		sum+=a[i];
		i++;
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 3640
n, a, b = map(int, input().split())
v = list(map(int, input().split()))
dp = [[0] * (n + 1) for _ in range(n + 1)]
d = [[0] * (n + 1) for _ in range(n + 1)]
d[0][0] = 1
for i in range(n):
    for j in range(i + 1):
        if dp[i + 1][j] < dp[i][j]:
            d[i + 1][j] = d[i][j]
            dp[i + 1][j] = dp[i][j]
        elif dp[i + 1][j] == dp[i][j]:
            d[i + 1][j] += d[i][j]
        if dp[i + 1][j + 1] < dp[i][j] + v[i]:
            d[i + 1][j + 1] = d[i][j]
            dp[i + 1][j + 1] = dp[i][j] + v[i]
        elif dp[i + 1][j + 1] == dp[i][j] + v[i]:
            d[i + 1][j + 1] += d[i][j]
ans = 0
idx = float('inf')
cnt = 0
for i in range(a, b + 1):
    if dp[n][i] * idx > ans * i:
        ans = dp[n][i]
        idx = i
        cnt = d[n][i]
    elif dp[n][i] * idx == ans * i:
        cnt += d[n][i]
print(ans / idx)
print(cnt)


Measured memory_bytes: 39024
#include "bits/stdc++.h"
using namespace std;

int main() {
    string A, B;
    cin >> A >> B;
    if(A.size() > B.size()){
        puts("GREATER");
        return 0;
    }else if(A.size() < B.size()){
        puts("LESS");
        return 0;
    }else if(A > B){
        puts("GREATER");
        return 0;
    }else if(A < B){
        puts("LESS");
        return 0;
    }else{
        puts("EQUAL");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '1') {
			s[i] = '9';
		}
		else if (s[i] == '9') {
			s[i] = '1';
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, k) {
        vector<int> imos(n);
        rep(i, n) {
            imos[max(0, i - a[i])]++;
            if (i + a[i] + 1 < n) imos[i + a[i] + 1]--;
        }
        int mn = imos[0];
        rep(i, n - 1) {
            imos[i + 1] += imos[i];
            mn = min(mn, imos[i + 1]);
        }
        swap(a, imos);
        if (mn == n) break;
    }
    rep(i, n) {
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5184
#include <stdio.h>

int main()
{
	int n, d, x, a;
	
	scanf("%d %d %d", &n, &d, &x);
	while(n--){
		scanf("%d", &a);
		x += (d-1)/a+1;
	}
	
	printf("%d", x);
	
	return 0;
}

Measured memory_bytes: 128
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
#define pb push_back
// to floor a/b you can do a/b and to ceiling a/b you can do (a+b-1)/b
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=(r%mod * x%mod)%mod;
        x=(x%mod * x%mod)%mod;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}
//Start of Matrix Exponentiation Code
void mat_mul(ll F[2][2],ll M[2][2]) {
   ll a = ((F[0][0]%mod * M[0][0]%mod)%mod + (F[0][1]%mod * M[1][0]%mod)%mod)%mod;
   ll b = ((F[0][0]%mod * M[0][1]%mod)%mod + (F[0][1]%mod * M[1][1]%mod)%mod)%mod;
   ll c = ((F[1][0]%mod * M[0][0]%mod)%mod + (F[1][1]%mod * M[1][0]%mod)%mod)%mod;
   ll d = ((F[1][0]%mod * M[0][1]%mod)%mod + (F[1][1]%mod * M[1][1]%mod)%mod)%mod;
   F[0][0] = a;
   F[0][1] = b;
   F[1][0] = c;
   F[1][1] = d;
}
void mpower(ll F[2][2], ll n) {
   if (n == 0 || n == 1)
      return;
   ll M[2][2] = {{1,1},{1,0}};
   mpower(F, n / 2);
   mat_mul(F, F);
   if (n % 2 != 0)
      mat_mul(F, M);
}
ll fib_mat(ll n) {
   ll F[2][2] = {{1,1},{1,0}};
   if (n == 0)
      return 0;
   mpower(F, n - 1);
   return F[0][0]%mod;
}
//End of Matrix Exponentiation
void fun(string s)
{
    ll n = s.size(),i,j;
    if(n%2==1)
    {
        for(i=n/2-1,j=n/2+1;;i--,j++)
        {
            if(i<0 || j>n)
                break;
            s[j]=s[i];
        }
        cout<<s<<"\n";
    }
    else
    {
        for(i=n/2-1,j=n/2;;i--,j++)
        {
            if(i<0 || j>n)
                break;
            s[j]=s[i];
        }
        cout<<s<<"\n";
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,f=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>j;
        if(i%2==1 && j%2==1)
            f++;
    }
    cout<<f;
    return 0;

}



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    int in, num[4];
    cin >> in;
    REP(i, 4) {
        num[3 - i] = in % 10;
        in /= 10;
    }
    REP(i, 1 << 4) {
        int ans = num[0];
        REP(j, 3) {
            if (i & (1 << j))
                ans += num[j + 1];
            else
                ans -= num[j + 1];
        }
        if (ans == 7) {
            cout << num[0];
            REP(j, 3) {
                if (i & (1 << j))
                    cout << "+" << num[j + 1];
                else
                    cout << "-" << num[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
# D問題
N = int(input())
ab = []
for i in range(N):
    ab.append(list(map(int, input().split())))
ab = sorted(ab, key = lambda x:x[1])
time = 0
flag = True
for i in range(N):
    time += ab[i][0]
    if time > ab[i][1]:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

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

using namespace std;

using ll = long long;

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

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

    ll n, a, ans = 0;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        ans += a - 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
//#include<cstring>
#include<string>
//#include<vector>
#include<map>
//#include<queue>
//#include<stack>
#include<algorithm>
#define ll unsigned long long
#define endl "\n"
//#define eps 1e-9
using namespace std;
map<char,int>m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int f=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        char x=s[i];
        m[x]++;
    }
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->second%2!=0)
        {
            f=1;
            break;
        }
    }
    if(f==1)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }


    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define inline __inline__ __attribute__((always_inline))
const int N = 1e5 + 5, INF = 0x3f3f3f3f, M = N << 1;
const ll LNF = 0x3f3f3f3f3f3f3f3f;

int a[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << setprecision(8) << fixed;
  int n, k;
  int ans = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] >= k) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m,q,l,r;
    cin>>n>>m>>q;
    int sum[n+1][n+1];
    memset(sum,0,sizeof(sum));
    for(int i=0;i<m;i++){
        scanf("%d%d",&l,&r);
        sum[l][r]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            sum[i][j]=sum[i][j]+sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1];
        }
    }
    for(int i=0;i<q;i++){
        scanf("%d%d",&l,&r);
        cout<<sum[n][r]-sum[l-1][r]<<endl;
    }
}


Measured memory_bytes: 1920
import java.io.*;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    Week week = Week.valueOf(br.readLine());
    System.out.println(7 - week.ordinal());
  }
}

enum Week {
	SUN,MON,TUE,WED,THU,FRI,SAT
}
  

Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int[] H = new int[N];
        int highest = 0;
        int count = 0;

        for (int i = 0; i < N; i++) {
            H[i] = Integer.parseInt(sc.next());
            if (i == 0) {
                highest = H[i];
                count++;
            } else {
                if (H[i] >= highest) {
                    count++;
                    if (H[i] > highest) {
                        highest = H[i];
                    } else {

                    }
                } else {

                }
            }
        }
        System.out.print(count);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
 
class sbit{
public:
	ll bit[100005];
	void add(int i, ll x){
		i++;
		while(i<100005){
			bit[i]+=x;
			i+=i&-i;
		}
	}
	void add(int l, int r, ll x){
		add(l, x);
		add(r, -x);
	}
	ll get(int i){
		i++;
		ll ret=0;
		while(i){
			ret+=bit[i];
			i-=i&-i;
		}
		return ret;
	}
};

ll k;
vector<pair<int, ll> > path[100005];

// int f[100005]; // original node index -> on the list
// int c[100005]; // size of subtree
// int d[100005]; // depth in tree
// int p[100005][18]; // parent doubling
int f[100005];
int c[100005];
int d[100005];
int p[100005][18];
sbit csm, dsm, qry;

void dfs(int nw, int par, int dep, int ind){
	f[nw]=ind;
	d[ind]=dep;
	p[ind][0]=par;
	for(int i=1; i<18; i++)
	 	p[ind][i]=p[p[ind][i-1]][i-1];
	int sm=1;
	for(int i=0; i<path[nw].size(); i++){
		pair<int, ll> &pr=path[nw][i];
		if(f[pr.first]==par) continue;
		dfs(pr.first, ind, dep+1, ind+sm);
		csm.add(ind+sm, ind+sm+c[ind+sm], pr.second);
		if(pr.second%k==0){
			dsm.add(ind+sm, ind+sm+c[ind+sm], pr.second);
		}
		sm+=c[ind+sm];
	}
	c[ind]=sm;
}

int lsc(int x, int y){
	if(d[x]<d[y]) swap(x, y);
	int dif=d[x]-d[y];
	for(int i=0; i<18; i++)
	 	if(dif&(1<<i)) x=p[x][i];
	// printf(" %d %d\n", x, y);
	if(x==y) return x;
	int ret=0;
	for(int i=18-1; i>=0; i--){
		// printf("(%d, %d)->(%d, %d)\n", x, y, p[x][i], p[y][i]);
		if(p[x][i]==p[y][i]) ret=p[x][i];
		else{
			x=p[x][i];
			y=p[y][i];
		}
	}
	return ret;
}

ll clc(int x){
	int q;
	while((q=qry.get(x))){
		int y=x;
		for(int i=18-1; i>=0; i--){
			if(qry.get(p[y][i])==q) y=p[y][i];
		}
		dsm.add(y, y+c[y], -(dsm.get(y)-dsm.get(p[y][0])));
		ll r=csm.get(y)-csm.get(p[y][0]);
		if(r%k==0){
			dsm.add(y, y+c[y], r);
		}
		qry.add(y, y+c[y], -(qry.get(y)-qry.get(p[y][0])));
	}
	return csm.get(x)-dsm.get(x);
}

int main(){
	int n;
	cin >> n >> k;
	for(int i=0; i<n-1; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		path[a].push_back(make_pair(b, c));
		path[b].push_back(make_pair(a, c));
	}
	for(int i=0; i<n; i++) f[i]=-1;
	dfs(0, 0, 0, 0);

	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		string s;
		ll x, y;
		cin >> s >> x >> y;
		if(s[0]=='a'){
			x=f[x];
			if(x){
			 	csm.add(x, x+c[x], y);
				qry.add(x, x+c[x], 1);
			}
			csm.add(x+1, x+c[x], y);
			qry.add(x+1, x+c[x], 1);
		}else{
			x=f[x];
			y=f[y];
			int z=lsc(x, y);
			ll ans=clc(x)+clc(y)-2*clc(z);
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 28492
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n;
  ll t[100000];
  ll a[100000];
  pii tr[100000];//t range
  pii ar[100000];//a range
  int i,j;
  ll ans=1LL;

  cin>>n;

  cin>>t[0];
  tr[0].first=tr[0].second=t[0];

  for(i=1;i<n;i++){
    cin>>t[i];
    tr[i].second=t[i];
    if(t[i]>t[i-1])
      tr[i].first=t[i];
    else
      tr[i].first=1;
  }

  rep(i,n){
    cin>>a[i];
    ar[i].second=a[i];
  }

  ar[n-1].first=ar[n-1].second=a[n-1];
  for(i=n-2;i>=0;i--)
    if(a[i]>a[i+1])
      ar[i].first=a[i];
    else
      ar[i].first=1;

  rep(i,n){
    if(ar[i].first<=tr[i].first && tr[i].second<=ar[i].second)//a-t-t-a
      ans=(ans*(tr[i].second-tr[i].first+1))%MOD;
    else if(tr[i].first<=ar[i].first && ar[i].second<=tr[i].second)//t-a-a-t
      ans=(ans*(ar[i].second-ar[i].first+1))%MOD;
    else if(ar[i].first<=tr[i].first && tr[i].first<=ar[i].second)//a-t-a-t
      ans=(ans*(ar[i].second-tr[i].first+1))%MOD;
    else if(tr[i].first<=ar[i].first && ar[i].first<=tr[i].second)//t-a-t-a
      ans=(ans*(tr[i].second-ar[i].first+1))%MOD;
    else{
      cout<<"0"<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main(void) {
	int A,B;
	cin >> A >> B;
	int C = A + B;
	int res = min(A%3,B%3);
	res = min(res,C%3);
	if (res == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
int n,a[200050],cnt1,cnt2,dp[200050],Max;
map<int,bool>vis;
int main(){
	scanf("%d",&n);
	Max=0;
	for(int i=1;i<=200000;i++) dp[i]=1;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		if(vis[a[i]-1]==1) dp[a[i]]+=dp[a[i]-1];
		vis[a[i]]=1;
	}
	for(int i=1;i<=n;i++){
		if(dp[i]>Max) Max=dp[i];
	}
	printf("%d\n",n-Max);
}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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; }

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll n;
    cin >> n;
    vector<string> x(n);
    for (ll i=0;i<n;i++)cin >> x[i];
    ll m;
    cin >> m;
    vector<string> y(m);
    for (ll i=0;i<m;i++)cin >> y[i];
    ll ans=0;
    for (ll i=0;i<n;i++){
        ll x_count=0,y_count=0;
        string a=x[i];
        for (ll k=0;k<n;k++)if (a==x[k])x_count++;
        for (ll j=0;j<m;j++)if (a==y[j])y_count++;
        ans=max(ans,x_count-y_count);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define up(i,j,n)	for(int i=j;i<=n;i++)
#define down(i,j,n)	for(int i=j;i>=n;i--)
#define cmax(a,b)	a=max(a,b)
#define cmin(a,b)	a=min(a,b)

const ll MAXN=2e5+5;
const ll oo=2e18+5;
const ll LIM=100;

ll N,l,r,nxt[MAXN],f[105][26],g[105];
char s[MAXN];

namespace solution{
	ll calc(ll p,ll c){
		ll sum=0;
		down(i,LIM,1)if(p>=g[i]){
			sum+=f[i][c];
			p-=g[i];
		}
		up(i,1,p)sum+=((s[i]-'a')==c);
		return sum;
	}
	void Prepare(){
		scanf("%s",s+1);
		scanf("%lld%lld",&l,&r);
		N=strlen(s+1);
		N>>=1;
		ll p=0;
		up(i,2,N){
			while(p&&s[p+1]!=s[i])p=nxt[p];
			if(s[p+1]==s[i])p++;
			nxt[i]=p;
		}
		up(i,1,N)f[1][s[i]-'a']++;
		memcpy(f[2],f[1],sizeof(f[1]));
		up(i,nxt[N]+1,N)f[2][s[i]-'a']++;
		g[1]=N;
		g[2]=N+N-nxt[N];
		up(i,3,LIM){
			g[i]=g[i-1]+g[i-2];
			cmin(g[i],oo);
			up(j,0,25){
				f[i][j]=f[i-1][j]+f[i-2][j];
				cmin(f[i][j],oo);
			}
		}
	}
	void Solve(){
		up(i,0,25)printf("%lld ",calc(r,i)-calc(l-1,i));
		puts("");
	}
}

int main(){
//	freopen("input.in","r",stdin);
	using namespace solution;
	Prepare();
	Solve();
	return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	
	int n;
	cin >> n;

	set<int> se;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;

		if (se.count(a)) {
			se.erase(a);
		} else {
			se.insert(a);
		}
	}

	int res = se.size();
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4992
#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; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for(auto &x : h) cin >> x;
	vector<int> g[n];
	while(m--){
		int a, b;
		cin >> a >> b;
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int res = 0;
	for(int i = 0; i < n; ++i){
		bool ok = true;
		for(auto &x : g[i]) ok &= h[i] > h[x];
		res += ok;
	}

	cout << res << endl;

	return 0;
}

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


int main(){
  
  int n;
  cin >> n;
  int n1 = n-1;
  int ans = 0;
  
  for(int i = 1; i < n+1; i++){
    ans += n1 / i;    
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int N=sc.nextInt();
		int K=sc.nextInt();
		pw.println(N%K==0?0:1);
		pw.close();
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256