akhauriyash/Code-Regression huggingface dataset:
N=int(input())
scf=[]
for i in range(N-1):
    scf.append(list(map(int,input().split())))

for i in range(N-1):
    t = scf[i][1]+scf[i][0]
    for j in range(i,N-2):
        if t <= scf[j+1][1]:
            t = scf[j+1][1] + scf[j+1][0]
        else:
            #始発より後に到着したら、待つかどうかの判定を行う。
            q = (t-scf[j+1][1]) // scf[j+1][2]
            mod = (t-scf[j+1][1]) % scf[j+1][2]
            if mod == 0:
                t = t + scf[j+1][0]
            else:
                t = scf[j+1][1] + scf[j+1][2] * (q+1) + scf[j+1][0]
    print(t)
print(0)
        

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
using lint=long long;
const int inf=1000000007;
const int MOD=1000000007;
bool judge(vector<int> const& a,lint k,lint fac){
    bool res=true;
    int n=a.size();
    vector<lint> buf(n);
    rep(i,n){
        buf[i]=a[i]%fac;
    }
    sort(buf.begin(),buf.end());
    lint sm=0;
    rep(i,n)sm+=fac-buf[i];
    //sm%=fac;
    lint sa=0;
    rep(i,n){
        sa+=buf[i];
        sm-=fac-buf[i];
        if(sa>=sm&&(sa-sm)%fac==0){
            if(sa<=k)return true;  
        }
    }
    return false;
}
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  lint sm=0;
  rep(i,n)sm+=a[i];
  vector<lint> p;
  lint buf=sm;
  for(int i=1;i<100000;++i){
      if(sm%i==0){
          p.push_back(i);
          p.push_back(sm/i);
      }
  }
  sort(p.begin(),p.end());
  lint res=1;
  for(auto const& val:p){
      if(judge(a,k,val)){
          res=max(res,val);
      }
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3648
S=input()
sum=[0,0,0,0]
for t in range(4):
    for i in range(4):
        if S[int(t)]==S[int(i)]:
            sum[int(i)]+=1
if sum[0] == 2 and sum[1] == 2 and sum[2] == 2 and sum[3] == 2:
    print('Yes')
else:
    print('No')

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

struct node
{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

#define NIL NULL

Node root;

/*
  Node treeMinimum(Node x)
  {


  }

  Node treeMaximum(Node x)
  {


  }

  Node treeSuccessor(Node x)
  {


  }

  void treeDelete(Node z)
  {
  Node y; // node to be deleted
  Node x; // child of y
  }
  Node treeSearch(Node u, int k)
  {


  }
*/
Node treeSearch(Node u, int k)
{
  while((u!=NIL)&&(k!=u->key))
    {
      if(k<u->key)
	{
	  u=u->left;
	}
      else
	{
	  u=u->right;
	}
    }
  return u;
}
void insert(int k)
{
  Node y=NIL;
  Node x=root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while (x!=NIL)
    {
      y=x; // 親を設定
      if (z->key<x->key)
	{
	  x=x->left; // 左の子へ移動
	}
      else
	{
	  x=x->right; // 右の子へ移動
	}
    }
  z->parent=y;
  if (y== NIL)
    {
      // T が空の場合
      root=z;
    }
  else if (z->key<y->key)
    {
      y->left=z; // z を y の左の子にする
    }
  else
    {
      y->right=z; // z を y の右の子にする
    }
}

void inorder(Node u)
{
  if(u==NIL)
    {
      return;
    }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u)
{
  if(u==NIL)
    {
      return;
    }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
    {
      scanf("%s", com);
      if ( com[0] == 'f' )
	{
	  scanf("%d", &x);
	  Node t = treeSearch(root, x);
	  if ( t != NIL ) printf("yes\n");
	  else printf("no\n");
	} 
      else if ( com[0] == 'i' )
	{
	  scanf("%d", &x);
	  insert(x);
	}
      else if ( com[0] == 'p' )
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
    }
  
  return 0;
}
/*
  insert(T, z)
  {
  y = NIL; // x の親
  x = 'T の根';
  while (x ≠ NIL)
  {
  y = x; // 親を設定
  if (z.key < x.key)
  {
  x = x.left; // 左の子へ移動
  else
  {
  x = x.right; // 右の子へ移動
  z.p = y;
  }
  }
  if (y == NIL)
  {
  // T が空の場合
  'T の根' = z;
  }
  else if (z.key < y.key)
  {
  y.left = z; // z を y の左の子にする
  }
  else
  {
  y.right = z; // z を y の右の子にする
  }
  }
  }

  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
  {
  scanf("%s", com);
  if ( com[0] == 'f' )
  {
  scanf("%d", &x);
  Node t = treeSearch(root, x);
  if ( t != NIL ) printf("yes\n");
  else printf("no\n");
  }
  else if ( com[0] == 'i' )
  {
  scanf("%d", &x);
  insert(x);
  }
  else if ( com[0] == 'p' )
  {
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
  }
  else if ( com[0] == 'd' )
  {
  scanf("%d", &x);
  treeDelete(treeSearch(root, x));
  }
  }
 
*/



Measured memory_bytes: 20488
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int s;
   cin >> s;
   set<int> S;
   S.insert(s);
   for(int i=0; i<1000000; i++){
      int n = s%2==0?s/2:3*s+1;
      if(S.find(n)!=S.end()){
         cout << i+2 << endl;
         return 0;
      }
      S.insert(n);
      s=n;
   }
   return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;
fn main() {
    input!{
        s: Chars,
        t: Chars,
    };
    let mut mx = 0;
    for i in 0..=s.len()-t.len() {
        let mut cnt = 0;
        for j in 0..t.len() {
            if s[i+j] == t[j] {
                cnt = cnt + 1;
            }
            // eprint!("{}", s[i+j]);
        }
        if mx < cnt {
            mx = cnt;
        }
        // eprintln!("");
    }
    println!("{}", t.len() - mx);
}

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


int main(){
    long long int i,a,c;
    char op;


    for(i=1;i<=i;i++){
        cin>>a>>op>>c;
        if(op=='+'){
            cout<<a+c;
        }
        else if(op=='-'){
            cout<<a-c;
        }

        else if(op=='*'){
            cout<<a*c;
        }

        else if(op=='/'){
            cout<<a/c;
        }

        else if(op=='?'){
            break;
        }


        cout<<endl;
    }
    return 0;

}



Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <cstring>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define pdd pair<double, double>
#define pid pair<int, double>
#define pdi pair<double, int>
#define hash hash228
const int SZ = 1e5 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 2;
const int inf = 2e9;

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

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

int n;
int a[SZ];

inline void read() {
    cin >> n;
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }
}

inline void solve() {
    if (a[0]) {
        if (n == 0 && a[0] == 1) {
            cout << 1 << "\n";
        } else {
            cout << -1 << "\n";
        }
        return;
    }
    if (n == 0 && a[0] == 0) {
        cout << -1 << "\n";
        return;
    }
    vector<int> pref(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        pref[i] = pref[i - 1] + a[i];
    }
    int x = 1;
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans += x;
        x -= a[i];
        if (x < 0) {
            cout << -1 << "\n";
            return;
        }
        x = min(x * 2, pref[n] - pref[i]);
    }
    cout << ans << "\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
    read();
    solve();
//    }

    return 0;
}

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

