akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i'|| c == 'o'|| c == 'u'){
        cout << "vowel";
        return 0;
    }
    cout << "consonant";
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
ans=0

S=[[0,0] for i in range(n)]
for i in range(n):
    for j in range(n):
        if A[i]>A[j]:
            if j>i: S[i][0]+=1
            S[i][1]+=1
#print(S)
for i in range(n):
    ans+= (k*S[i][0])%mod
    ans%=mod
    tmp= (k*(k-1)//2)%mod
    ans+= (tmp*S[i][1])%mod
    ans%=mod
print(ans)
    

Measured memory_bytes: 68796
#include <iostream>
#include <cmath>
using namespace std;
 
#define MAXN 100020
 
int N;
long long a[MAXN], b[MAXN], c[MAXN];
long long dp[MAXN][3];
 
int main() {
	cin >> N;
  	for (int i = 0; i < N; i++) {
      	cin >> a[i] >> b[i] >> c[i];
    }
  	dp[0][0] = a[0];
 	dp[0][1] = b[0];
  	dp[0][2] = c[0];
  	for (int i = 1; i < N; i++) {
      dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
      dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
      dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
    }
  	cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])) << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<vector<int>> G;
vector<LP> dp;
vector<bool> visited;

void dfs(int s){
    //cout << s << endl;
    visited[s]=true;
    rep(i,G[s].size()){
        int k=G[s][i];
        if (visited[k]) continue;
        dfs(k);
        dp[s].first*=dp[k].second;
        dp[s].second*=(dp[k].first+dp[k].second);
        dp[s].first%=mod;dp[s].second%=mod;
    }
    
}

void solve(){
    cin >> n;
    G.resize(n,{});
    dp.resize(n,LP(1,1));
    visited.resize(n,false);
    rep(i,n-1){
        int x,y;
        cin >> x >> y;
        G[x-1].push_back(y-1);
        G[y-1].push_back(x-1);
    }
    dfs(0);
    cout << (dp[0].first+dp[0].second)%mod << endl;
}

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

Measured memory_bytes: 11520
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007



int main() {
  int N, M;
  map<string, int> Blue, Red;

  cin >> N;
  rep(i, N) {
    string s;
    cin >> s;
    Blue[s]++;
  }

  cin >> M;
  rep(i, M) {
    string s;
    cin >> s;
    Red[s]++;
  }

  int ans = 0;

  for (auto tui : Blue) {
    string t = tui.first;
    ans = max(ans, Blue[t] - Red[t]);
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
ll N,W;
vector<ll> vec_w[4];
ll Max=0;
int main(){
  cin >> N >> W;
  ll w0,v0;
  cin >> w0 >> v0;
  vec_w[0].push_back(v0);
  for(int i=1;i<N;i++){
    ll w,v;
    cin >> w >> v;
    int x=w-w0;
    vec_w[x].push_back(v);
  }
  for(int i=0;i<4;i++){
    sort(vec_w[i].begin(),vec_w[i].end(),greater<ll>());
  }
  for(int i=0;i<4;i++){
    
    vec_w[i].insert(vec_w[i].begin(),0);
  }
  ll v0_s=0,sum=0;
  ll weight=0;
  for(int i=0;i<vec_w[0].size();i++){
    ll v1_s=0;
    v0_s+=vec_w[0][i];
    for(int j=0;j<vec_w[1].size();j++){
      ll v2_s=0;
      v1_s+=vec_w[1][j];
      for(int k=0;k<vec_w[2].size();k++){
	ll v3_s=0;
	v2_s+=vec_w[2][k];
	for(int l=0;l<vec_w[3].size();l++){
	  
	  v3_s+=vec_w[3][l];
	  sum=v0_s+v1_s+v2_s+v3_s;
        
	  weight=w0*i+(w0+1)*j+(w0+2)*k+(w0+3)*l;
	  if(weight<=W)Max=max(Max,sum);
	}
      }
    }
  }
  cout << Max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)
		cout<<0<<endl;
	else
		cout<<min(1ll*a*b,min(1ll*a*c,1ll*b*c))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, m, l, i, t, c;
	scanf("%d%d%d",&n,&m, &l);
	int array[110][110];
	int array2[110][110];
	long int array3[110][110];
	long int sum;

	for(i=0;i<n;i++) {
		for(t=0;t<m;t++) {
			scanf("%d",&array[i][t]);
		}
	}
	for(i=0;i<m;i++) {

		for(t=0;t<l;t++) {
			scanf("%d",&array2[i][t]);

		}
	}
	sum=0;

	for(i=0;i<n;i++) {
		for (c=0;c<l;c++) {
			for(t=0;t<m;t++) {
				sum+=array[i][t]*array2[t][c];

			}
			array3[i][c]=sum;
			printf("%lld",array3[i][c]);
			if(c+1 == l)
        printf("\n");
      else
        printf(" ");
			sum=0;
		}
	}

    
    return 0;
}


Measured memory_bytes: 2104
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

class range {
    struct Iterator {
        int val, inc;
        int operator*() {return val;}
        bool operator!=(Iterator& rhs) {return val < rhs.val;}
        void operator++() {val += inc;}
    };
    Iterator i, n;
    public:
    range(int e) : i({0, 1}), n({e, 1}) {}
    range(int b, int e) : i({b, 1}), n({e, 1}) {}
    range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {}
    Iterator& begin() {return i;}
    Iterator& end() {return n;}
};

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N;
    while(cin >> N) {
        vector<int> v;
        map< pair<int, int>, int> cnt;
        REP(i, N) {
            int x, y, w;
            cin >> x >> y >> w;
            cnt[make_pair(x, y)] += w;
        }

        int max_sum = 0;
        for(auto p : cnt) {
            REP(dy, 2) REP(dx, 2) {
                int bx = p.first.first - dx;
                int by = p.first.second - dy;
                int sum = 0;
                REP(i, 2) REP(j, 2) {
                    auto p = make_pair(bx+i, by+j);
                    if(cnt.count(p)) sum += cnt[p];
                }
                max_sum = max(max_sum, sum);
            }
        }
        cout << max_sum << " / 1" << endl;
    }
    return 0;
}

