akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int N;
 	cin >> N;
 	cout << "Christmas";
 	for (int i = 0; i < 25-N; i++){
 		cout << " Eve" ;
 	}
 	cout << "" << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b, int c)
{
    int gcd=0;
    int m=min(a,b);
    int n=min(m,c);
    for(int i=1; i<=n; i++)
    {
        if(a%i==0 && b%i==0 && c%i==0)
            gcd=i;
    }
    return gcd;
}
int main()
{
    int k;
    cin>>k;
    long long int sum=0;
    for(int i=1; i<=k; i++)
    {
        for(int j=1; j<=k; j++)
        {
            for(int m=1; m<=k; m++)
            {
                sum=sum+gcd(i,j,m);
            }
        }
    }
    cout<<sum<<endl;


}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;


int32_t main(){
    vaibhavv06;
	int n,m; cin>>n>>m;
    int arr[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char c; cin>>c;
            if(c == '.') arr[i][j]=1;
            else arr[i][j]=0;
        }
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<m;j++){
    //         cout<<arr[i][j]<<" ";

    //     }
    //     cout<<endl;
    // }
    int dp[n][m];
    MM(dp,0);
    dp[0][0]=arr[0][0];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(i==0 && j==0) continue;
            else if(arr[i][j]==0) dp[i][j]=0;
            else if(i==0 || j==0 ){
                if(i==0){
                    dp[i][j]=dp[i][j-1];
                }
                else dp[i][j]=dp[i-1][j];
            }
            else {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=MOD;
            }
        }
    }
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<m;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<dp[n-1][m-1]<<endl;
}

Measured memory_bytes: 15872
#include <iostream>

using namespace std;


int main() {
  int64_t a,b,c,d;
  cin >> a >> b >> c >> d;
  int64_t max_value;
  int64_t output;
  
  for( int index = 0; index < 4; index++){
    switch(index){
      case 0:
        output = a*c;
        max_value = output;
       	break;
      case 1:
        output = a*d;
        break;
      case 2:
        output = b*c;
        break;
      case 3:
        output = b*d;
        break;
    }
    
    if(max_value < output){
      max_value = output;
    }
  }
  
  cout << max_value;
  cout << endl;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	string s; cin >> s;
	int K, U, P, C; K = U = P = C = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'K')K++;
		if (s[i] == 'U')U++;
		if (s[i] == 'P')P++;
		if (s[i] == 'C')C++;
	}
	cout << min({ K,U,P,C }) << endl;
	return 0;
}

Measured memory_bytes: 3188
N,M = map(int,input().split())

li=list(map(int,input().split()))

cumsum = [None] * (N+1)

cumsum[0] = 0

for i in range(N):
  cumsum[i+1] = (cumsum[i] + li[i]) % M

# M は大きいので長さ M の配列を持つことはできませんが,と解説にある。
# testcase3ではこの初期化でメモリ(>3GB)、実行時間（>7s)で死ぬ
# modhis = [0] * M
modhis = {}
ans = 0
for i in range(N+1):
  if cumsum[i] in modhis:
    ans += modhis[cumsum[i]]
    modhis[cumsum[i]] += 1
  else:
    modhis[cumsum[i]] = 1
#  配列版。先述の通り死ぬ。Mが小さい間は通るけど。。
#  ans += modhis[cumsum[i]]
#  modhis[cumsum[i]] += 1

print(ans)
# for debug
# print(cumsum)
# print(modhis)

Measured memory_bytes: 16268
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#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)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	string s;
    int o=0;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='o')o++;
    }
    if(o + 15 - s.size() >= 8){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}

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

using namespace std;

typedef long long ll;

string S;
ll K;