int main(){
    int n;
    long long q,k;
    long long a[110000];
    long long bak[110000] = {0};
    cin >> n >> k >> q;
    for(int i = 0; i < q;i++) cin >> a[i] ;

    for(long long i = 0; i < q; i++){
        bak[a[i]]++;
    }

    for(long long i = 1; i <= n; i++){
        if(bak[i] <= q - k) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

}

Measured memory_bytes: 2304
import java.util.*

/**
 * Created by Shadab on 26-Nov-17.
 */
fun main(args: Array<String>){

    //Generating Lucas numbers array.
    var lucas: Array<Long?> = kotlin.arrayOfNulls<Long>(87)

    lucas.set(0, 2)
    lucas.set(1, 1)

    for (i in 2..86) {
        var total = lucas.get(i - 1) as Long + lucas.get(i - 2) as Long
        lucas.set(i, total)
    }

    //taking user input for Lucas number position
    var sc =  Scanner(System.`in`)

    while(sc.hasNext()) {

        var n = sc.nextInt();
        println(lucas.get(n))
    }

}


Measured memory_bytes: 31380
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int A, B;
	cin >> A >> B;
	if (A <= 9 && B <= 9) cout << A * B << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int X = max(A, B);
  int Y = min(A, B);
  int Z = 0;
  int c = 0;
  rep(i, Y) {
    c++;
    Z += X;
    if(Z >= C) {
      break;
    }
  }
  cout << c << endl;
}
    

Measured memory_bytes: 3644
using System;

class Program{
    static int[] preorder, inorder, positions;