/* vim:set foldmethod=marker: */

Measured memory_bytes: 7452
#include <stdio.h>
#include <stdlib.h>
long long a(long h, long w, long long m)
{
    long i;
    long long S[3],T[3],x=m;
    for(i=1;i<=h-1;i++){
        S[0]=i*w;
        S[1]=(h-i)*(w/2);
        S[2]=(h-i)*(w-w/2);
        T[0]=llabs(S[0]-S[1]);
        T[1]=llabs(S[1]-S[2]);
        T[2]=llabs(S[0]-S[2]);
        if(T[0]>=T[1] && T[0]>=T[2]) x=T[0];
        else if(T[1]>=T[0] && T[1]>=T[2]) x=T[1];
        else x=T[2];
        if(m>x) m=x;
        S[1]=(h-i)/2*w;
        S[2]=(h-i-(h-i)/2)*w;
        T[0]=llabs(S[0]-S[1]);
        T[1]=llabs(S[1]-S[2]);
        T[2]=llabs(S[0]-S[2]);
        if(T[0]>=T[1] && T[0]>=T[2]) x=T[0];
        else if(T[1]>=T[0] && T[1]>=T[2]) x=T[1];
        else x=T[2];
        if(m>x) m=x;
    }
    return m;
}
int main()
{
    long H,W;
    scanf("%ld %ld",&H,&W);
    if(H*W%3==0) puts("0");
    else printf("%lld\n",a(W,H,a(H,W,H*W)));
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= b&&b <= c){
		cout << a << " " << b << " " << c << endl;
	}
	else if (a <= c&&c <= b){
		cout << a << " " << c << " " << b << endl;
	}
	else if (b <= a&&a <= c){
		cout << b << " " << a << " " << c << endl;
	}
	else if (b <= c&&c <= a){
		cout << b << " " << c << " " << a << endl;
	}
	else if (c <= a&&a <= b){
		cout << c << " " << a << " " << b << endl;
	}
	else cout << c << " " << b << " " << a << endl;
return 0;
}

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

void solve(long long N, long long K)
{
    //int N K
    string ch = "";
    while (N >= K) //N % K != 0)
    {
        ch = to_string(N % K) + ch;
        N /= K;
    }
    //ch = to_string(N % K) + ch;
    //N /= K;
    ch = to_string(N) + ch;
    //cout << ch << endl;
    long long ssize = ch.size();

    cout << ssize << endl;
}

// Generated by 1.1.7.1 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()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


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

