akhauriyash/Code-Regression huggingface dataset:
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
a,b = gets_i_list

puts a*b

Measured memory_bytes: 14580
#include<bits/stdc++.h>
#define N 223456
using namespace std;
typedef long long ll;
ll dp[100];
int main()
{
//    freopen("in.txt","r",stdin);
    ll n;
    string ans="";
    cin>>n;
    while(n)
    {
        n--;
        ans += 'a' + (n%26);
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
#define inf 1e18
using ll = long long;
using namespace std;

int main(){
  ll N,M,L; cin >> N >> M >> L;
  ll a,b,c;
  vector<vector<ll>> dist(N,vector<ll>(N, inf));
  rep(i,N) dist[i][i] = 0;
  rep(i,M){
    cin >> a >> b >> c;
    a--; b--;
    // if(c > L) continue;
    dist[a][b] = dist[b][a] = c;
  }
  rep(k,N) rep(i,N) rep(j,N) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  vector<vector<ll>> g(N,vector<ll>(N, inf));
  rep(i,N) rep(j,N){
    if(dist[i][j] <= L){
      g[i][j] = 1;
    }
  }
  rep(k,N) rep(i,N) rep(j,N) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  int Q; cin >> Q;
  ll s,t;
  rep(i,Q){
    cin >> s >> t;
    s--; t--;
    ll ans = g[s][t];
    if(ans >= mod) ans = 0;
    cout << ans-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d,sign=1;
    cin>>a>>b>>c>>d;
    while(1){
        if(sign==1){
            sign=0;
            c-=b;
        }
        else{
            sign=1;
            a-=d;
        }
        if(a<=0 || c<=0) break;
    }
    if(sign==1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a.at(i);
    int cnt_4 = 0;
    int cnt_odd = 0;
    rep(i,N) {
        if (a.at(i) % 4 == 0) ++cnt_4;
        else if (a.at(i) % 2 == 1) ++ cnt_odd;
    }
    if (cnt_4 >= cnt_odd
    || (cnt_4 + cnt_odd == N && cnt_4 + 1 == cnt_odd)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

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

}


Measured memory_bytes: 3668
n, m = map(int, input().split())
xli = list(map(int, input().split()))

ans = 0
if n < m:
    xli.sort()
    wli = list()
    for i in range(len(xli)-1):
        wli.append(xli[i+1]-xli[i])
    sortWli = list(reversed(sorted(wli)))
    su = 0
    for i in range(n-1):
        su += sortWli[i]
    ans = xli[-1] - xli[0] - su
print(ans)

Measured memory_bytes: 58408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vii dp(N,vi(3));
  vii A(N,vi(3));
  rep(i,0,N){
    rep(j,0,3) cin>>A[i][j];
  }
  rep(i,0,3) dp[0][i]=A[0][i];
  rep(i,1,N){
    rep(j,0,3){
      if(j==0){
        dp[i][j]=max(dp[i-1][1],dp[i-1][2])+A[i][j];
      }
      else if(j==1){
        dp[i][j]=max(dp[i-1][0],dp[i-1][2])+A[i][j];
      }
      else{
        dp[i][j]=max(dp[i-1][1],dp[i-1][0])+A[i][j];
      }
    }
  }
  int ans=0;
  rep(i,0,3) ans=max(ans,dp[N-1][i]);
  cout<<ans<<endl;
  }


Measured memory_bytes: 11136
#include <iostream>

int main() {
	int i ;
	std::cin >> i;
	switch(i%10){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			std::cout << "hon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			std::cout << "pon";
			break;
		case 3:
			std::cout << "bon";
			break;
	}
	return 0;
}              

Measured memory_bytes: 3628
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
        int N;

        scanf("%d", &N);

        vector<int> A(N+2);

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

        int T=0;
        int p=0;

        for(int i=0; i<N+2; i++) {
                T += abs(p-A[i]);
                p = A[i];
        }

        cerr << "T" << T << endl;

        for(int i=1; i<N+1; i++) {
                printf("%d\n", T - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]));
        }

}

Measured memory_bytes: 1664
#include<stdio.h>

#define MAX 100

int main() {
    //変数の宣言
    int a[MAX], b[MAX];
    char op[MAX]; //演算子
    int i=0, j, x[MAX]; //処理用
    
    //入力
    while (1) {
        scanf("%d %c %d", &a[i], &op[i], &b[i]);
        
        //判定
        if (op[i] == '+') {
            x[i] = a[i] + b[i];
        }else if (op[i] == '-') {
            x[i] = a[i] - b[i];
        }else if (op[i] == '*') {
            x[i] = a[i] * b[i];
        }else if (op[i] == '/') {
            x[i] = a[i] / b[i];
        }else{
            break;
        }
        
        i++; //カウント
    }
    
    //出力
    for (j=0; j<i; j++) {
        printf("%d\n", x[j]);
    }
    
    
    return 0;
}



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

int main() {
    // long long N, M, A, B, C;
    // cin >> N >> M >> A >> B >> C;

    long long N, M, A = 10000, B = 5000, C = 1000;
    cin >> N >> M;

    for (long long a = 0; a <= N; a++) {
        long long bmin = 0;
        long long bmax = N - a;
        while (bmax - bmin > 1) {
            long long bmid = (bmax + bmin) / 2LL;
            if (A * a + B * (bmid) + C * (N - a - bmid) >= M) {
                bmax = bmid;
            } else {
                bmin = bmid;
            }
        }
        if (A * a + B * (bmax) + C * (N - a - bmax) == M) {
            cout << a << ' ' << bmax << ' ' << N - a - bmax << endl;
            return 0;
        }
        if (A * a + B * (bmin) + C * (N - a - bmin) == M) {
            cout << a << ' ' << bmin << ' ' << N - a - bmin << endl;
            return 0;
        }
    }

    for (long long a = 0; a <= N; a++) {
        long long bmin = 0;
        long long bmax = N - a;
        while (bmax - bmin > 1) {
            long long bmid = (bmax + bmin) / 2LL;
            if (A * a + B * (bmid) + C * (N - a - bmid) <= M) {
                bmax = bmid;
            } else {
                bmin = bmid;
            }
        }
        if (A * a + B * (bmax) + C * (N - a - bmax) == M) {
            cout << a << ' ' << bmax << ' ' << N - a - bmax << endl;
            return 0;
        }
        if (A * a + B * (bmin) + C * (N - a - bmin) == M) {
            cout << a << ' ' << bmin << ' ' << N - a - bmin << endl;
            return 0;
        }
    }

    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s,t;
    cin>>s>>t;
    int n=s.size();
    rep(i,n+1){
        string u=s.substr(0,i);
        string v=s.substr(i,n-i);
        string w=v+u;
        // cout<<w<<endl;
        if(w==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

//#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>

#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

//int 最大値は2147483647 > 10^9
//ll gojou[200];

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

    ll max_h=0;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        if(max_h<a[i])max_h=a[i];
        //max_h = max(a[i],max_h);
    }

    ll ans=0;
    //printf("1 1");return 0; //RE箇所探索用
    map<ll,ll> l;
    map<ll,ll> r;

    /*
    vector<ll> l(n+max_h),r(n+max_h);
    rep(i,n+max_h) l[i]=0;
    rep(i,n+max_h) r[i]=0;
    */
    rep(i,n){
        if(i-a[i]>=0) l[i-a[i]]++;
        r[i+a[i]]++;
    }
    for(auto itr = l.begin(); itr != l.end(); ++itr) {
        ans+= itr->second * r[itr->first];
    }
    cout<<ans<<endl;
    return 0;
/*
    rep(i,n+max_h) ans+=l[i]*r[i];
    cout<<ans<<endl;
    return 0;
    */

} // end of main
    
//実行は、Opt + Ctl + N


//pythonの入力
//s, w = map(int, input().split())


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

int main() {
    string s,ans;
    cin >> s;
    char l1,l2,l3,l4;
    int count1=0,count2=0,count3=0,count4=0;
    l1=s.at(0);
    l2=s.at(1);
    l3=s.at(2);
    l4=s.at(3);
    if(l1==l2)count1++;
    if(l1==l3)count1++;
    if(l1==l4)count1++;
    if(l2==l1)count2++;
    if(l2==l3)count2++;
    if(l2==l4)count2++;
    if(l3==l1)count3++;
    if(l3==l2)count3++;
    if(l3==l4)count3++;
    if(l4==l1)count4++;
    if(l4==l2)count4++;
    if(l4==l3)count4++;
    if(count1==1&&count2==1){
        if(count3==1&&count4==1){
            ans="Yes";
        }
        else{ans="No";}
    }
    else{
        ans ="No";
    }
    cout << ans << endl;
}


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

int main(){
	int n,i;
	double ans=0;
	double x[10];
	char s[10][5];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf%s",&x[i],s[i]);
		if(strcmp(s[i],"JPY")==0)ans+=x[i];
		else ans+=x[i]*380000;
	}
	printf("%lf",ans);
	return 0;
}

Measured memory_bytes: 128
h,w,k=map(int,input().split())
S=[input() for i in range(h)]

LIS=[]

def saiki(x,st):
    if x==h-1:
        LIS.append(st)
        return
    else:
        saiki(x+1,st+st[-1])
        saiki(x+1,st+str(int(st[-1])+1))

saiki(0,"0")

DIC1={c:0 for c in "0123456789"}
DIC2={c:0 for c in "0123456789"}
ans=10**9
for cod in LIS:
    for ele in DIC1:
        DIC1[ele]=0
    cnt=int(cod[-1])
    end=False
    for i in range(w):
        for ele in DIC2:
            DIC2[ele]=0
        for q in range(h):
            if S[q][i]=="1":
                DIC2[cod[q]]+=1
        if max(DIC2.values())>k:
            end=True
            break
        flg=True
        for ele in DIC1:
            if DIC1[ele]+DIC2[ele]>k:
                flg=False
                break
        if flg:
            for ele in DIC1:
                DIC1[ele]+=DIC2[ele]
        else:
            for ele in DIC1:
                DIC1[ele]=DIC2[ele]
            cnt+=1
    if end:
        continue
    ans=min(ans,cnt)
    #print(cod,cnt)
print(ans)


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

struct UnionFind {
  vector<int>par;
  vector<int>rank; 

  UnionFind(int n=1){
    init(n);
  }
  void init(int n=1) {
    par.resize(n);rank.resize(n);
    for(int i=0;i<n;++i)par[i]=i,rank[i]=0;
  }
  int root(int x){
    if(par[x]==x)return x;
    else{
      int r=root(par[x]);
      return par[x]=r;
    }
  }
  bool issame(int x,int y) {
    return root(x)==root(y);
  }
  bool merge(int x,int y) {
    x=root(x);y=root(y);
    if(x==y) return false;
    if(rank[x]<rank[y])swap(x, y);
    if(rank[x]==rank[y])++rank[x];
    par[y]=x;
    return true;
  }
};

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

  int N,M;
  cin>>N>>M;
  vector<int>X(M),Y(M),Z(M);
  for(int i=0;i<M;i++)cin>>X[i]>>Y[i]>>Z[i];
  for(int i=0;i<M;i++)X[i]--,Y[i]--;
  UnionFind uf(N);
  for(int i=0;i<M;i++)uf.merge(X[i],Y[i]);
  int ans=0;
  for(int i=0;i<N;i++)if(uf.par[i]==i)ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...) \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
   public:
    i64 d[maxn];
    void solve() {
        memset(d, -1, sizeof d);
        int n, h;
        cin >> h >> n;
        vector<int> A(n), B(n);
        for (int i = 0; i < n; ++i) cin >> A[i] >> B[i];
        d[h] = 0;
        for (int i = h; i > 0; --i) {
            if (d[i] == -1)
                continue;
            for (int j = 0; j < n; ++j) {
                int q = i - A[j];
                q = max(0, q);
                if (d[q] == -1)
                    d[q] = d[i] + B[j];
                else
                    d[q] = min(d[q], d[i] + B[j]);
            }
        }
        cout << d[0] << '\n';
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

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

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

int main()
{
  ll n;
  cin >> n;
  vector<ll> v(n);
  for (ll i = 0; i < n; i++)
  {
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  rep(n-1)
  {
    if(v[i]==v[i+1])
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define lli long long
const lli mod = (lli)(1e9+7);

int main() 
{
    int n;
    cin >> n;
    
    vector<int> v(n);
    
    lli sum = 0, ans = 0;
    
    for(int i=0;i<n;i++){
        cin >> v[i];
        sum += 1LL*v[i];
        sum %= mod;
    }
    
    for(int i=0;i<n;i++){
        sum -= v[i];
        if(sum<0) sum += mod;
        sum %= mod;
        lli temp = v[i];
        temp *= sum;
        temp %= mod;
        ans+=temp;
        ans%=mod;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

#define mp make_pair
#define pb push_back
#define f first
#define s second 
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define int long long
#define forn(i, x, y) for(int i = x; i <= y; i++)
#define forev(i, y, x) for(int i = y; i >= x; i--)

using namespace std;

const int maxn = (int)3e6 + 100;
const int mod = (int)1e9 + 7;
const int P = (int)1e6 + 7;
const int inf = (int)1e9 + 7;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef long double ld;

using namespace std;

int l,r,dp[100][2][2][2];
int calc(int bit,int sp1,int sp2,int was){
	if(bit<0)return 1;
	int &res=dp[bit][sp1][sp2][was];
	if(res!=-1)return res;
	res=0;
	forn(b1,0,1){
		forn(b2,0,1){
			if(b1<b2)continue;
			if(!was&&b1!=b2)continue;
			int x=(l>>bit)&1,y=(r>>bit)&1;
			if(sp1&&b1>y)continue;
			if(sp2&&b2<x)continue;
			res=(res+calc(bit-1,sp1&(b1==y),sp2&(b2==x),was|b1))	%mod;
		}
	}
	return res;
}
main(){
	cin>>l>>r;
	memset(dp,-1,sizeof(dp));
	cout<<calc(60,1,1,0);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int H,W;
  scanf("%d %d",&H,&W);
  char A[9][9];
  int i,j;
  int num = 0;
  int count = 1;

  for(i=0;i<H;i++){
    scanf("%s",A[i]);
  }

  for(i=0;i<9;i++){
    for(j=0;j<9;j++){
      if(A[i][j]!='#'){
	A[i][j] = '.';
      } else {
	num++;
      }
    }
  }

  /*
  for(i=0;i<9;i++){
    for(j=0;j<9;j++){
      printf("%c",A[i][j]);
    }
    printf("\n");
  }
  */
  

  int marker[2] = {0,0};
  //char ans[30];

  while(count<num){
    if(A[marker[0]+1][marker[1]]=='#' && A[marker[0]][marker[1]+1]=='.'){
      marker[0]++;
      count++;
    } else if(A[marker[0]][marker[1]+1]=='#' && A[marker[0]+1][marker[1]]=='.'){
      marker[1]++;
      count++;
    } else {
      //ans = "Impossible";
      //printf("num:%d count:%d\n",num,count);
      printf("Impossible\n");
      break;
    }
    if(count==num){
      //ans = "Possible";
      //printf("num:%d count:%d\n",num,count);
      printf("Possible\n");
    }
  }

  //printf("%s\n",ans);
    
  return 0;
}


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

//#define debug
using namespace std;
int n, m, i, j, r;

int main() {
#ifdef debug
	freopen("1.in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	while (cin >> n >> r) {
		if (n < 10) {
			cout << r + 100 * (10 - n) << endl;
		} else {
			cout << r << endl;
		}
	}
	return 0;
}


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

using namespace std;


int main(){
	long long int N;
	cin >> N;
	string S;
	cin >> S;
	long long int a = 0, b = 0;
	for( auto c : S ){
		if( c=='R' ){
			a++;
		} else{
			b++;
		}
	}
	if( a > b ){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
int a[123456];
int main(){
    std::ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int i,haha;
    int maxi=0;
    rep(i,n){
    	cin>>a[i];
    	maxi=max(maxi,a[i]);
    }
    haha=a[0];
    rep(i,n){
    	haha=__gcd(haha,a[i]);
    }
    if(k<=maxi && k%haha==0){
    	cout<<"POSSIBLE"<<endl;
    }
    else{
    	cout<<"IMPOSSIBLE"<<endl;
    }


    return 0;      

}



Measured memory_bytes: 640
#include<stdio.h>
 
int main(){

  int a,b;
  
  (void) scanf("%d %d",&a,&b);
  
  if ( (a % 2 != 0) && (b % 2 != 0) )
  {
  	printf("Odd");
    return 0;
  }
  
 printf("Even");      
 return 0; 
}

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

#define mx 500008


typedef int ll;


int main()
{
    
        ll n,k;
        cin>>n>>k;
        ll a[n+7];
        int mn=0;
        for(int i=1;i<=n;i++){

        cin>>a[i];
        mn=max(mn,a[i]);
        }
        ll ans=0;
        ll lo=1;
        ll hi=mn;
        while(lo<=hi){
            ll mid=(lo + (hi-lo)/2);
            ll tot=0;
            for(int i=1 ; i<=n;i++) {
                int u=a[i];
                if(u>mid)
            tot += (u-1)/mid;
            }
            //cout<<mid<<" "<<tot<<endl;
            if(tot<=k){
                ans=mid;
                hi=mid-1;
            }
            else lo=mid+1;
        }
        cout<<ans<<endl;
    
}


Measured memory_bytes: 4348
#!/usr/bin/perl

my $l1 = <STDIN>;

$l1 =~ /^(\d+)\s+(\d+)/o;

my $a = $1;
my $b = $2;

my $l2 = <STDIN>;
$l2 =~ s/[\x00-\x20]+$//o;

if( $l2 =~ /^(\d*)-(\d*)$/o ){
  my $al = $1;
  my $bl = $2;
  if( length($al) == ($a - 0) and length($bl)== ($b - 0) ){
    print "Yes\n";
  } else {
    print "No\n";
  }
} else {
   print "No\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int H, W, N;

	cin >> H >> W >> N;

	cout << (N + max(H, W) - 1) / (max(H, W)) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

long a[220000];
long b[220000];

int main() {
	int m, n, k;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for (int i = 1; i <= m; i++) {
		cin >> b[i];
		b[i] += b[i - 1];
	}
	int j = m;
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (a[i] > k) break;
		while (a[i] + b[j] > k)
			j--;
		ans = max(ans, i + j);
	}
	cout << ans << endl;
}

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

int main()
{
    int n, a;
    std::cin >> n;
    std::cin >> a;

    int amari = n % 500;

    if (amari <= a){
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}

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

f=False
for i in range(N+1):
	for j in range(N+1):
		s = 10000*i+5000*j
		t = Y-s
		if t>=0 and t%1000==0 and (i+j+t//1000)== N:
			f=True
			break
	if f:break

if f:print(i,j,t//1000)
else:print(-1,-1,-1)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/arc064/tasks/arc064_a

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define int long long
#define endl '\n' 

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

    int N, x;
    cin >> N >> x;

    vector<int> a(N+5);
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
    }

    int ans = 0;
    for(int i = 1; i <= N; i++) {
        ans += max(0LL, (a[i]+a[i-1])-x);
        a[i] -= max(0LL, (a[i]+a[i-1])-x);
    }

    cout << ans << endl;
}


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

int main()
{
    int N;
    int A[100005], B[100005];
    int mpos = 0;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        if(A[mpos] < A[i]) mpos = i;
    }
    cout << A[mpos] + B[mpos] << endl;
    return (0);
}


Measured memory_bytes: 1024
#include<stdio.h>
#define N 100
#define INF 10000000

void MatrixChain(int);
int min(int,int);

int A[N];
int B[N][N];

void MatrixChain(int n) {
 
  int i,j,k,l,m;
 
  for(i=1; i<=n; i++)
    B[i][i]=0;
 
  for(j=2; j<=n; j++){
 
    for(i=1; i<=n-j+1; i++){
      l=i+j-1;
      B[i][l]=INF;
 
      for(k=i; k<=l-1; k++){
 
    m=B[i][k]+B[k+1][l]+A[i-1]*A[k]*A[l];
 
    B[i][l]=min(B[i][l],m);
      }
    }
  }
}

int min(int l,int m){
  if(l<m) return l;
  else return m;
}

int main(){
  int n,i,j,l,m;
 
  scanf("%d",&n);
 
 
  for(i=0; i<n; i++){   
 
    scanf("%d %d",&l,&m);
    A[i]=l;
    A[i+1]=m;
  }
   
  MatrixChain(n);
   
   
  printf("%d\n",B[1][n]);
  return 0;
}

Measured memory_bytes: 636
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

dic = dict()

for i in range(N):
    if s[i] not in dic:
        dic[s[i]] = 1
    else:
        dic[s[i]] += 1


for i in range(M):
    if t[i] in dic:
        dic[t[i]] -= 1

print(max(0, max(dic.values())))


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        long N = NextInt();
        for (long h = 1; h <= 3500; h++)
        {
            for (long n = 1; n <= 3500; n++)
            {
                long x = N * h * n;
                long y = 4 * h * n - N * n - N * h;
                if (y != 0 && x % y == 0 && (x/y) > 0)
                {
                    Console.WriteLine(h + " " + n + " " + (x / y));
                    return;
                }
            }
        }
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 何分割するか */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long h = scanner.nextLong();
			long w = scanner.nextLong();
			long[] s = new long[N];
			System.out.println(Math.min(getResult(h, w, s, N), getResult(w, h, s, N)));
		}
	}

	/**
	 * https://atcoder.jp/contests/abc062/submissions/7236184 を参考に作成
	 * 
	 * @param h 高さ
	 * @param w 幅
	 * @param s 結果の配列
	 * @param n 何分割するか
	 * @return 結果の最大値と最小値の差分
	 */
	private static long getResult(final long h, final long w, final long[] s, int n) {
		if (1 == n) {
			s[N - n] = h * w;
			return Arrays.stream(s).max().getAsLong() - Arrays.stream(s).min().getAsLong();
		}
		if ((0 == (h % n)) || (0 == (w % n))) {
			IntStream.range(N - n, N).forEach(i -> s[i] = h * w / n);
			return Arrays.stream(s).max().getAsLong() - Arrays.stream(s).min().getAsLong();
		} else {
			return IntStream.rangeClosed(-(n - 1), (n - 1)).mapToLong(i -> {
				s[N - n] = (h / n + i) * w;
				return Math.min(getResult(h - h / n - i, w, s, n - 1), getResult(w, h - h / n - i, s, n - 1));
			}).min().getAsLong();
		}
	}
}


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

int main(){
	long long a,b;
	cin>>a>>b;
	long long count=0;
	for(int i=0;i<a;i++){
		long long x;
		cin>>x;
		if(x>=b){
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define ll long long
 
string A;
ll alp[26];
int main()
{
	cin >> A;
 
	ll n = A.size();
	ll ans = n*(n - 1) / 2 + 1;
	REP(i, 0, n) {
		alp[A[i] - 'a']++;
	}
 
	REP(i, 0, 26) {
		ans -= (alp[i] * (alp[i] - 1) / 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int s = sc.nextInt();
		
		HashMap<Integer, Boolean> record = new HashMap<Integer, Boolean>();
		record.put(s, true);
		int count = 1;
		while(true) {
			s = f(s);
			count++;
			if (record.containsKey(s)) {
				System.out.println(count);
				break;
			}
			record.put(s, true);
		}
	}
	
	public static int f(int n) {
		if (n%2 == 0) {
			return n/2;
		}
		return 3*n+1;
	}
}


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

int main(){
    int N, M, ans=0, a, b, sum=0;
    cin >> N;
    vector<int> T(N);
    for(int i=0; i<N; i++){
	cin >> T[i];
	sum += T[i];
    }
    cin >> M;
    vector<int> P(M), X(M);
    for(int i=0; i<M; i++){
	cin >> P[i] >> X[i];
	cout << sum -T[P[i]-1] +X[i]<< endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
vector<int> G[10];
int n,m;
int vis[15];
bool check(){
    fore(i,0,n)
        if(vis[i] == -1)
            return 0;
    return 1;
}
int dfs(int u){
    if(check())
        return 1;

    int ans = 0;
    fore(i,0,sz(G[u])){
        int v = G[u][i];
        if(vis[v] == 1)
            continue;
        vis[v] = 1;
        ans += dfs(v);
        vis[v] = -1;
    }
    return ans;
}
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    cin >> n >> m;
    while(m--){
        int u,v;
        cin >> u >> v;
        u--;v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    cls(vis,-1);
    vis[0] = 1;
    cout << dfs(0) << '\n';
    return 0;   
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var w = Console.ReadLine();

            var result = w.ToLookup(c => c).All(l => l.Count() % 2 == 0)
                ? "Yes" : "No";

            Console.Write(result);
        }
    }
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

int n,k,h,w;
string s,t;

int main() {
  cin >> s;
  cout << s.substr(0,(int)s.size()-8) << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**9
for i in range(N-K+1):
    l = x[i]
    r = x[i+K-1]
    sec1 = abs(l) + abs(r-l)
    sec2 = abs(r) + abs(l-r)
    ans = min(ans, sec1, sec2)
print(ans)


Measured memory_bytes: 14228
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, m;

int32_t main(){_
   
   cin >> n >> m;
   
   char q = n + '0';
   string s(m, q);
   q = m + '0';
   string t(n, q);

   if((int)(s.size()) < (int)(t.size())){
      cout<<t;
   }   
   else if ((int)(s.size()) > (int)(t.size())){
      cout<<s;
   }
   else{
      if(s > t){
         cout<<s;
      }
      else{
         cout<<t;
      }
   }


   return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

junretu= list(itertools.permutations(range(1, n + 1)))
p_num = junretu.index(tuple(p)) + 1
q_num = junretu.index(tuple(q)) + 1

print(abs(p_num - q_num))


Measured memory_bytes: 8052
#include<iostream>
#include<sstream>

using namespace std;

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

int main() {
  while (true) {
    int t;
    string n;
    cin >> t >> n;
    if (t == 0 && n == "0") break;
    int res = 0, b;
    rep (i, 1 << (n.size() - 1)) {
      int p = 0, r = 0;
      rep (j, n.size() - 1) {
	if (i & 1 << j) {
	  stringstream ss;
	  ss << n.substr(p, j - p + 1);
	  int a;
	  ss >> a;
	  r += a;
	  p = j + 1;
	}
      }
      stringstream ss;
      ss << n.substr(p);
      int a;
      ss >> a;
      r += a;
      if (r <= t && res < r) {
	res = r;
	b = i;
      } else if (res == r) {
	b = -1;
      }
    }
    if (res == 0) cout << "error" << endl;
    else if (b == -1) cout << "rejected" << endl;
    else {
      cout << res << " " << n[0];
      rep (i, n.size() - 1) {
	if (b & 1 << i) cout << " ";
	cout << n[i + 1];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
# import pandas as pd
# import numpy as np

# d = pd.read_csv("useful.csv", usecols = ["Q133", "Q134", "Q146"])

# #l = d["Q133"]
# l = d["Q146"]
# bad = []
# good = [] 
# for i in range(1, 56):
# 	if int(l[i][0]) >= 4:
# 		good.append(i)
# 	else:
# 		bad.append(i)
# print(bad, good)

import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(1, n):
	if a[i] == a[i-1] + 1:
		ans += c[a[i-1]-1]
print(ans + sum(b))

Measured memory_bytes: 38384
# atcoder https://atcoder.jp/contests/dp/tasks/dp_c

N = int(input())
a, b, c = [], [], []
for _ in range(N):
    ai, bi, ci = map(int, input().split())
    a.append(ai); b.append(bi); c.append(ci)


dp = [[0] * N for _ in range(3)] #dp[h][i]: i日目にhを行った場合の最大幸福度
dp[0][0], dp[1][0], dp[2][0]  = a[0], b[0], c[0]

for i in range(1, N):
    dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1])
    dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1])
    dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1])

print(max(dp[h][N-1] for h in range(3)))

Measured memory_bytes: 26912
using System;
using System.Text;

namespace ABC152
{
    public class EmptyClass
    {
        public static void Main(string[] args)
        {
            int[] inp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if (inp[1] > inp[0])
            {
                int tmp = inp[0];
                inp[0] = inp[1];
                inp[1] = tmp;
            }

            StringBuilder sb = new StringBuilder();
            while (inp[0]-->0)
            {
                sb.Append(inp[1]);
            }
            Console.WriteLine(sb.ToString());
        }
    }
}


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

struct Key{int a; int c;};

int main() {
    int N, M;
    cin >> N >> M;
    vector<stack<int>>st(N);
    vector<Key>k_vec(M);
    for (int i = 0; i < M; ++i) {
        int a, b;
        int key_type = 0;
        cin >> a >> b;
        for (int j = 0; j < b; ++j) {
            int c;
            cin >> c;
            key_type += pow(2, c-1);
            st[c-1].push(i);
        }
        k_vec[i] = {a, key_type};
    }
    vector<int>dp(pow(2, N), INT_MAX / 2);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        while (! st[i].empty()){
            int top = st[i].top();
            st[i].pop();
            for (int j = 0; j < dp.size(); ++j) {
                int res = j | k_vec[top].c;
                dp[res] = min(dp[res], dp[j] + k_vec[top].a);
            }
        }
    }
    if(dp.back() == INT_MAX / 2){
        cout << -1 << "\n";
    } else{
        cout << dp.back() << "\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
  cin >> s;
  rep(i,4) cout << s[i];
  cout << " ";
  for(int i=4;i<12;i++) cout << s[i];
  cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
ll N,A,B,C;
  vector<ll>l;
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

ll dfs(ll a,ll b,ll c,ll d){
  if(d==N){
    if(min(a,min(b,c))==0){
      return INF;
    }
    else{
      return abs(A-a)+abs(B-b)+abs(C-c)-3*10;
    }
  }

  ll MP1=dfs(a+l[d],b,c,d+1)+10;
  ll MP2=dfs(a,b+l[d],c,d+1)+10;
  ll MP3=dfs(a,b,c+l[d],d+1)+10;
  ll MP4=dfs(a,b,c,d+1);//それぞれのパターンのDFSを生成
  
  return min(min(MP1,MP4),min(MP2,MP3));//毎回ここはreturnされるが再帰関数は続くから
  //実際最後にのみreturnが適用されている
}



int main(){
  

  cin>>N>>A>>B>>C;
  l.resize(N);// おそらくint main()外でvectorを範囲指定せずに定義した場合、ここでl.resize(N)をして再度取得する必要がある
  

  
  rep(i,N){
    cin>>l[i];
  }
  
  cout<<dfs(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

int inf = (1 << 30);
int mod = 1e9;
long long long_inf = (1LL << 60);

int main(){

    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];

    int ans = 0, top = 0;
    for(int i = 0; i < N; i++){
        if(top <= H[i]){
            top = H[i];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll=long long;

#define rep(i, a, n) for (int i = (a); i < (n); i++)

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期

  int n,t;
  cin>>n>>t;

  int a[n];
  rep(i,0,n){cin>>a[i];}

  int sum=n*t;
  rep(i,0,n-1){
    //cout<<a[i+1]<<" "<<a[i]<<endl;
    if(a[i+1]-a[i]<=t){
      sum-=t-(a[i+1]-a[i]);
      //cout<<sum<<endl;
    }
  }

  cout<<sum<<endl;
}

Measured memory_bytes: 1152
#define $ for(i=j=0;j<n?:(j=0,++i<n);j++)
#define _(a,b)$ for(b=l=0;l<n;)b=(b+a[i][l]*p[l++][j])%m;$ a[i][j]=b;
long m=1e9+7,p[50][50],a[50][50],b[50][50],k,s;i,j,l;main(n){scanf("%d%ld",&n,&k);$ a[i][i]=1;$ scanf("%d",p[i]+j);for(;k;k/=2){if(k&1){_(a,b[i][j])}_(p,b[i][j])}$ s+=a[i][j];printf("%d",s%m);}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

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

const ll MODBASE = 1000000007LL;
const int MAXN = 13;
const int MAXM = 1010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, m;
ll dp[MAXM][(1<<MAXN)];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,0,m)
        FOR(mask,0,(1<<n)-1) dp[i][mask] = 1e18;
    dp[0][0] = 0;
    FOR(i,1,m) {
        int price, boxes;
        cin >> price >> boxes;
        int mask = 0;
        FOR(j,1,boxes) {
            int u;
            cin >> u;
            mask += (1<<(u-1));
        }
        FOR(mask2,0,(1<<n)-1) {
            dp[i][mask2] = min(dp[i][mask2], dp[i-1][mask2]);
            dp[i][mask2 | mask] = min(dp[i][mask2 | mask], dp[i-1][mask2] + price);
        }
    }
    // FOR(i,0,m) {
    //     FOR(j,0,(1<<n)-1) cout << dp[i][j] << ' ';
    //     cout << endl;
    // }
    if (dp[m][(1<<n)-1] == 1e18) cout << -1;
    else cout << dp[m][(1<<n)-1];
    return 0;
}


Measured memory_bytes: 63232
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
 
using namespace std;
 
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pii pair<int,pi>
#define X first
#define Y second
#define pb push_back
#define ab(x) ((x)<0?(-(x)):(x))
#define xx(x) ((x)*(x))
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vpi vector<pi>
#define vpll vector<pll>
#define ALL(x) (x).begin(),(x).end()
#define Max (1<<30)
#define LLMax (1ll<<60)
template<class T>string ToString(T t){stringstream s;s<<t;return s.str();}
template<class T>void ToOther(T&t,string a){stringstream s(a);s>>t;}
 


char ck[1<<24];
char TT=0;
int n;
int x[55];
int y[55];
int cor[55];
int R[55];

int up[55];
bool can(int p,int q){
	if( xx(x[p]-x[q]) + xx(y[p]-y[q]) < xx(R[p]+R[q]))return 1;
	return 0;
}
bool no_up(int x,int st){
	return !(up[x]&st);
}
int main(){
	while(cin>>n,n){
		for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>R[i]>>cor[i];

		memset(up,0,sizeof(up));

		for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)if(can(i,j))up[j] |= (1<<i);
		queue<int> q;
		queue<int> num;
		q.push((1<<n)-1);
		num.push(0);
		TT++;
		ck[(1<<n)-1]=TT;

		int r=0;
		while(q.size()){
			int k=q.front();
			int t=num.front();
			q.pop();num.pop();

			r=max(r,t);

			for(int i=n-1;i>=0;i--)if(k>>i&1)for(int j=i-1;j>=0;j--)if(k>>j&1){
				if(cor[i]==cor[j] && no_up(i,k) && no_up(j,k)){
					int nxt= k^(1<<i)^(1<<j);
					int nxt2=t+2;

					if(ck[nxt]==TT)continue;
					ck[nxt]=TT;

					q.push(nxt);
					num.push(nxt2);
				}
			}
		}
		cout<<r<<endl;
	}
}

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const int MOD = 1000000007ll;
const int mod1 = 1000000009ll;
const int mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

int bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
int bit(lli _mask,int _i){return (_mask&(1ll<<_i))==0?0:1;}
int add(int a,int b,int m=MOD){int x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
int sub(int a,int b,int m=MOD){int x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
int mul(int a,int b,int m=MOD){lli x=a*1ll*b;x%=m;while(x<0)x+=m;return (int)x;}
int ldtoint(ld x){return (int)(x+0.5);}lli ldtolli(ld x){return (lli)(x+0.5);}
int powermod(lli _a,lli _b,int _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=mul(_r,_a,_m);_b>>=1;_a=mul(_a,_a,_m);}return _r;}

template<class T1,class T2>ostream&operator<<(ostream& os,const pair<T1,T2>&p){os<<"["<<p.first<<","<<p.second<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,const vector<T>&v){os << "[";bool first=true;for (T it:v){if (!first)os<<", ";first = false;os<<it;}os<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,set<T>&v){os<<"[";bool first=true;for (T it:v){if(!first)os<<", ";first=false;os<<it;}os<<"]";return os;}
template<class T1,class T2>ostream&operator<<(ostream& os,map<T1,T2>&v){os<<"[";bool first=true;for(pair<T1,T2> it:v){if(!first)os<<", ";first=false;os<<"("<<it.F<<","<<it.S<<")";}os<<"]";return os;}
template<class T>void parr(T a[],int s,int e){cout<<"[";for(int i=s;i<e;i++)cout<<a[i]<<", ";cout<<a[e]<<"]\n";}

int N,M,root;
vector<int> G[100010];
vector<int> ans,pre;
bool vis[100010];

void dfs2(int u){
    vis[u] = true;
    if(u!=root)
        pre.pb(u);
    for(int v:G[u]){
        if(!vis[v]){
            dfs2(v);
            break;
        }
    }
}

void dfs1(int u){
    vis[u] = true;
    ans.pb(u);
    for(int v:G[u]){
        if(!vis[v]){
            dfs1(v);
            break;
        }
    }
}

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));
    //ios::sync_with_stdio(0);cin.tie(0);

    si(N);si(M);
    if(N == 2){
        cout<<"2\n1 2";
        return 0;
    }
    for(int i=1;i<=M;i++){
        int u,v;
        si(u);si(v);
        G[u].pb(v);
        G[v].pb(u);
    }
    for(int i=1;i<=N;i++)
        if(G[i].size()>=2)
            root = i;
    dfs1(root);
    dfs2(root);
    cout<<ans.size() + pre.size()<<"\n";
    reverse(all(pre));
    for(int x : pre)
        cout<<x<<" ";
    for(int x : ans)
        cout<<x<<" ";

    return 0;
}


Measured memory_bytes: 9592
fun main(args: Array<String>) {
    var (N,M) = readLine()!!.split(" ").map(String::toLong)
    if(Math.abs(N-M)>1){
         println(0)
         return
    }
    var fact1 = 1L
    var fact2 = 1L
    (2..N).map{i->
        fact1 = fact1 * i % 1000000007
    }
    (2..M).map{i->
        fact2 = fact2 * i % 1000000007
    }
    if(N != M) println((fact1*fact2)%1000000007)
    else println((fact1*fact2*2)%1000000007)

}


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

int main()
{
    string A,B;
    int a,b;
    cin >> A >> B;
    a = A.size();
    b = B.size();
    for(int i = 0;i<b;i++){
        cout << A[i] << B[i];
    }
    if(a - b == 1){
        cout << A[a-1];
    }
    cout << endl;
}



Measured memory_bytes: 256