    static void Reconstruct(int leftLimPre, int rightLimPre,
            int leftLimIn, int rightLimIn, bool isPrintSpace){
        int root=preorder[leftLimPre];
        int rootPos=positions[root-1];
        int numLeft=rootPos-leftLimIn;
        int numRight=rightLimIn-rootPos;
        if(numLeft>0){
            Reconstruct(leftLimPre+1, leftLimPre+numLeft,
                    leftLimIn, rootPos-1, isPrintSpace);
            isPrintSpace=true;
        }
        if(numRight>0){
            Reconstruct(rightLimPre-numRight+1, rightLimPre,
                    rootPos+1, rightLimIn, isPrintSpace);
            isPrintSpace=true;
        }
        if(isPrintSpace){
            Console.Write(" ");
        }
        Console.Write(root);
    }

    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        preorder=new int[n];
        inorder=new int[n];
        positions=new int[n];
        var s=Console.ReadLine().Split(' ');
        for(var i=0; i<n; i++){
            preorder[i]=int.Parse(s[i]);
        }
        s=Console.ReadLine().Split(' ');
        for(var i=0; i<n; i++){
            inorder[i]=int.Parse(s[i]);
            positions[inorder[i]-1]=i;
        }

        Reconstruct(0, n-1, 0, n-1, false);
        Console.WriteLine();
    }
}

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 998244353
using namespace std;
vector<string> str;
int m;
string al = "abcdefghijklmnopqrstuvwxyz";
void dfs(string s, int n) {
    // cout << "hidfso" << endl;
    if(s.size() == m) {
        str.push_back(s);
        return;
    } else {
        set<char> st;
        for(auto e : s) {
            st.insert(e);
        }
        for(auto e : st) {
            string t = s;
            t.push_back(e);
            dfs(t, n + 1);
        }
        string tmp = s;
        tmp.push_back(al[st.size()]);
        dfs(tmp, n + 1);
    }
}
int main() {
    cin >> m;
    string emp;
    dfs(emp, 0);
    sort(all(str));
    for(auto e : str) {
        cout << e << endl;
    }
}