int main(){
  string O, E;
  cin>>O>>E;
  int Z=O.size()+E.size();
  for(int i=0; i<Z; i++){
    if(i%2==0) cout<<O.at(i/2);
    else cout<<E.at((i-1)/2);
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if((a+b)%3==0)
    {
        printf("Possible\n");
    }
    else if(a%3==0 || b%3==0)
    {
        printf("Possible\n");
    }
    else
    {
        printf("Impossible\n");
    }
    return 0;
}


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

ll n,k;
int t;
ll m, M;

int main() {
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	cin>> n;

	int d = n % 10;
	if( d == 2 || d == 4 || d == 5 || d == 7 || d == 9 ) {
		cout<<"hon" << endl;
	} else if ( d == 3 ) {
		cout << "bon" <<endl;
	} else {
		cout<< "pon" << endl;
	}
	return 0;

}

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

int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    long long x=n/(a+b);
    long long y=n%(a+b);
    if(y>a){
        y=a;
    }
    cout<<a*x+y<<endl;
    return 0;
}

Measured memory_bytes: 256
/// 5:22 PM 10/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>

using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define VARIABLE_ERROR(x) cout << #x << " = " << x << endl;
#define CONTAINER_ERROR(v) cout << "{";for (auto &x:v) { cout << x << ','; }cout << "}" << endl;
#define PI 3.14159265358979323846
#define M 1000000007
#define INF 1e15
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll n = s.size();
    for(ll i=0;i<n;i++) {
        if(s[i]!=t[i]) {
            cout<<"No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3636
// atcoder/abc172/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  lli a;
  while (cin >> a) {
    cout << a + (a * a) + (a * a * a) << endl;
  }

  return 0;
}


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

typedef long long ll;

// 約数の列挙O(√n)
vector<int> divisor(int n){
    vector<int> res;
    for(int i=1; i*i<=n; i++){
        if(n%i==0){
            res.push_back(i);
            // n の約数が i の時、n/i も n の約数になる
            if(i!=n/i) res.push_back(n/i);
        }
    }
    return res;
}

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

  vector<int> div;
  div = divisor(M);

  int Ma=0;
  for(int i=0; i<div.size(); i++){
    if(div[i]<=(M/N)){
      Ma = max(Ma,div[i]);
    }
  }

  cout << Ma << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
    int i,j;
    int n, m;
    cin >> n >> m;
    vector<pii> v(m);
    rep(i,m) cin >> v[i].second >> v[i].first,v[i].second++;
    sort(all(v));
    int ans = 0;
    int a = -1;
    rep(i,m){
        if(v[i].second > a){
            ans++;
            a = v[i].first;
        }
    }
    cout << ans << endl;
}


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

#define debug(x) cerr << #x << " = " << x << endl

const int N_MAX = 503;
string P[N_MAX], R[N_MAX], B[N_MAX];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    cin >> P[i];
    R[i].resize(W), B[i].resize(W);
    if (i & 1) {
      memset(&R[i][0], '.', W - 1), memset(&B[i][1], '#', W - 1);
      for (int j = 1; j < W - 1; ++j)
        if (P[i][j] == '#')
          R[i][j] = '#';
    }
    else {
      memset(&R[i][0], '#', W - 1), memset(&B[i][1], '.', W - 1);
      for (int j = 1; j < W - 1; ++j)
        if (P[i][j] == '#')
          B[i][j] = '#';
    }
    R[i][0] = B[i][W - 1] = '.';
    R[i][W - 1] = B[i][0] = '#';
  }
  
  for (int i = 0; i < H; ++i)
    cout << R[i] << '\n';
  cout << '\n';
  for (int i = 0; i < H; ++i)
    cout << B[i] << '\n';
  return 0;
}


Measured memory_bytes: 1536
#!/usr/bin/env python3

N,M,X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

B = [0] * (N+1)

for a in A:
    B[a] = 1

print(min(B[:X].count(1), B[X+1:].count(1)))


Measured memory_bytes: 9112
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>

using namespace std;