int main() {
	cin >> S >> K;
	ll ans = 0;
	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[0] == S[i])cnt++;
	}
	
	if (cnt == S.size()) {
		cout << (S.size() * K) / 2 << endl;
		return 0;
	}
	
	if (S[0] != S[S.size() - 1]) {
		ll length = 1;
		for (int i = 1; i < S.size(); i++) {
			if (S[i] == S[i - 1])length++;
			else {
				ans += (length / 2LL * K);
				length = 1;
			}
		}
		ans += (length / 2LL) * K;
	}

	else {
		string s2 = S + S;
		ll length = 1;
		bool f = true;
		for (int i = 1; i <= S.size() * 2; i++) {
			if (i == S.size() - 1) {
				if (s2[i] == s2[i - 1])length++, ans += length / 2LL;
				else ans += length / 2LL * K, length = 1;
			}
			else if (s2[i] == s2[i - 1])length++;
				else if (i >= S.size()) {
					ans += length / 2LL * (K - 1);
					break;
				}
				else {
					if (f) {
						ans += length / 2LL;
						f = false;
					}
					else {
						ans += length / 2LL * K;
					}
					length = 1;
			}
		}
	}

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

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

int main(){
  string s,rev;
  cin >> s;
  rev = s;
  int n = s.size();
  reverse(rev.begin(),rev.end());
  vector<char> s2((n-1)/2),s3((n-1)/2);
  
  rep(i,(n-1)/2){
    s2.at(i) = s.at(i);
  }
  auto rev2 = s2;
  
  for(int i = 0;i<(n-1)/2;i++){
    s3.at(i) = rev.at(i);
  }
  auto rev3 = s3;
  
  reverse(rev2.begin(),rev2.end());
  reverse(rev3.begin(),rev3.end());
  if(s == rev){
    if(s2 == rev2){
      if(s3 == rev3){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Inf 0x3f3f3f3f
int main()
{
    double k,a,b;
    cin>>k>>a>>b;
    double mul=ceil(a/k);
    //cout<<mul<<endl;
    if(k*mul<=b)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;

}

Measured memory_bytes: 3724
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n;
	cin >> n;
	if (n % 2 == 1) cout << n * 2 << endl;
	else cout << n << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  while(true){
    int n,t,l,b;
    cin>>n>>t>>l>>b;
    if(n==0&&t==0&&l==0&&b==0)break;
    vector<int> ms(n+1,0);
    for(int i=0;i<l;i++){
      int a;
      cin>>a;
      ms[a]=1;
    }
    for(int i=0;i<b;i++){
      int a;
      cin>>a;
      ms[a]=2;
    }
    vector<vector<double> > dp(t+2,vector<double>(n+1,0));
    dp[0][0]=1;
    for(int i=0;i<t;i++){
      for(int j=0;j<n;j++){
        if(dp[i][j]==0)continue;
        for(int k=1;k<=6;k++){
          int np=j+k;
          if(np>n)np=n-(np%n);
          if(ms[np]==0)dp[i+1][np]+=dp[i][j]/6;
          else if(ms[np]==1)dp[i+2][np]+=dp[i][j]/6;
          else dp[i+1][0]+=dp[i][j]/6;
        }
      }
      dp[i+1][n]+=dp[i][n];
    }
    cout<<fixed<<setprecision(20)<<dp[t][n]<<endl;
  }
}



Measured memory_bytes: 3340
#include<stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d",&a);
  b = a%60;
  c = ((a-b)%3600)/60;
  d = (a-b-c*60)/3600;
  printf("%d:%d:%d\n",d,c,b);
  return 0;
}



Measured memory_bytes: 2032
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(c+1):
    for j in range(b+1):
        if (x-50*i-100*j)%500==0 and ((x-50*i-100*j)/500)<=a and ((x-50*i-100*j)/500)>=0:
            cnt += 1

print(cnt)

Measured memory_bytes: 38768
class Array
  def lcm
    self.inject{|a,b| a.lcm(b)}
  end

  def gcd
    self.inject{|a,b| a.gcd(b)}
  end
end

array = []

num = gets.to_i

for value in 0...num do
  input = gets.to_i
  array.push(input)
end
p array.lcm


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;
const int N = 17;
const int mod = 1e9 + 7;
int n, m, a[N], fac[1 << N], inv[1 << N], dp[N][1 << N], mx, c[1 << N];
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 << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int ksm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = x * x % mod)
		if(y & 1) res = res * x % mod;
	return res;
}
bool cmp(const int & a, const int & b) {return a > b;}
int C(int n, int m)
{
	if(n < m || n < 0 || m < 0) return 0;
	return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); m = read();
	for(int i = 1; i <= m; i ++) a[i] = read();
	sort(a + 1, a + m + 1, cmp); mx = (1 << n); fac[0] = 1;
	for(int i = 1; i <= mx; i ++) fac[i] = fac[i - 1] * i % mod;
	inv[mx] = ksm(fac[mx], mod - 2);
	for(int i = mx - 1; i >= 0; i --) inv[i] = inv[i + 1] * (i + 1) % mod;
	for(int i = 1; i <= mx; i ++) c[i] = c[i - (i & (- i))] + 1;
	dp[0][0] = 1;
	for(int i = 1; i <= m; i ++)
		for(int s = 0; s < (1 << n); s ++)
			if(dp[i - 1][s])
			{
				(dp[i][s] += dp[i - 1][s]) %= mod;
				for(int j = 0; j < n; j ++)
					if(!(s & (1 << j))) (dp[i][s | (1 << j)] += dp[i - 1][s] * fac[1 << j] % mod * C(mx - a[i] - s, (1 << j) - 1)) %= mod;
			}
	int ans = 0;
	for(int s = 0; s < (1 << n); s ++)
	{
		if(c[s] & 1) ans = (ans - dp[m][s] * fac[mx - 1 - s] % mod + mod) % mod;
		else ans = (ans + dp[m][s] * fac[mx - 1 - s] % mod) % mod;
	}
	printf("%lld\n", ans * mx % mod);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 19200
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 300005;
const ll mm = 1e+18;
void solve()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h+=(m/60.0);
    double f=fabs(5*h-m);
    double ff=(double)(f)/60.0;
    ff*=acos(-1);
    ff*=2.0;
    double ans=a*a+b*b-2.0*a*b*cos(ff);
    double ss=sqrt(ans);
    cout<<fixed<<setprecision(10)<<ss;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // srand(time(0));
    //freopen("sp.txt","r",stdin);
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 4236
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.size()==2){
    cout << s << endl;
  }else{
    cout << s[2] << s[1] << s[0] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxw = 1e5 + 10;
const int maxn = (1 << 18) + 10;
const int magic = 1 << 9;
int v[maxn], w[maxn];
int dp[magic][maxw];

int query(int x, int L) {
  if(x < magic) return dp[x][L];
  vector <pair <int, int>> cont;
  while(x >= magic) {
    cont.emplace_back(w[x], v[x]);
    x >>= 1;
  }
  int ans = 0;
  for(int i = 0; i < (1 << cont.size()); i++) {
    int totalW = 0, totalV = 0;
    for(int j = 0; j < cont.size(); j++) {
      if((i >> j) & 1) {
        totalW += cont[j].first;
        totalV += cont[j].second;
      }
    }
    if(totalW <= L) {
      ans = max(ans, totalV + dp[x][L - totalW]);
    }
  }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d %d", &v[i], &w[i]);
  }
  for(int i = 1; i < magic && i <= n; i++) {
    for(int j = 1; j < maxw; j++) {
      dp[i][j] = dp[i >> 1][j];
      if(w[i] <= j) {
        dp[i][j] = max(dp[i][j], v[i] + dp[i >> 1][j - w[i]]);
      }
    }
  }
  int q;
  scanf("%d", &q);
  while(q--) {
    int x, L;
    scanf("%d %d", &x, &L);
    printf("%d\n", query(x, L));
  }
  return 0;
}