Measured memory_bytes: 9588
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		System.out.println((int) (n + Math.pow(n, 2) + Math.pow(n, 3)));

	}

}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  map<ll, ll> v;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    v[tmp]++;
  }
  for (int i = 0; i < m; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    v[tmp2] += tmp1;
  }
  ll res = 0;

  ll count = 0;
  ll before = 0;
  auto i = v.rbegin();
  for( ; i != v.rend() ; ++i ){
    before = count;
    count += i->second;
    if(count <= n){
      res += i->first * i->second;
    }else{
      res += i->first * (n - before);
      break;
    }
  }

  cout << res << endl;




}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  string s,t;
  cin >> n >> m >> s >> t;
  ll d=n/__gcd(n,m)*m;
  ll x=d/n,y=d/m;
  for(ll i=0,j=0; i<n; i+=y,j+=x) {
    if(s[i]!=t[j]) {
      pr(-1);
      return;
    }
  }
  pr(d);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<P> v;
  rep(i,n) {
    int a,b;
    cin>>a>>b;
    v.emplace_back(a,b);
  }
  sort(v.begin(),v.end());
  priority_queue<int> pq;
  int i=0;
  int ans=0;
  for (int day=1; day<=m; day++) {
    while (v[i].first==day) {
      pq.push(v[i].second);
      i++;
    }
    if (!pq.empty()) {
      ans+=pq.top();
      pq.pop();
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1908
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
vector<int>atu;
int scan(void){int h,m;cin>>h>>m;atu.pub(h*60+m);return h*60+m;}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,T,h,i,j;cin>>n>>m>>T;
	llint balls[17][1000];//合計
	for(h=0;h<=16;h++){
		for(i=0;i<T;i++){balls[h][i]=-big;}
	}
	balls[0][0]=0;
	for(i=0;i<n;i++){
		llint a;cin>>a;
		maxeq(balls[0][a%T],a);
	}
	for(h=1;h<=16;h++){
		for(i=0;i<T;i++){
			for(j=0;j<T;j++){
				maxeq(balls[h][(i+j)%T],balls[h-1][i]+balls[h-1][j]);
			}
		}
		//for(i=0;i<T;i++){cerr<<balls[h][i]<<" ";}cerr<<endl;
	}
	llint kei[1000];
	for(i=0;i<T;i++){kei[i]=-mod;}
	kei[0]=0;
	for(h=0;h<=16;h++){
		if(!(m&(1<<h))){continue;}
		llint ata[1000];
		for(i=0;i<T;i++){ata[i]=-mod;}
		for(i=0;i<T;i++){
			for(j=0;j<T;j++){
				maxeq(ata[(i+j)%T],kei[i]+balls[h][j]);
			}
		}
		swap(ata,kei);
	}
	for(i=T-1;i>0;i--){maxeq(kei[i-1],kei[i]-1);}
	
	int Q;cin>>Q;
	while(Q--){
		llint A,B;cin>>A>>B;
		cout<<(kei[A]>=(B*T+A)?"yes":"no")<<endl;
	}
	return 0;
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	long double a, b, c;
	cin >> a >> b >> c;
	long double eps = 1.0E-14;
	if (sqrt(a) + sqrt(b) + eps < sqrt(c))
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;

char s[1000];

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	if (n & 1) return printf("No\n"), 0;
	for (R int i = 1; i <= n; i += 2)
		if (s[i] != 'h' || s[i + 1] != 'i') return printf("No\n"), 0;
	printf("Yes\n");
	return 0;
}

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

int main() {
    long long n,a,b[200001],c=0,d=1;
    cin>>n;
    b[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a;
        b[i]=b[i-1]+a;
    }
    sort(b,b+n+1);
    for(int i=1;i<=n;i++){
        if(b[i]==b[i-1]){
            d++;
            if(i==n){
                c+=d*(d-1)/2;
            }
        }else{
            c+=d*(d-1)/2;
            d=1;
        }
    }
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

typedef pair<int, int> PII;
int main(int argc, char const *argv[])
{
    int h, w;
    cin >> h >> w;
    vector<PII> v;
    rep(i, h)
    {
        int t;
        cin >> t;
        v.push_back({t, 0});
    }
    rep(i, w)
    {
        int t;
        cin >> t;
        v.push_back({t, 1});
    }
    sort(ALL(v));
    ll a = w + 1;
    ll b = h + 1;
    ll ans = 0;
    int i = 0;
    rep(i, h + w)
    {
        cerr << i << endl;
        auto t = v[i];
        if (t.second == 0)
        {
            ans += a * t.first;
            b--;
        }
        else
        {
            ans += b * t.first;
            a--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

# C - management
N = int(input())
A = list(map(int, input().split()))
dic = dict()

for i in range(1, N + 1):
	dic[i] = 0

for a in A:
	dic[a] += 1

for v in dic.values():
	print(v)

Measured memory_bytes: 121592
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToArray();
        var A = line[0];
        var B = line[1];
        var C = line[2];
        var D = line[3];
        var E = line[4];
        var F = line[5];

        var waterAmax = F / (A * 100);

        decimal max = -1;
        decimal maxSugarWater =0;
        decimal maxSugar = 0;
        for (int i = 0; i <= waterAmax; ++i)
        {
            var bCount = (F - (A * i * 100)) / (B * 100);
            for (int j = 0; j <= bCount; ++j)
            {
                if (i == 0 && j == 0) continue;
                if (F < (A * i + B * j) * 100) break;
                var cCount = (F - (A * i * 100 + B * j * 100)) / C;
                for (int k = 0; k < cCount; ++k)
                {
                    if (F < (A * i + B * j) * 100 + C * k) break;
                    var dCount = (F - ((A * i * 100 + B * j * 100) + C)) / D;
                    for (int l = 0; l < dCount; ++l)
                    {
                        if (F < (A * i + B * j) * 100 + C * k + D * l) break;
                        if ((C * k + D * l) <= (i*A + j*B) * E)
                        {
                            var sugarWater = (A * i)*100 + (B * j)*100 + C * k + D * l;
                            var sugar = C * k + D * l;
                            var concentration = sugar == 0 ? 0 : sugar / sugarWater * 100;
                            if (max < concentration)
                            {
                                max = concentration;
                                maxSugarWater = sugarWater;
                                maxSugar = sugar;
                            }
                        }
                    }

                }
            }
        }
        Console.WriteLine($"{maxSugarWater} {maxSugar}");
    }
}

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

int main(){
    string str,str2;
    int n=0;
    cin>>str>>n;
    
    for(int i=0;i<n;i++){
        string str3;
        int x=0;
        int y=0;
        cin>>str2;
        if(str2 == "print"){
            cin>>x>>y;
            cout<<str.substr(x,y - x + 1)<<endl;
        }
        else if(str2 == "reverse"){
            cin>>x>>y;
            for(int j=0;j<=y - x;j++){
                str3 += str[y - j];
            }
            str.replace(x,y - x + 1,str3);
            
        }
        else if(str2 == "replace"){
            cin>>x>>y>>str3;
            str.replace(x,y - x + 1,str3);
        }
    }
    return 0;
}


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

int main() {

  int N;
  cin >> N;
  
  int answer = 0;

  for (int i = 1; i <= N; i++) {
    if (i <= 9) {
      answer++;
    } else if (100 <= i && i <= 999) {
      answer++;
    } else if (10000 <= i && i <= 99999) {
      answer++;
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
x=int(input())
if(x>=400 and x<=599):
    print(8)
if(x>=600 and x<=799):
    print(7)
if(x>=800 and x<=999):
    print(6)
if(x>=1000 and x<=1199):
    print(5)
if(x>=1200 and x<=1399):
    print(4)
if(x>=1400 and x<=1599):
    print(3)
if(x>=1600 and x<=1799):
    print(2)
if(x>=1800 and x<=1999):
    print(1)

Measured memory_bytes: 9164
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int N,M;
cin>>N>>M;
int m[N+1];
memset(m,0,sizeof(m));
rep(i,M){
    int a,b;
    cin>>a>>b;
    m[a]++;
    m[b]++;
}
rep3(i,N){
    cout<<m[i]<<endl;
}


return 0;
}

Measured memory_bytes: 3612
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
X.sort(key=lambda x: x[1])

bdg = -1
cnt = 0
for a, b in X:
    if a > bdg:
        bdg = b - 1
        cnt += 1
        
print(cnt)






Measured memory_bytes: 29084
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>

using namespace std;

#define int long long

signed main() {
    int l;
    cin >> l;
    double ans = pow((l / 3.0), 3);

    cout << setprecision(8) << ans << endl;
    
    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int TC;
    cin >> TC;
    while (TC--) {
        int N;
        cin >> N;
        V<int> K(N), L(N), R(N);
        V<tuple<int, int, int>> vl, vr;
        ll ans = 0;

        rep(i, N) {
            cin >> K[i] >> L[i] >> R[i];
            ans += min(L[i], R[i]);
            if (L[i] >= R[i]) {
                vl.eb(K[i], L[i], R[i]);
            } else {
                vr.eb(N - K[i], R[i], L[i]);
            }
        }

        auto calc = [](V<tuple<int, int, int>>& vec) {
            int sz = vec.size();
            sort(ALL(vec));
            reverse(ALL(vec));

            ll res = 0;
            int p = 0;
            priority_queue<ll> que;

            for (int i = sz; i >= 1; --i) {
                while (p < sz) {
                    int k, l, r;
                    tie(k, l, r) = vec[p];
                    if (k >= i) {
                        que.push(l - r);
                        p++;
                    } else {
                        break;
                    }
                }
                if (que.size()) {
                    res += que.top();
                    que.pop();
                }
            }
            return res;
        };

        ans += calc(vl) + calc(vr);
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 9828
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

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

    if (b == "A")
        cout << "T" << endl;
    if (b == "T")
        cout << "A" << endl;
    if (b == "C")
        cout << "G" << endl;
    if (b == "G")
        cout << "C" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;

string T, P;
int lenP;

void store() {
    cin >> T >> P;
    lenP = P.length();
}

void solve() {
    for (int i = 0; i < T.length() - lenP + 1; i++) {
        if (T.substr(i, lenP) == P) {
            cout << i << endl;
        }
    }
}

int main() {
    store();
    if (T.length() < lenP) {
        return 0;
    }

    solve();

    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y,a,b;
    cin >> x >> y;
    if( x < y ){cout << "a < b" <<endl;}
    else if( x > y){cout << "a > b" <<endl;}
    else {cout << "a == b"<<endl;}
    return 0;
}


Measured memory_bytes: 3104
import heapq
def main():
  N, M = list(map(int, input().split()))
  jobs = [[] for _ in range(M)]
  for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
      jobs[d-1].append(-r)

  m = 0
  heap = []
  for i in range(M):
    for a in jobs[i]:
      heapq.heappush(heap, a)
    if len(heap) > 0:
      b = heapq.heappop(heap)
      m += -b
  print(m)
if __name__ == '__main__':
  main()


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

int main()
{
  ll h;
  ll a=1;
  ll count=0;

  cin>>h;
  while(true){
    if(h==0) break;
    count+=a;
    h/=2;
    a*=2;
  }

  cout<<count<<endl;
 
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] V = new int[N];
        for (int i = 0; i < N; i++) {
            V[i] = scan.nextInt();
        }
        int max_answer = Integer.MIN_VALUE;
        for (int i = -1; i < N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (K < i + N - j + 1) {
                    continue;
                }
                List<Integer> data = new ArrayList<>();
                for(int k = 0; k <= i; k++) {
                    if (0 <= k) {
                        data.add(V[k]);
                    }
                }
                for(int k = j; k < N; k++) {
                    data.add(V[k]);
                }
                data.sort(Comparator.naturalOrder());
                int answer = 0;
                int length = data.size();
                for (int k = 0; k < length; k++) {
                    answer += data.get(k);
                }
                if (0 < K - i - (N - j + 1)) {
                    for (int k = 0; k < K - i - (N -j + 1) && k < length; k++) {
                        int x = data.get(k);
                        if (0 <= x) {
                            continue;
                        }
                        answer -= x;
                    }
                }
                max_answer = Math.max(max_answer, answer);
            }
        }
        System.out.println(max_answer);

    }
}



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	sort(all(a));
	const int MX = a.back();
	VI ck(MX+100);
	rep2(i, 2, MX+1){
		rep(j, n){
			if((ll)a[j]*i > MX) break;
			ck[a[j]*i ]++;
		}
	}
	rep(i, n-1) if(a[i] == a[i+1]) ck[a[i]]++;

	int ans =0;
	rep(i, n) if(ck[a[i]]==0) ans++;
	cout <<ans <<'\n';
	return 0;
}


Measured memory_bytes: 7896
#include<iostream>
#include<string>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::string;

int main(){
    bool b=true;
    long long int max = 1e+18;
    int n;
    long long int *a,out=1;
    cin >> n;
    a = new long long int[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i] == 0){       //0がある->無条件で0
            cout << 0;
            b = false;
            break;
        }
    }
    if(b){
        for(int i=0;i<n;i++){
            if(a[i] > max/out){
                b = false;
                cout << "-1";
                break;
            }
            out *= a[i];
        }
    }
    if(b) cout << out;
}

Measured memory_bytes: 4372
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 1010;
const LL Mod = 1e9+7;
struct matrix {
	LL a[2][2], l1, l2;
	void clear() { memset(a, 0, sizeof(a)); }
}x, z;
char s[Maxn][Maxn];
LL n, m, K;
LL qpow(LL x, LL k) {
	LL ret = 1;
	while(k){
		if(k&1) ret = ret*x%Mod;
		x = x*x%Mod;
		k >>= 1;
	}
	return ret;
}
matrix ttimes(matrix x, matrix y) {
	matrix ret;
	ret.l1 = x.l1; ret.l2 = y.l2;
	ret.clear();
	for(LL i = 0; i < ret.l1; i++){
		for(LL j = 0; j < ret.l2; j++){
			for(LL k = 0; k < x.l2; k++) ret.a[i][j] = (ret.a[i][j]+x.a[i][k]*y.a[k][j])%Mod;
		}
	}
	return ret;
}
int main() {
	LL i, j, k;
	scanf("%lld%lld%lld", &n, &m, &K);
	LL sr = 0, sc = 0, sum = 0;
	for(i = 1; i <= n; i++){
		scanf("%s", s[i]+1);
		for(j = 1; j <= m; j++) sum += s[i][j] == '#';
	}
	for(i = 1; i <= n; i++) if(s[i][1] == '#' && s[i][m] == '#') sr++;
	for(i = 1; i <= m; i++) if(s[1][i] == '#' && s[n][i] == '#') sc++;
	if(sr && sc) printf("1\n");
	else if(!sr && !sc) printf("%lld\n", qpow(sum, K-1));
	else if(sr){
		LL ss = 0;
		for(i = 1; i <= n; i++){
			for(j = 1; j < m; j++) if(s[i][j] == '#' && s[i][j+1] == '#') ss++;
		}
		x.l1 = x.l2 = 2;
		x.a[0][0] = sr; x.a[0][1] = Mod-1; x.a[1][1] = sum;
		z.l1 = z.l2 = 2;
		z.a[0][0] = z.a[1][1] = 1;
		K--;
		while(K){
			if(K&1) z = ttimes(z, x);
			x = ttimes(x, x);
			K >>= 1;
		}
		printf("%lld\n", (z.a[1][1]+ss*z.a[0][1])%Mod);
	} else {
		LL ss = 0;
		for(i = 1; i < n; i++){
			for(j = 1; j <= m; j++) if(s[i][j] == '#' && s[i+1][j] == '#') ss++;
		}
		x.l1 = x.l2 = 2;
		x.a[0][0] = sc; x.a[0][1] = Mod-1; x.a[1][1] = sum;
		z.l1 = z.l2 = 2;
		z.a[0][0] = z.a[1][1] = 1;
		K--;
		while(K){
			if(K&1) z = ttimes(z, x);
			x = ttimes(x, x);
			K >>= 1;
		}
		printf("%lld\n", (z.a[1][1]+ss*z.a[0][1])%Mod);
	}
	return 0;
}

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

int main() {

	int n;
	cin >> n;
	vector<int> R;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		R.push_back(tmp);
	}

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,k;
  cin >> a >> b >> k;
  if(b-a<=k){
    for(int i=a;i<= b;i++){
      cout << i <<endl;
    }
  }else{
    for(int i=a;i<a+k;i++){
      cout << i <<endl;
    }
    if(a+k-1<b-k+1){
      for(int i=b-k+1;i<=b;i++){
        cout << i <<endl;
      }
    }else{
      for(int i=a+k;i<=b;i++){
        cout << i <<endl;
      }
    }
  }
}




Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        final int M = sc.nextInt();

        int[] num = new int[N];
        for (int i = 0; i < num.length; i++) {
            num[i] = -1;
        }
        if (M == 0 && N == 1) {
            System.out.println(0);
            return;
        } else if (M != 0) {
            for (int i = 0; i < M; i++) {
                int keta = sc.nextInt() - 1;
                int value = sc.nextInt();
                if (num[keta] != -1 && num[keta] != value) {
                    System.out.println(-1);
                    return;
                } else if (keta == 0 && value == 0 && N != 1) {
                    System.out.println(-1);
                    return;
                }
                num[keta] = value;
            }
            sc.close();
        }

        for (int i = 0; i < num.length; i++) {
            if (num[i] == -1) {
                if (i == 0)
                    num[i] = 1;
                else
                    num[i] = 0;
            }
            System.out.print(num[i]);
        }

        System.out.println();
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <bits/stdc++.h>
#include <set>
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define vii vector<pair<int, int> >
#define si stack<int>
#define pb push_back
#define mp make_pair
#define ALL(T) (T).begin(), (T).end()
#define MODU 1000000007
typedef long long ll;
using namespace std;