inline int ctoi(const char c)
{
	return c >= '0'&&c <= '9' ? c - '0' : -1;
}

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

	int res;
	if (k % n == 0) {
		res = 0;
	}
	else {
		res = 1;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n; string s;

void solve()
{
    cin >> n >> s;
    for (int i=0; i<s.size(); i++) {
        int a = s[i] - 'A';
        if (a+n>25) a = n - (25-a) -1;
        else a+=n;
        char k = a+'A';
        cout << k;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long d = n.ToString().Length;
            long ans1 = n / (long)Math.Pow(10, d - 1) + 9 * (d - 1) - 1;
            long ans2 = Ans(n);
            Console.WriteLine(Math.Max(ans1, ans2));
        }
        static long Ans(long n)
        {
            int x = 0;
            for (int i = 0; i < n.ToString().Length; i++)
            {
                x += n.ToString()[i] - '0';
            }
            return x;
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const ll inf = 1LL << 50;
ll dp[2][510][510];
ll A[510][510];

ll pls[510][510];
ll mns[510][510];

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

	rep(i, n)rep(j, n){
		if(i == j) continue;
		cin >> A[i][j];
	}

	rep(i, n){
		rep(j, i){
			if(j - 1 >= 0) pls[i][j] += pls[i][j - 1];
			pls[i][j] += A[i][j];
		}
	}

	rep(i, n){
		rep(j, i){
			if(j - 1 >= 0) mns[i][j] += mns[i][j - 1];
			mns[i][j] += A[j][i];
		}
	}


	const int unused = n;

	rep(i, 2) rep(j, n + 1) rep(k, n + 1) dp[i][j][k] = inf; 
	dp[0][0][unused] = 0;
	int cur = 0, nxt = 1;

	rep(i, n - 1){
		rep(j, n + 1) rep(k, n + 1) dp[nxt][j][k] = inf;

		rep(j, n + 1) rep(k, n + 1){
			if (dp[cur][j][k] == inf) continue;
		
			const int vj = j;
			const int vk = (k != unused) ? k : -1;

			// potential increase
			{
				ll add = 0LL;
				if(vj - 1 >= 0) add += pls[i + 1][vj - 1];
				chmin(dp[nxt][i + 1][j], dp[cur][j][k] + add);
			}

			// do nothing 
			{
				ll add = 0LL;
				add += mns[i + 1][i];
				if(vj - 1 >= 0) add -= mns[i + 1][vj - 1];
				if(vk - 1 >= 0) add += pls[i + 1][vk - 1];
				chmin(dp[nxt][j][k], dp[cur][j][k] + add);
			}
		}

		swap(cur, nxt);
	}

	ll ans = inf;
	rep(j, n + 1) rep(k, n + 1) chmin(ans, dp[cur][j][k]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10368
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
s = s.replace(' ','')
a = list(s.split(','))
n = int(input())
print(a[n-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << 700 + 100 * count(s.cbegin(), s.cend(), 'o') << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mxf=3123;
bool can[mxf];
int main(){
  int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F; 
  set<int>seto;
  for(int c=0;c*C<=F;c++)for(int d=0;c*C+d*D<=F;d++){
    seto.insert(c*C+d*D);
  }

  int ws=100*A,s=0;

  for(int a=0;100*(a*A)<=F;a++)for(int b=0;100*(a*A+b*B)<=F;b++)if(a+b!=0){    
    int to=min((a*A+b*B)*E,F-100*(a*A+b*B));
    auto it=seto.upper_bound(to);
    if(it!=seto.begin()){
      it--;
      int sugar=*it;
      int all=100*(a*A+b*B)+sugar;
      if(sugar*ws>all*s){
        ws=all;
        s=sugar;
      }
    }
  }
  printf("%d %d\n",ws,s);
  return 0;
}


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

int main(int argc, char *argv[]){
  int n, m;
  string s;
  while(std::cin >> n >> m >> s, n){
    string p;
    for (int i = 0; i < n; i++) {
      p += "IO";
    }
    p += "I";
    if(p.length() > s.length()){
      std::cout << 0 << std::endl;
      return 0;
    }
    int ans = 0, pos = 0;
    for (int i = 0; i < s.length(); i++) {
      if(s[i] != p[pos]){
        if(s[i] == 'I')pos = 1;
        else pos = 0;
      }else {
        pos++; 
      }
      if(pos == p.length()){
        ans++;
        i -= p.length() - 1;
        pos = 0;
      }
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2108
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == a[a[i]]) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
	os << '[' << m.first << " " << m.second << ']'; 
	return os; 
}

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

	char ch;
	cin >> ch;

	if (isupper(ch)) cout << 'A' << endl;
	else cout << 'a' << endl;
	
	

	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

void chmin(int&a ,int b){if(a>b) a = b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 1e9;

    auto id = [](char c){
        return c=='R'? 0:1;
    };

    vvec<int> sum(N+1,vec<int>(2));
    for(int i=0;i<N;i++){
        for(int k=0;k<2;k++) sum[i+1][k] = sum[i][k]+(id(S[i])==k);
    }
    vec<int> cnt = {sum[N][0],sum[N][1]};

    for(int i=0;i<=N;i++){
        int r = i-sum[i][0],b = N-i-(cnt[1]-sum[i][1]);
        ans = min(ans,max(r,b));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 14424
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    int sum = 0;
    for(int i = 0; i < N;){
        int now = i;
        int min_f = 1;
        for(int j = now; j < N - 1; j++) {
            if (A[j] >= A[j + 1]) min_f++;
            else break;
        }
        int min_l = 1;
        for(int j = now; j < N - 1; j++){
            if(A[j] <= A[j + 1]) min_l++;
            else break;
        }
        sum++;
        int minin = max(min_f, min_l);
        i+= minin;
    }
    cout << sum << endl;
}

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

int main(){
int H, W;
while(1){
  cin >> H >> W;
  if(H == 0 && W == 0) break;
  for(int i = 0; i < H; i++){
   for(int j = 0; j < W; j++){
    cout << '#';
    }
   cout << endl;
  }
  cout << endl;
 }
return 0;
}


Measured memory_bytes: 3020
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

class Main {
    public static void main(String[] args){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String s=br.readLine();
            String t=br.readLine();
            if(s.equals(t.substring(0,t.length()-1))){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static void dfs(ArrayList<HashSet<Integer>> list,boolean[] vis,int i){
        vis[i]=true;
        Iterator<Integer> it=list.get(i).iterator();
        while(it.hasNext()){
            int u=it.next();
            if(!vis[u]){
                dfs(list,vis,u);
            }
        }
    }
    static int modInverse(int x,int m){
        return power(x,m-2,m);
    }
    static int power(int x, int y, int m)
    {
        if (y == 0)
            return 1;

        long p = power(x, y / 2, m) % m;
        p = (p * p) % m;

        return (int)((y%2==0)? p : (x*p)%m);
    }
    static void shuffle(String[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            String temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static class quad{
        int a,b,c,d;
        public quad(int a,int b,int c,int d){
            this.a=a;
            this.b=b;
            this.c=c;
            this.d=d;
        }
    }
}

Measured memory_bytes: 32692
import java.io.*;
import java.util.*;

class Main{
    void run() throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String[] num = in.readLine().split(" ",0);
            int Ax = Integer.parseInt(num[0]);
            int Ay = Integer.parseInt(num[1]);
            int Bx = Integer.parseInt(num[2]);
            int By = Integer.parseInt(num[3]);
            int Cx = Integer.parseInt(num[4]);
            int Cy = Integer.parseInt(num[5]);
            if(Ax == 0 && Ay == 0 && Bx == 0 && By == 0 && Cx == 0 && Cy == 0)
                break;
            int AbecAx = Bx - Ax;
            int AbecAy = By - Ay;
            int AbecBx = Cx - Ax;
            int AbecBy = Cy - Ay;
            double A = Math.acos((AbecAx * AbecBx + AbecAy * AbecBy) / (Math.sqrt(AbecAx*AbecAx + AbecAy*AbecAy) * Math.sqrt(AbecBx*AbecBx + AbecBy*AbecBy)));
            int BbecAx = Ax - Bx;
            int BbecAy = Ay - By;
            int BbecBx = Cx - Bx;
            int BbecBy = Cy - By;
            double B = Math.acos((BbecAx * BbecBx + BbecAy * BbecBy) / (Math.sqrt(BbecAx*BbecAx + BbecAy*BbecAy) * Math.sqrt(BbecBx*BbecBx + BbecBy*BbecBy)));
            int CbecAx = Bx - Cx;
            int CbecAy = By - Cy;
            int CbecBx = Ax - Cx;
            int CbecBy = Ay - Cy;
            double C = Math.acos((CbecAx * CbecBx + CbecAy * CbecBy) / (Math.sqrt(CbecAx*CbecAx + CbecAy*CbecAy) * Math.sqrt(CbecBx*CbecBx + CbecBy*CbecBy)));
            //????§????????????\???
            double henA = Math.sqrt((Bx - Ax)*(Bx - Ax)+(By - Ay)*(By - Ay));
            double henB = Math.sqrt((Cx - Bx)*(Cx - Bx)+(Cy - By)*(Cy - By));
            double henC = Math.sqrt((Ax - Cx)*(Ax - Cx)+(Ay - Cy)*(Ay - Cy));
            double s = (henA + henB + henC)/2;
            double S = Math.sqrt(s*(s-henA)*(s-henB)*(s-henC));
            double r = S/s;
            //System.out.println("r"+r);

            //r1????±???????
            double r1 = (r*(1+Math.tan(B/4))*(1+Math.tan(C/4)))/(2*(1+Math.tan(A/4)));
            System.out.print(r1+" ");
            double r2 = (r*(1+Math.tan(A/4))*(1+Math.tan(C/4)))/(2*(1+Math.tan(B/4)));
            System.out.print(r2+" ");
            double r3 = (r*(1+Math.tan(B/4))*(1+Math.tan(A/4)))/(2*(1+Math.tan(C/4)));
            System.out.print(r3);
            System.out.println();
        }

    }
    public static void main(String[] args) throws IOException{
        Main ma = new Main();
        ma.run();
    }
}

Measured memory_bytes: 34168
#include <stdio.h>

int check(int *b, int n)
{
    int i;

#if 0
    printf("[");
    for (i = 0; i < n; i++){
        printf("%d ", b[i]);
    }
    printf("]\n");
#endif    
    for (i = 0; i < n; i++){
        if (b[i] != i + 1){
            return (0);
        }
    }
    return (1);
}

int main(void)
{
    int N, n;
    int block[100000];
    int cnt;
    int i, j;
    
    while (1){
        scanf("%d", &N);
        if (N == 0){
            break;
        }

        
        for (i = 0; i < N; i++){
            scanf("%d", &block[i]);
        }
        
        cnt = 0;
        n = N;
        block[n] = 0;
        while (1){
            if (check(block, n) == 1){
                printf("%d\n", cnt);
                break;
            }
            cnt++;
            if (cnt > 10000){
                printf("-1\n");
                break;
            }
            for (n = 0; block[n] != 0; n++);
            block[n] = n;
            block[n + 1] = 0;
            for (i = 0; i < n; i++){
                block[i]--;
            }
            
            for (i = j = 0; i <= n; i++){
                if (block[i] != 0){
                    block[j] = block[i];
                    j++;
                }
            }
            block[j] = 0;
            n = j;
//            for (; j <= n; j++){
//                block[j] = 0;
//            }

        }
    }
    return (0);
}

        
        


Measured memory_bytes: 2120
S = input()

n = len(S)

ans = 0

for i in range(2**(n-1)):
    tmp = ''
    for j in range(n-1):
        tmp += S[j]
        if i & (1 << j):
            tmp += '+'
    tmp += S[-1]
    ans += eval(tmp)


print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

string st[4] = {"AC", "WA", "TLE", "RE"}, S;
int ans[4], N;

int main(){
    cin>>N;
    rep(i,N){
        cin>>S;
        rep(i,4){
            if(st[i]==S){
                ans[i]++;
            }
        }
    }
    rep(i,4){
        cout<<st[i]<<" x "<<ans[i]<<endl;
    }
    
    
}

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

public class Program
{
    static void Main()
    {
        string a = Console.ReadLine();
        string b = Console.ReadLine();
        if (a.Length > b.Length)
            Console.WriteLine("GREATER");
        else if (a.Length < b.Length)
            Console.WriteLine("LESS");
        else
        {
            int result = string.Compare(a, b);
            if (result > 0)
                Console.WriteLine("GREATER");
            else if (result < 0)
                Console.WriteLine("LESS");
            else
                Console.WriteLine("EQUAL");
        }
    }
}

Measured memory_bytes: 13012
use std::vec::Vec;

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

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

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (n, r) = read_touple::<usize>();

    let mut ans = r;
    if n < 10 {
       ans = r + 100 * (10 - n);
    }

    println!("{}", ans);
}



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

using namespace std;
 
 
 
int main(void){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  //cout << K << endl;
  int ans=0;
  if(K<A)
    ans=K;
  else if(K<=A+B)
    ans=A;
  else
    ans=A-(K-A-B);
  cout << ans << endl;
}

Measured memory_bytes: 3676
# AOJ 1007 JPEG Compression

$RIGHT = 0
$DOWN = 1
$LEFT_BELOW = 2
$RIGHT_ABOVE = 3

def scan(n)
  m = Array.new(n) {Array.new(n)}
  x = y = 0
  prev_dir = $RIGHT_ABOVE

  (1..(n * n)).each do |i|
    m[y][x] = i

    case prev_dir
    when $RIGHT
      if y.zero?
        x -= 1
        y += 1
        prev_dir = $LEFT_BELOW
      elsif y == n - 1
        x += 1
        y -= 1
        prev_dir = $RIGHT_ABOVE
      end
    when $DOWN
      if x.zero?
        x += 1
        y -= 1
        prev_dir = $RIGHT_ABOVE
      elsif x == n - 1
        x -= 1
        y += 1
        prev_dir = $LEFT_BELOW
      end
    when $LEFT_BELOW
      if y == n - 1
        x += 1
        prev_dir = $RIGHT
      elsif x.zero?
        y += 1
        prev_dir = $DOWN
      else
        x -= 1
        y += 1
      end
    when $RIGHT_ABOVE
      if x == n - 1
        y += 1
        prev_dir = $DOWN
      elsif y.zero?
        x += 1
        prev_dir = $RIGHT
      else
        x += 1
        y -= 1
      end
    end
  end

  m.each do |row|
    puts row.map {|v| "%3d".%(v)}.join("")
  end
end

i = 0
while true
  i += 1
  n = gets.to_i
  break if n.zero?

  puts "Case #{i}:"
  scan(n)
end

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],k,q,u,v,x,y,tc,c,l,r,ans,p,cnt,root[N],sz[N];

char s[N];

bool ok[N];


set<int> nxt[26];

int main(){
//	#ifndef ONLINE_JUDGE
//		freopen("test.txt","r",stdin);
//	#endif
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++){
		nxt[s[i]-'a'].insert(i+1);
	}
	scanf("%d",&q);
	while(q--){
		int t;
		scanf("%d",&t);
		if (t==1){
			scanf("%d %c",&p,&c);
			nxt[s[p-1]-'a'].erase(p);
			s[p-1]=c;
			nxt[c-'a'].insert(p);
		}
		else{
			scanf("%d%d",&l,&r);
			int ans=0;
			for(int i=0;i<26;i++){
				auto ll=nxt[i].lower_bound(l);
				if (ll!=nxt[i].end() && *ll<=r)
                    ans++;
			}
			printf("%d\n",ans);
		}
	}
}



Measured memory_bytes: 26368
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;




int main()
{
  int n;
  string str ;
  cin >> n >> str ;
  if(n%2==1){cout<<"No"; return 0;}
//   for(int i=0 ; i<n/2 ; i++ ){
//     if(str[i]!=str[i+n/2]) { cout<<"No"; return 0;}
//   }
// cout<<"Yes";
if(str.substr(0,n/2)==str.substr(n/2,n/2))
  cout<<"Yes";
else cout<<"No";

  return 0 ;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    a = [int(x) for x in input().split()]

    if 0 in a:
        ans = 0
    else:
        mx = 10 ** 18
        ans = 1
        for ai in a:
            ans *= ai
            if mx < ans:
                ans = -1
                break
    
    print(ans)

Measured memory_bytes: 87848
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	string s;
	cin >> s;
	for(int i = 0; i < 5; i++){
		cout << s[i];
	}
	cout << " ";
	for(int i = 6; i < 13; i++){
		cout << s[i];
	}
	cout << " ";
	for(int i = 14; i < 19; i++){
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e5 + 10;
vector<int> v;
vector<tuple<int, int, int>> vp;
class SemgentTree
{
public:
	int minv[N * 4];
	int ql, qr, qx;
	void init()
	{
		MEM(minv, 0x3f);
	}
	void set(int l, int r, int x = 1)
	{
		ql = l, qr = r, qx = x;
	}
	void update(int l, int r, int o = 1)
	{
		if (ql <= l && r <= qr)
		{
			minv[o] = min(minv[o], qx);
			return;
		}
		int mid = (l + r) / 2;
		if (ql <= mid) update(l, mid, o << 1);
		if (mid < qr) update(mid + 1, r, o << 1 | 1);
	}
	int query(int l, int r, int o = 1)
	{
		int ret = 0x3f3f3f3f;
		if (l <= ql && qr <= r)
		{
			ret = minv[o];
		}
		if (l == r) return ret;
		int mid = (l + r) / 2;
		if (ql <= mid) ret = min(ret, query(l, mid, o << 1));
		else ret = min(ret, query(mid + 1, r, o << 1 | 1));
		return ret;
	}
} st;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, q;
	cin >> n >> q;
	vp.resize(n);
	v.resize(q);
	st.init();
	for (auto& p : vp)
	{
		int d, x, y;
		cin >> x >> y >> d;
		y--;
		p = make_tuple(x, y, d);
	}
	for (auto& x : v) cin >> x;
	for (auto& p : vp)
	{
		int L, R, d;
		tie(L, R, d) = p;
		L -= d;
		R -= d;
		int l = lower_bound(v.begin(), v.end(), L) - v.begin() + 1;
		int r = upper_bound(v.begin(), v.end(), R) - v.begin() + 1;
		if (l == r) continue;
		r--;
		st.set(l, r, d);
		st.update(1, q);
	}
	for (int i = 1; i <= q; i++)
	{
		st.set(i, i);
		int ans = st.query(1, q);
		if (ans == 0x3f3f3f3f) ans = -1;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
using namespace std;
bool num[10];
int a,b,c,l,n,k;
int main()
{
	cin>>n>>k;
	int cnt=0;
	for(int i=1;i<=k;i++)
    {
        int a;
        cin>>a;
        num[a]=true;
    }
    int i=n;
    for(;;i++)
    {
        int t=i;
        int flog=1;
        for(;t;t/=10)
        {
            if(num[t%10])
            {
                flog=0;
                break;
            }
        }
        if(flog)
            break;
    }
    cout<<i<<endl;
	return 0;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
    bool ret = true;
    if (x < 2) {
        ret = false;
    }
    for (LL i = 2; i <= sqrt(x); i++) {
        if (x%i == 0) {
            ret = false;
        }
    }
    return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    LL n;
    cin >> n;
    string ans = "";
    if (n == 0) {
        cout << 0 << endl;
    }
    else {
        for (LL i = 0;n != 0; i++) {
            int sign = (i % 2) ? -1 : 1;
            if (n % 2) {
                ans.insert(0,"1");
                n -= 1 * sign;
            }
            else {
                ans.insert(0,"0");
            }
            n /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N,K = (int(x) for x in input().split())
P = list(int(x) for x in input().split())

for i in range(N):
    sam = P[i]
    P[i] = (sam+1)/2

total1 = 0

for i in range(K):
    total1 += P[i]

ans = total1
total2 = 0

for i in range(N-K):

    total1 += P[K+i]
    total2 += P[i]
    
    if ans < total1 - total2:
        ans = total1 - total2


print(ans)
    



Measured memory_bytes: 24556
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int count = 0;
        for(int i = 0; i < n -1; i++){
            for(int j = i + 1; j < n; j++){
                count++;
            }
        }
        for(int i = 0; i < m -1; i++){
            for(int j = i + 1; j < m; j++){
                count++;
            }
        }
        System.out.println(count);
        

    }
    
}

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


void solve(std::vector<long long> x, std::vector<long long> y){
  long long myx = x[1] - x[0];
  long long myy = y[1] - y[0];

  cout << (x[1]-myy) << " " << (y[1]+myx) << " " << (x[0]-myy) << " " << (y[0]+myx) << endl;

  return;
}

// 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::vector<long long> x(2);
  std::vector<long long> y(2);
  for(int i = 0 ; i < 2 ; i++){
    scanf("%lld",&x[i]);
    scanf("%lld",&y[i]);
  }
    solve(std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
import java.util.*
import java.math.*
import java.lang.Math.*


val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1e9.toLong()+7
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun solve(X: Int, Y: Int): String {
    for (c in 0..100) {
        for (t in 0..100) {
            if (c == 0 && t == 0) continue
            if (c+t == X && c*2 + t*4 == Y) return "Yes"
        }
    }

    return "No"
}


fun main(args: Array<String>) {
    val (X, Y) = readIntArray()

    val ans = solve(X, Y)

    println(ans)
}


Measured memory_bytes: 36320
s = input()
n = len(s)-1
ans = 0
for i in range(2 ** n):
  op = ["+"] * n
  for j in range(n):
    if ((i>>j)& 1):
      op[n-1-j] = ""
  
  a = ""
  for N,P in zip(s, op+[""]):
    a += N + P
  ans += eval(a)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int A = in(),B = in();
    (A + B) % 2 == 0 ? cout << (A + B) / 2  << "\n": cout << "IMPOSSIBLE" << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int h,n;cin>>h>>n;
  int c=0,a;
  rep(i,n){
    cin>>a;
    c+=a;
  }
  cout<<(c<h?"No":"Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#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, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n)	cin >> a[i];
	sort(a.begin(), a.end());
	int sum = 0;
	rep(i, k)	sum += a[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int a, b;
	cin >> a >> b;

	int sm = a + b;
	if(sm % 2 == 0){
		cout << sm / 2 << endl;
	}else{
		cout << sm / 2 + 1 << endl;
	}
}


Measured memory_bytes: 256