Measured memory_bytes: 205472
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int s = sc.nextInt();
		int w = sc.nextInt();
		
		if (s > w) {
			System.out.println("safe");
		} else {
			System.out.println("unsafe");
		}
	}
}

Measured memory_bytes: 35768
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define tp tuple<int,int,int>
#define mtp make_tuple
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e5 + 5;
vector<int> g[N];
int p[N], col[N];

void dfs(int node, int anc) {
    col[node] = 1;
    for (int to : g[node]) {
        if (!col[to]) {
            dfs(to, node);

            if (p[to]) {
                cout << to + 1 << " " << node + 1 << "\n";
            }
            else {
                p[node] ^= 1;
                cout << node + 1 << " " << to + 1 << "\n";
            }
        }
        else if (to != anc && col[to] == 1) {
            p[node] ^= 1;
            cout << node + 1 << " " << to + 1 << "\n";
        }
    }
    col[node] = 2;
}

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

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    if (m % 2) {
        cout << "-1\n";
    }
    else {
        dfs(0, -1);
    }

    return 0;
}

Measured memory_bytes: 15488
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 200010
ll n;
namespace uf{
  ll p[N],siz[N],id[N];
  ll to[N],len[N],m;
  void init(){
      for(int i=1;i<=n;i++)p[i]=i,siz[i]=1,id[i]=i;
      m=n;
  }
  ll par(ll x){
      ll y=x,z;
      while(x!=p[x])x=p[x];
      while(y!=x)z=p[y],p[y]=x,y=z;
      return x;
  }
  