ll intmax = (1LL<<32)-1;
ll llmax = (1LL<<60)-1;

const int INF = 1e9 + 5;

class fastio{
public:
	fastio(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	}
} __fastio;

template <typename T>
T abs(T x){
	if(x < 0) return -x;
	else return x;
}

void DFSVisit(int u, vector<int> g[], vector<bool> &visited){
    visited[u] = true;
    for(int i=0; i<(int)g[u].size(); i++){
        if(!visited[g[u][i]]){
            DFSVisit(g[u][i], g, visited);
        }
    }
}

void DFS(vector<int> adj[], int V){
    vector<bool> visited(V, false);
    for(int u=0; u<V; u++)
        if(!visited[u])
            DFSVisit(u, adj, visited);
}

template <typename T>

void swap(T &a, T &b){
	T temp;
	temp = a;
	a = b;
	b = temp;
}


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	int v = 1;
	int brk = 0;
	for(int i=0; i<n; i++) {
		if(a[i] != v) {
			brk++;
		}
		else {
			v++;
		}
	}
	if(brk == n) {
		cout << -1;
	}
	else {
		cout << brk;
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<string>
using namespace std;

int main(){
    int a , b;
    cin >> a >> b;

    if(a <= b){
        cout<<a;
    }else{
        cout<<(a-1);
    }
    cout<<endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    D_c=Counter(D)
    M=int(input())
    T=[int(_) for _ in input().split()]
    T_c=Counter(T)
    for t in T_c.items():
        if D_c[t[0]]<t[1]:
            print("NO")
            break
    else:
        print("YES")

if __name__=='__main__':
    main()

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

#define INF 10000000

// 0: cost , 1 :time
int d[2][101][101];


int main() {
    int n, m, a, b, cost, time, k, p, q, r, i, j;

    while ((cin >> n >> m) && n) {
        for (i = 1; i <= m; i++) {
            for (j = 1; j <= m; j++) {
                d[0][i][j] = d[1][j][i] = INF;
            }
        }
        for (i = 0; i < n; i++) {
            cin >> a >> b >> cost >> time;
            d[0][a][b] = d[0][b][a] = cost;
            d[1][a][b] = d[1][b][a] = time;
        }

        for (k = 1; k <= m; k++) {
            for (i = 1; i <= m; i++) {
                for (j = 1; j <= m; j++) {
                    for (r = 0; r < 2; r++) {
                        if (d[r][i][j] > d[r][i][k] + d[r][k][j]) {
                            d[r][j][i] = d[r][i][j] = d[r][i][k] + d[r][k][j];
                        }
                    }
                }
            }
        }

        cin >> k;
        while (k--) {
            cin >> p >> q >> r;
            cout << d[r][p][q] << endl;
        }
    }
    
    return 0;
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 200*1000+10;
int cur, n, k, a[maxn], ted, p;
vector<pair<int,int>> vec[2];
bool dif;

int main()
{
    ios::sync_with_stdio(0);
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++)
    {
       scanf("%d", &a[i]);
       vec[0].pb({i - a[i], 1});
       vec[0].pb({i + a[i] + 1, -1});
    }
    vec[0].pb({n, 0});
    for (int j = 0; j < k; j++)
    {
        dif = 0;
        cur ^= 1;
        ted = 0;
        p = 0;
        vec[cur].clear();
        sort(all(vec[cur ^ 1]));
        for (auto &w : vec[cur ^ 1])
        {
            while (p < min(n, w.first))
            {
                if (a[p] != ted)
                    dif = 1;
                a[p] = ted;
                vec[cur].pb({p - a[p], 1});
                vec[cur].pb({p + a[p] + 1, -1});
                p++;
            }
            ted += w.second;
        }
        if (!dif)
            break;
    }
    for (int i = 0; i < n; i++)
        printf("%d ", a[i]);
	return 0;
}


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

using namespace std;

string s[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

int main() {
    string cur;
    cin >> cur;
    int res = -1;
    for (int i = 0; i < 7; i++) {
        if (s[i] == cur) {
            res = i;
            break;
        }
    }
    if(res == 6) res = 7;
    else res = 7 - res - 1;
    printf("%d\n", res);
}


Measured memory_bytes: 256
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    cout << fixed << setprecision(15);
    cout << sqrt(A * A + B * B - 2.0 * A * B * cos((double)(abs(((H * 60.0 + M) / 720.0) - M / 60.0) * 2.0 * acos(-1))));
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

int kai(int n){
  int s=1;
  for(int i=0;i<n;i++){
    s*=(i+1);
  }
  return s;
}

int index(vector<int> a,int b){
 	for(int i=0;i<a.size();i++){
     	if(a.at(i)==b){
         return i;
        }
    }
  	return -1;
}

int main() {
  int N;
  cin>>N;
  int p=0,q=0;
  vector<int> P(N),Q(N);
  vector<int> PP={1,2,3,4,5,6,7,8};
  vector<int> QQ={1,2,3,4,5,6,7,8};
  
  for(int i=0;i<N;i++){
   	cin>>P.at(i);
  }
  
  for(int i=0;i<N;i++){
   	cin>>Q.at(i); 
  }
  
  for(int i=0;i<N;i++){
   	p+=kai(N-i-1)*(index(PP,P.at(i)));
    PP.erase(PP.begin()+index(PP,P.at(i)));
  }
  for(int i=0;i<N;i++){
   	q+=kai(N-i-1)*(index(QQ,Q.at(i)));
    QQ.erase(QQ.begin()+index(QQ,Q.at(i)));
  }
  
  	if(p<q){
  		cout<<q-p<<endl;
    }
  	else{
     	cout<<p-q<<endl; 
    }
  
 
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll D[101010];
pair<ll,int> P[101010];
int num[101010],par[101010];
ll DS[101010];
vector<pair<int,int>> E;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>D[i];
		P[i]={D[i],i+1};
	}
	sort(P,P+N);
	sort(D,D+N);
	
	for(i=N-1;i>=1;i--) {
		num[i]++;
		ll sj=D[i]+2*num[i]-N;
		x=lower_bound(D,D+N,sj)-D;
		if(x>=i || D[x]!=sj) return _P("-1\n");
		E.push_back({x,i});
		num[x]+=num[i];
		DS[x]+=DS[i]+num[i];
		par[i]=x;
	}
	if(DS[0]!=D[0]) return _P("-1\n");
	
	FORR(e,E) cout<<P[e.first].second<<" "<<P[e.second].second<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6260