  void unite(ll a,ll b,ll e){
      a=par(a); b=par(b);
      to[id[a]]=to[id[b]]=++m;
      len[id[a]]=siz[b]*e,len[id[b]]=siz[a]*e;
      p[a]=b,siz[b]+=siz[a],id[b]=m;
  }
  
  vector<ll> g[N];
  ll ans[N];
  void dfs(ll x,ll d){
      ans[x]=d;
      for(auto y:g[x])dfs(y,d+len[y]);
  }
  void main(){
      for(int i=1;i<m;i++){
	  g[to[i]].push_back(i);
      }
      dfs(m,0);
      for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
  }
};
struct edge{
  ll a,b,c;
  bool operator<(const edge&key)const{
      return this->c>key.c;
  } 
};
edge e[N];
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++)cin>>e[i].a>>e[i].b>>e[i].c;
    sort(e,e+n-1); uf::init();
    for(int i=0;i<n-1;i++){
	uf::unite(e[i].a,e[i].b,e[i].c);
    }
    uf::main();
    return 0;
}



Measured memory_bytes: 26368
import sys
input = sys.stdin.readline


class SegmentTree:
    def __init__(self, n, func, e, arrange=None):
        self.init(n)
        self.func = func
        self.e = e
        self.make_arrange(arrange)
    
    def init(self, n):
        self.inf = pow(2, 32)
        self.n = n
        self.N = 1
        while self.N < self.n:
            self.N *= 2
        self.size = self.N * 2 - 1
        self.N -= 1
    
    def make_arrange(self, arrange):
        self.set_arrange(arrange)
        self.construct(arrange)

    def set_arrange(self, arrange):
        if arrange == None:
            self.segment = [self.e]*(self.size)
            return
        self.segment = [0]*(self.N) + arrange + [self.e]*(self.size-self.N-self.n)
    
    def construct(self, arrange):
        if arrange == None:
            return
        for i in range(self.N-1, -1, -1):
            self.segment[i] = self.func(self.segment[2*i+1], self.segment[2*i+2])
    
    def update(self, i, x):
        i += (self.N-1)
        self.segment[i] = x
        while i > 0:
            i = (i-1)//2
            self.segment[i] = self.func(self.segment[2*i+1], self.segment[2*i+2])
    
    def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return self.e
        elif a <= l and r <= b:
            return self.segment[k]
        else:
            find_l = self.find(a, b, 2*k+1, l, (l+r)//2)
            find_r = self.find(a, b, 2*k+2, (l+r)//2, r)
            res = self.func(find_l, find_r)
            return res

    def count(self, l, r):
        return self.find(l-1, r, 0, 0, self.size-self.N)
    
    def bisect_sub(self, a, b, k, l, r, x):
        if r <= a or b <= l:
            return b+1
        if self.segment[k] < x:
            return b+1
        if k >= self.N:
            return r
        
        find_l = self.bisect_sub(a, b, 2*k+1, l, (l+r)//2, x)
        if find_l <= b:
            return find_l

        find_r = self.bisect_sub(a, b, 2*k+2, (l+r)//2, r, x)
        return find_r

        

    def bisect(self, l, r, x):
        return self.bisect_sub(l-1, r, 0, 0, self.size-self.N, x)
    

def main():
    n, q = map(int, input().split())
    p = list(map(int, input().split()))
    seg = SegmentTree(n, max, 0, arrange=p)

    res = []
    for i in range(q):
        a, b, c = list(map(int, input().split()))
        if a == 1:
            seg.update(b, c)
        elif a == 2:
            ans = seg.count(b, c)
            res.append(ans)
        else:
            ans = seg.bisect(b, n, c)
            res.append(ans)

    print(*res, sep="\n")
            

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 31356
program kleene_inversion
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, a(2000) = 0, b(4000) = 0, i, j
  integer(8) :: inv(4000) = 0_8, k, ans = 0_8, coef
  read(*,*) n, k
  read(*,*) a(1:n)
  b(1:n) = a(1:n)
  b(n+1:2*n) = a(1:n)
  do i = 1, 2*n
    do j = 1, i-1
      if (b(j) > b(i)) inv(i) = inv(i)+1_8
    end do
  end do
  coef = mod(mod(k*(k-1_8),md)*500000004_8,md)
  do i = 1, n
    ans = mod(ans+mod(k*inv(i),md)+mod(coef*(inv(n+i)-inv(i)),md),md)
  end do
  write(*,'(i0)') mod(ans,md)
end program kleene_inversion

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<29;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c; cin >> a >> b >> c;
    
    if(a==b+c || a+b==c || a+c==b) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
}



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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

void solve(string s, string t){
  int32 n = s.size();
  int32 m = t.size();
  bool flg = false;
  int32 cnt = 0;
  string a,b;
  a=b="";
  int32 i=0,j=0;
  while(i<n&&j<m){
    if(flg){
      while(s[i] != '\"'){
        a.pb(s[i]);
        ++i;
      }
      while(t[j] != '\"'){
        b.pb(t[j]);
        ++j;
      }
      if(a != b)++cnt;
      a=b="";
      flg= false;
    }else{
      if(s[i] == '\"' && t[j] == '\"'){
        flg = true;
      }else if(s[i] != t[j]){
        ANS("DIFFERENT");
        return;
      }
    }
    ++i;++j;
  }
  if(cnt >= 2 || i != n || j != m){
    ANS("DIFFERENT");
  }else if(cnt == 1){
    ANS("CLOSE");
  }else{
    ANS("IDENTICAL");
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  while(true){
    cin >> s;
    if(s == ".")return 0;
    cin >> t;
    solve(s,t);
  }
  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int sumx = accumulate(a.begin(), a.end(), 0);
    if(sumx % 10)
        cout << sumx << endl;
    else{
        sort(a.begin(), a.end());
        int i = 0;
        while(i < n){
            if(a[i] % 10)
                break;
            i++;
        }
        if(i == n)
            cout << 0 << endl;
        else
            cout << sumx - a[i] << endl;
    }

    return 0;
}



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

int main()
{
        string S; cin >> S;
        ll len = S.length();
        for (int i = 0; i < S.length(); i+=2) {
                len -= 2;
                string s1 = S.substr(0, len/2);
                string s2 = S.substr(len/2, len/2);
//              cout << s1 << " " << s2 << endl;
                if (s1 == s2) {
                        cout << s1.length() * 2 << endl;
                        break;
                }
        }


}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, c, d;
    cin >> a >> b >>c >>d;
    if(a*b >= c*d){
        cout << a*b;
    }
    else cout << c*d;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    scanf("%d", &n);
    vector<int> b(n-1);
    for(int i=0;i<n-1;i++){
        scanf("%d", &b[i]);
    }
    int ans=b[0]+b[n-2];
    for(int i=1;i<n-1;i++){
        ans+=min(b[i], b[i-1]);
    }
    printf("%d", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
#define ull unsigned long long int
//const int mod=1e9+7;
const ll inf=1LL<<32;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    int dp[n];
    memset(dp,0,sizeof(dp));
    fb(i,n-1,0){
        if(s[i]=='o'){
            dp[i]=1;
            if(i+c+1<n)
            dp[i]+=dp[i+c+1];
        }
        else
        {
            if(i+1<n)
            dp[i]=dp[i+1];
        }
    }
    map<int,int> mp;
    fr(i,0,n){
        mp[dp[i]]=i;
    }
    fr(i,0,n){
        if(dp[i]>=k&&s[i]=='o')
        {
            // agar aage bhi dp[i]=k&&s[i]=='o' hua to ye bound nhi hua
            if(i==mp[k])
            cout<<i+1<<endl;
            k--;
            i+=c;
        }
        if(k==0)
        break;
    }

}


Measured memory_bytes: 11924
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    i64 X;
    cin >> X;

    auto f = [&](i64 A, i64 B) {
        return A*A*A*A*A - B*B*B*B*B;
    };

    for(i64 A = -1000; A <= 1000; A++){
        i64 b = -1000, B = 1000;
        if(f(A, B) > X|| X > f(A, b)) continue;
        
        while(B - b > 1){
            i64 m = (B + b) / 2;
            if(f(A, m) <= X) B = m;
            else b = m;
        }
        if(f(A, B) == X) {
            cout << A << " " << B << endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
    long a,b,c,ans;
    scanf("%ld %ld %ld",&a,&b,&c);
    ans=c+b;
    if(ans>a+b*2+1) ans=a+b*2+1;

    printf("%ld",ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				cout << "No" << endl; return 0;
			}
		}
		else {
			if (s[i] == 'R') {
				cout << "No" << endl; return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

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

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){
 
  ll n, w; cin >> n >> w;
  vector<ll> v(100000 + 10, -1);
  v[0] = 0;

  rep(i, n){
    ll weight, value;
    cin >> weight >> value;
    for(int j = 100000; j >= 0; j--){
      if(v[j] != -1){
        if(v[j + value] == -1)
          v[j + value] = v[j] + weight;
        else
          chmin(v[j + value], v[j] + weight);
      }
    }
  }

  for(int i = 100000; i >= 0; i--){
    if(v[i] != -1 and v[i] <= w){
      pr(i);
      return 0;
    }

  }

  return 0;
}


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

int main(){
	// sengen
	long long n,m;
	// nyuryoku
	cin >> n >> m;
	long long a[m];
	long long sum=0;
	for(int i=0;i<m;i++){
		cin >> a[i];
		sum += a[i];
	}
	// keisan
	if(sum <= n){
		cout << n - sum;
	}else{
		cout << "-1";
	}
	// syutsuryoku
}

Measured memory_bytes: 3672
#include <cstdio>
#include <iostream>
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int MAXN = 2e5+5;
int a[MAXN];
int main(){
	int k,n;
	int maxx=0,sum=0;
	scanf("%d%d",&k,&n);
	for(int i=0;i<n;++i)
		scanf("%d",&a[i]);
	a[n]=k+a[0];
	for(int i=1;i<=n;++i){
		sum+=(a[i]-a[i-1]);
		maxx=max(maxx,a[i]-a[i-1]);
	}
	printf("%d\n",sum-maxx);
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n){
		char c;
		set<char>s;
		for(int i=0;i<n;i++){
			cin>>c;
			s.insert(c);
		}
		if(s.size()==3){
			cout<<"Three"<<endl;
		}
		else{
			cout<<"Four"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
abcd = list(map(int, input()))
n = len(abcd)-1


for i in range(2**n):
    ans = 0
    formula = []
    for j in range(n):
        if (i >> j & 1):
            formula.append('+')
        else:
            formula.append('-')
    ans += abcd[0]
    for k in range(n):
        if formula[k] == '+':
            ans += abcd[k+1]
        elif formula[k] == '-':
            ans -= abcd[k+1]
    if ans == 7:
        print(abcd[0], formula[0], abcd[1], formula[1],
              abcd[2], formula[2], abcd[3], '=', 7, sep='')
        break


Measured memory_bytes: 3064
if __name__ == "__main__":
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    ans = 0.0
    count = 0
    tmp = 0.0
    for i in range(n):
        if count == k:
            tmp = tmp - (1.0 + float(p[i-k])) / 2.0 + (1.0 + float(p[i])) / 2.0
            if tmp > ans:
                ans = tmp
        else:
            tmp += (1.0 + float(p[i])) / 2.0
            ans = tmp
            count += 1

    print(ans)


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

void solve(std::string S)
{
    if (S == "SUN")
        cout << "7" << endl;
    else if (S == "MON")
        cout << "6" << endl;
    else if (S == "TUE")
        cout << "5" << endl;
    else if (S == "WED")
        cout << "4" << endl;
    else if (S == "THU")
        cout << "3" << endl;
    else if (S == "FRI")
        cout << "2" << endl;
    else if (S == "SAT")
        cout << "1" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}

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

int main() {

  int a,b,c,d,e,f;

  cin >> a ;
  b=a/2;
  if(a%2==0) {
    c=b;
  }
          else{
            c=b+1;
          }
  cout<<b*c<<endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD = (int)1e9 + 7;
const int MOD = 998244353;

const double EPS = 1e-9;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int modpow(int x, int n, const int mo) {
	int res = 1;
	while (n > 0) {
		if (n & 1) (res *= x) %= mo;
		(x *= x) %= mo;
		n >>= 1;
	}
	return res;
}

int inverse(int x, const int mo) {
	return modpow(x, mo - 2, mo);
}

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

	COMinit();

	int K,N;
	cin>>K>>N;

	rep(i,2,2*K+1)
	{
		if(i%2==0)
		{
			int sz=min(i-1,K)-i/2+1;
			int ans=0;
			rep(j,0,min(sz+1,N/2+1))
			{
				int res=COM(sz,j);
				res*=COM(N-2*j+K-1,K-1);
				res%=MOD;
				if(j%2==0)ans=(ans+res)%MOD;
				else ans=(ans-res+MOD)%MOD;
			}	
			cout<<ans<<endl;
		}
		else
		{
			int sz=min(i-1,K)-i/2;
			int ans=0;
			rep(j,0,min(sz+1,N/2+1))
			{
				int res=COM(sz,j);
				res*=COM(N-2*j+K-1,K-1);
				res%=MOD;
				if(j%2==0)ans=(ans+res)%MOD;
				else ans=(ans-res+MOD)%MOD;
			}	
			cout<<ans<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 12288
#include<stdio.h>
int main()
{
    int x,a;
    scanf("%d%d",&x,&a);
    if(x<a){
        printf("0\n");
    }
    else if(x>a){
        printf("10\n");
    }
    else if(x==a){
        printf("10\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int half, i;
		for(i = S.length() - 1;i > 1;i --) {
			if(i % 2 != 0)continue;
			int ac = 0;
			for(int k = 0;k < i;k ++) {
				char c = S.charAt(k);
			}
			for(int k = 0;k < i / 2; k ++) {
				char c1 = S.charAt(k), c2 = S.charAt(k + i / 2);
				if(c1 == c2) ac ++;
			}
			if(ac == i / 2) break;
		}
		System.out.println(i);
	}
}

Measured memory_bytes: 25172
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		double c = sc.nextInt();
		double d = sc.nextInt();

		double tturn = Math.ceil(c/b);
		double aturn = Math.ceil(a/d);

		if(tturn <= aturn) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W, N;
    cin >> H >> W >> N;
    vector<ll> a(N), b(N);
    for (int i = 0; i < N; i++)
        cin >> a[i] >> b[i];
    map<pll, ll> mp;
    for (int i = 0; i < N; i++) {
        for (int j = -2; j <= 0; j++) {
            for (int k = -2; k <= 0; k++) {
                ll nx = a[i] + j, ny = b[i] + k;
                if (nx <= 0 || nx >= H - 1 || ny <= 0 || ny >= W - 1)
                    continue;
                mp[pll(nx, ny)]++;
            }
        }
    }
    ll ans[10] = { 0 };
    for (auto it = mp.begin(); it != mp.end(); it++){
        ans[it->second]++;
        //cout<<it->first.first<<" "<<it->first.second<<" "<<it->second<<endl;
    }
    ll sum = (H - 2) * (W - 2);
    for (auto v : ans) {
        sum -= v;
    }
    ans[0] += sum;
    for (auto v : ans) {
        cout << v << endl;
    }
    return 0;
}

Measured memory_bytes: 58240
//============================================================================
// Name        : oturi.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int pay = 1000,buy,oturi = 0,gohyaku,gohyakua,hyaku,hyakua,goju,gojua,ju,jua,go,goa;
    while(1){
	cin >> buy;
	if(buy == 0){
		break;
	}
	oturi = pay - buy;
	gohyakua = oturi % 500;
	gohyaku = oturi / 500;
	hyakua = gohyakua % 100;
	hyaku = gohyakua / 100;
	gojua = hyakua % 50;
	goju = hyakua / 50;
	jua = gojua % 10;
	ju = gojua / 10;
	goa = jua % 5;
	go = jua / 5;
	cout << gohyaku + hyaku + goju + ju + go + goa << endl;
    }
	return 0;
}

Measured memory_bytes: 1160
n,m = map(int,input().split())
dp = [0]+[10**8+10]*(2**n-1)
for i in range(m):
  a,b = map(int,input().split())
  s = sum([2**(x-1) for x in list(map(int,input().split()))])
  for j in range(2**n):
    if dp[j|s] > dp[j]+a:
      dp[j|s] = dp[j]+a
if dp[-1] <= 10**8:
  print(dp[-1])
else:
  print(-1)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int g = 0;
  int p = 0;
  int res = 0;
  for(int i = 0;i < s.size();i++){
    if(g == p){
      g++;
      if(s[i] == 'p')res--;
    }
    else{
      if(s[i] == 'g'){
        res++;
      }
      p++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		var r = Enumerable.Range(1, 1009).FirstOrDefault(x => (int)(0.08 * x) == h[0] && (int)(0.1 * x) == h[1]);
		Console.WriteLine(r > 0 ? r : -1);
	}
}


Measured memory_bytes: 28348
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int x=0;
    if(a<=b){
      x=x+b;
      if(a<=b-1){
        x=x+b-1;
      }else{
        x=x+a;
      }
    }else{
      x=x+a;
      if(b<=a-1){
        x=x+a-1;
      }else{
        x=x+b;
      }
    }
    System.out.println(x);
  }
}


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

int n, t, cost = 1007;
int main(){
cin >> n >> t;
vector <pair<int, int>  >item;
for(int i = 0; i<n; i++){
	int a, b;
	cin >> a >> b;
	item.push_back(make_pair(a,b));
}
bool IsTrue = false;
for(int i = 0; i<n; i++){
	if(item[i].second <= t){
		cost = min(cost, item[i].first);
		IsTrue = true;
	}
}
if(IsTrue)
	cout << cost;
else
	cout << "TLE";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int long long 
const int N=1e5+5;
const int INF=1e9+5;
vector<int> dp(N,INF);



int main(){
    int n;
    scanf("%d",&n);
  
    int a[n][3];
    int dp[n][3];
    for(int i=0;i<n;i++){
       for(int j=0;j<3;j++){
         cin>>a[i][j];
         dp[i][j]=0;
       }
    }
     
     dp[0][0]=a[0][0];
     dp[0][1]=a[0][1];
     dp[0][2]=a[0][2];

    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
               if(j!=k)
                 dp[i][j]=max(dp[i-1][k]+a[i][j],dp[i][j]);
            }
        }
    }   
  
     printf("%d\n", max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}));
  

return 0;
}

Measured memory_bytes: 2944
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
//#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 4e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
bool prime(int n) {
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios;
    ll n , a , b;
    cin >> n >> a >> b;
    ll ans = (n / (a + b)) * a;
    ans += min(a , n % (a + b));
    cout << ans;
    return 0;
}


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

using namespace std;

int main(void){
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> C(N,0);
    vector<vector<int>> A(N,vector<int>(M,0));
    
    for(int i=0;i<N;i++){
        cin >> C.at(i);
        for(int j=0;j<M;j++){
            cin >> A.at(i).at(j);
        }
    }
    
    int max=1;
    
    for(int i=0;i<N;i++){
        max*=2;
    }
    
    int minans=1000000000;
    int crtans=0;
    
    for(int i=0;i<max;i++){
        vector<int> binary(N,0);
        vector<int> ability(M,0);
        for(int j=0;j<N;j++){
            binary.at(j)=((i >> j)&1);
        }
        
        for(int j=0;j<N;j++){
            if(binary.at(j)==1){
                for(int k=0;k<M;k++){
                    ability.at(k)+=A.at(j).at(k);
                }
                crtans+=C.at(j);
            }
        }
        
        bool isOk=true;
        
        for(int j=0;j<M;j++){
            if(ability.at(j)<X){
                isOk=false;
                break;
            }
        }
        
        if(isOk){
            if(minans>crtans){
                minans=crtans;
            }
        }
        
        crtans=0;
    }
    
    if(minans==1000000000){
        minans=-1;
    }
    
    cout << minans << endl;
    
    return 0;
    
}


Measured memory_bytes: 3604