akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


ll mypower(ll x, ll n){
    if(n==0){
        return 1;
    }
    ll temp = mypower(x, n/2);
    if(n%2==0){
        return (temp*temp)%MOD;
    }else{
        return (((temp*temp)%MOD)*x)%MOD;
    }
}

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll r,g,b;
    r=0; g=0; b=0;

    for(int i=0; i<N; i++){
        if(S[i]=='R'){
            r++;
        }else if(S[i]=='G'){
            g++;
        }else if(S[i]=='B'){
            b++;
        }
    }

    ll ans = r*g*b;

    for(ll i=0; i<N; i++){
        for(ll j=1; j<=min(i,N-i-1); j++){
            if(S[i]!=S[i-j] && S[i]!=S[i+j] && S[i-j]!=S[i+j]){
                ans--;
            }
        }
    }

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

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

int main(){
  int N;
  vector<int> T(3);
  cin >> N >> T[0] >> T[1] >> T[2];
  vector<int> L(N);
  for(int i=0; i<N; i++) cin >> L[i];
  
  vector<int> Ltemp(4);
  int result=1e9;
  for(int i=0; i<(1<<(2*N)); i++){
    int mp=0;
    for(int l=0; l<4; l++){
      Ltemp[l]=0;
    }
    for(int j=0; j<N; j++){
      int a=((i&(1<<(2*j)))>0?1:0);
      int b=((i&(1<<(2*j+1)))>0?1:0);
      if(a*b==0&&Ltemp[a+2*b]>0) mp+=10;
      Ltemp[a+2*b]+=L[j];
    }
    for(int k=0; k<3; k++){
      if(Ltemp[k]==0) mp+=1e8;
      mp+=abs(T[k]-Ltemp[k]);
    }
    result=min(result,mp);
  }
  cout << result << endl;
}

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

int main() {
  long long a, b, x;
  cin >> a >> b >> x;
  long long ans;
  if (a > 0) {
    ans = b/x - (a - 1)/x;
  }
  else {
    ans = b/x + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(i=j; i<k; i++)
#define rrep(i,j,k) for(i=j; i>=k; i--)
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); it++)
#define ZERO(a) memset(a,0,sizeof(a))
#define lastbit(x) (x&(-x)) 
#define pb push_back 
#define all(c) (c).begin(),(c).end()
#define fin scan_int()
#define pd(x) printf("%d",x)
#define newl printf("\n")
#define xx first
#define yy second
#define mod 1000000007
#define FIND(x,y) ((y).find((x))!=(y).end())
#define dbg(a) cerr << #a << endl;
#define dbgv(vari) cerr << #vari<< " = "<< (vari) <<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define compress(s) sort(all(s)); s.resize(unique(s.begin(),s.end())-s.begin());
#define strtoint(s,n) if (!(istringstream(s) >> n) ) n = 0;
typedef long long ll;
typedef vector<int > vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<string,int > psi; 
typedef pair<int ,int > pii;

string inttostr(int str){stringstream stream;stream << str;return stream.str();}
ll modexpo(ll a,ll b,ll n){ll d=1;while(b){if(b&1)d=(d*a)%n;b>>=1;a=(a*a)%n;}return d;}
ll expo(ll a,ll b){ll d=1;while(b){if(b&1)d=d*a;b>>=1;a=a*a;}return d;}
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b) {return (a*b)/gcd(a,b);}
ll inv(ll a,ll m){return modexpo(a,m-2,m);}

/*/////////////////////////////////////////////*/////////////////////////////////////////////////////////
#define gc getchar
inline int scan_int() {
   int NR=0,sign=1;    char c=gc();
    while( c < 48 || c > 57 ){if(c=='-')sign=0; c=gc();}
    while(c>47 && c< 58)
    {    NR = (NR << 3) + (NR << 1) + (c - 48);    c=gc();    }
    return (sign?NR:(-NR));}
inline void fast_out(int x){
         register char buffor[35]; register int i=0;
         do{buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x); i--;
            while(i>=0) putchar(buffor[i--]);
            putchar('\n');
}
////////////////////////////////////////////////////////////////////////////////////////////////////////*/

int main(){
    int n=fin;
    int a[n];
    int i;
    rep(i,0,n) a[i] = fin;
    
    map<int, int> mp;
    rep(i,0,n) mp[a[i]] = mp[a[i]]+1;
    
    int c=0;
    tr(mp,it) {
        if(it->xx != it->yy) {
            if(it->xx < it->yy)
            c += it->yy - it->xx;
            else c += it->yy;
        }
    }
    cout<<c<<endl;
    
    return 0;
}

Measured memory_bytes: 5120
//sに追加する値は単調減少。辞書順最小は, (N)*…(1)*の形になる。あとは「X以上の値が少なくともいくつ先頭にくるか？」を
//求めていけばよい。
#include <iostream>
#include <set>
#define int long long
using namespace std;

int n;
int a[100000];

int mx[100001];
int dp[100000];
int ans[100000];

multiset<int> u;		//u…{a[x]～a[n-1]のうち, mx[x]以上の要素の集合} (0 <= x <= n - 1)

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	mx[0] = 0;
	for (i = 0; i < n; i++) mx[i + 1] = max(mx[i], a[i]);
	
	for (i = 0; i < n; i++) {
		dp[0] += a[i];
		u.insert(a[i]);
	}
	
	for (i = 1; i < n; i++) {
		int val = 0;
		//削除
		while ((*u.begin()) < mx[i]) {
			val += (*u.begin()) - mx[i - 1];
			multiset<int>::iterator it = u.begin();
			u.erase(it);
		}
		val += u.size() * (mx[i] - mx[i - 1]);
		
		dp[i] = dp[i - 1] - val;
	}
	
	ans[n - 1] = dp[n - 1];
	for (i = n - 2; i >= 0; i--) {
		ans[i] = dp[i] - dp[i + 1];
	}
	
	for (i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 8960
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;

    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

vi fac;

const ll mod = 1000000007; // faster if const

ll modpow(ll b, ll e) {
  ll ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}
ll inv(ll n) { return modpow(n, mod-2); }
ll c(ll n, ll k) { return ((fac[n] * inv(fac[k]) % mod) * inv(fac[n-k])) % mod; }

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  fac.pb(1);
  rep(i,1,112345) fac.pb(fac[i-1] * i % mod);

  ll n;
  cin >> n;

  vi x(n+1);
  rep(i,1,n+1) cin >> x[i];

  vi frac(n);
  rep(i,1,n) frac[i] = frac[i-1] + inv(i);
  ll ans = 0;
  rep(i,1,n) {
    ans += (x[i+1] - x[i]) * frac[i];
    ans %= mod;
  }

  ans *= fac[n-1];
  ans %= mod;

  cout << ans << endl;

}

Measured memory_bytes: 2804
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll r,g;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>r>>g;
	cout<<(g*2)-r;
	return 0;
}


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

#define int long long
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define fs first
#define sc second
#define mpr make_pair
#define iter iterator
#define all(X) X.begin(),X.end()
#define sau(X) sort(all(X)),X.resize(unique(all(X))-X.begin())
#define exist(X,ele) binary_search(all(X),ele)

template<typename T1,typename T2>
ostream& operator << (ostream& out,const pair<T1,T2>& X)
{
	out<<"{"<<X.fs<<","<<X.sc<<"}";
	return out;
}

template<typename T>
ostream& operator << (ostream& out,const vector<T>& X)
{
	for(auto i:X) out<<i<<" ";
	return out;
}

inline void cmin(int& x,int y)
{
	x=min(x,y);
}

inline void cmax(int& x,int y)
{
	x=max(x,y);
}

const int inf=5000000000000000ll;

main()
{
	ios::sync_with_stdio(false);
	
	int x,y; cin>>x>>y;
	for(int i=0;i<max(x,y);i++)
	{
		cout<<min(x,y);
	}
	
	return 0;
}






















Measured memory_bytes: 256
import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce
import itertools
from collections import defaultdict
import bisect
from fractions import Fraction
 

N = int(input())
A=list(map(int, input().split()))  

c = collections.Counter(A)

for k,v in c.items():
    if v >=2:
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 42820
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<bool>> s(h);
	vector<vector<int>> ans(h);
	vector<int> count(h);

	int num = 1;

	rep(i, h) {
		s[i].resize(w);
		ans[i].resize(w);
		
		
		rep(j, w) {
			char a;
			cin >> a;
			s[i][j] = (a == '#');
			if (s[i][j]) {
				count[i]++;
				ans[i][j] = num;
				num++;
			}
		}
	}

	rep(i, h) {
		if (count[i] > 0) {
			rep(j, w) {
				if (ans[i][j] == 0) {
					if (j > 0) {
						if (ans[i][j - 1] != 0) {
							ans[i][j] = ans[i][j - 1];
						}
					}
				}
			}

			rrep(j, w) {
				if (ans[i][j] == 0) {
					if (j < w-1) {
						if (ans[i][j + 1] != 0) {
							ans[i][j] = ans[i][j + 1];
						}
					}
				}
			}
		}
	}


	rep(i, h) {
		if (count[i] == 0) {
			if (i > 0) {
				if (count[i-1] != 0) {
					ans[i] = ans[i-1];
					count[i] = 1;
				}
			}
		}
	}

	rrep(i, h) {
		if (count[i] == 0) {
			if (i < h-1) {
				if (count[i + 1] != 0) {
					ans[i] = ans[i + 1];
					count[i] = 1;
				}
			}
		}
	}

	rep(i, h) {
		VecRowShow(ans[i]);
	}
	return 0;
}



Measured memory_bytes: 1152
#Cat Snuke and a Voyage

N,M = list(map(int, input().split()))
p = []
for i in range(M):
    a,b = list(map(int, input().split()))
    p.append([a,b])

l = [[] for i in range(N)]
for pi in p:  #0-originedに注意
    l[pi[0]-1].append(pi[1])
    l[pi[1]-1].append(pi[0])

flag = False

for li in l[0]:
    if( N in l[li-1] ):
        flag = True
        break

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main(){
  int N;
  cin >> N;
    if (N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
      cout << "hon" << endl;
    }
  	if (N%10==0||N%10==1||N%10==6||N%10==8){
      cout << "pon" << endl;
    }
  	if (N%10==3){
      cout << "bon" << endl;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n;
    ll sum[112345], a[112345];

    cin >> n;

    REP(i, n)
    {
        cin >> a[i];
    }

    sort(a, a + n);

    REP(i, n)
    {
        if (i == 0)
            sum[i] = a[i];
        else
            sum[i] = sum[i - 1] + a[i];
    }

    int l = n - 1;

    int res = 1;

    while (true)
    {
        int i = l - 1;

        while (i >= 0 && sum[i] * 2 >= a[l])
            i--, res++;

        if (l - i == 1)
            break;

        l = i + 1;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
//g++ -o vector -std=c++14 -Wall -Wextra -pedantic-errors  vector.cc
int main(){
    std::vector<int> v;
    int q;
    std::cin >> q;
    for (int i{0};i<q;i++){
        int a;
        std::cin >>a;
        if(a==0){
            int b;
            std::cin >> b;
            v.push_back(b);
        }
        if(a==1){
            int b;
            std::cin >> b;
            std::cout << v[b] << std::endl;
        }
        if(a==2){
            v.pop_back();
        }
    }
    /*
    for(auto& y:v){
        std::cout << y;
    }*/    
}


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

int Mod;

struct Matrix {
    int n, m;
    ll a[10][10];

    Matrix(int _n = 0, int _m = 0, int x = 0) {
        memset(a, 0, sizeof a);
        n = _n, m = _m;
        for (int i = 1; i <= n; ++i)
            a[i][i] = x;
    }

    Matrix operator * (const Matrix &b) {
        Matrix res = Matrix(n, b.m);
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j) if (a[i][j])
                for (int k = 1; k <= b.m; ++k)
                    (res.a[i][k] += a[i][j] * b.a[j][k] % Mod) %= Mod;
        return res;
    }

    Matrix operator ^ (ll k) {
        Matrix res = Matrix(n, n, 1), x = *this;
        while (k) {
            if (k & 1) res = res * x;
            x = x * x;
            k >>= 1;
        }
        return res;
    }
};

inline ll fsp(ll x, ll k) {
    x = x % Mod;
    ll res = 1;
    while (k) {
        if (k & 1) res = res * x % Mod;
        x = x * x % Mod;
        k >>= 1;
    }
    return res;
}

int main() {
    ll n, a, d;
    cin >> n >> a >> d >> Mod;
    ll b = 1, ans = 0;
    for (int i = 1; i <= 18; ++i, b = b * 10) {
        ll L = b, R = 10 * b - 1, s;
        if (R < a) continue;
        if (L <= a) L = 1;
        else L = (L - a - 1) / d + 2;
        R = (R - a) / d + 1;
        L = max(L, 1ULL), R = min(R, 1ULL * n);
        if (L > R) continue;
        s = (a + (L - 1) * (d));
        s %= Mod;
        Matrix base = Matrix(3, 3, 0);
        base.a[1][1] = b * 10 % Mod;
        base.a[2][1] = base.a[2][2] = base.a[3][2] = base.a[3][3] = 1;
        base = base ^ (R - L + 1);
        ans = ((ans * fsp(b * 10, (R - L + 1)) % Mod + s % Mod * base.a[2][1] % Mod) % Mod + d % Mod * base.a[3][1] % Mod) % Mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m,k,temp,ans=0,j;
    cin>>n>>m>>k;
    ll a[n+6],b[m+6];
    for(int i=0;i<=n;i++)
    {
        if(i==0)
        {
            a[i]=0;
        }
        else
        {
            cin>>temp;
            a[i]=temp+a[i-1];
        }
        
    }
    for (int i=0;i<=m;i++)
    {
        if(i==0)
        {
            b[i]=0;
        }
        else
        {
            cin>>temp;
            b[i]=temp+b[i-1];
        }
        
    }
    j=m;
    for(int i=0;i<=n;i++)
    {
        if(a[i]>k)
        {
            break;
        }
        while(k-a[i]<b[j])
        {
            j--;
        }
        ans=max(ans,i+j);
    }
    cout<<ans<<'\n';

}

Measured memory_bytes: 6744
#include<iostream>
using namespace std;
int main(){
  char s;int ok[4] = {};
  while(cin >> s){
    if(s=='N') ok[0]=1;
    else if(s=='W') ok[1]=1;
    else if(s=='S') ok[2]=1;
    else ok[3]=1;
  }
  cout << ((ok[0]==ok[2] && ok[1]==ok[3]) ? "Yes":"No") << endl;
}
  

Measured memory_bytes: 256
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    s=input()
    if s=="AC":
        ac+=1
    elif s=="WA":
        wa+=1
    elif s=="TLE":
        tle+=1
    else:
        re+=1
print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")


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

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int area = B * A / 2;

    cout << area << endl;

    return 0;
}

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

int main() {
  double a,b,h,m;
  double kekka=0;
  long double pi = 3.14159265358979323846264338327950L;
  cin >> a >> b >> h >> m;
  
  double temp = (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0)* 2.0 * pi;
  

  kekka = (a*a) + (b*b) - 2.0*a*b*cosl(temp);
  kekka = sqrtl(kekka);  
  cout << setprecision(15) << kekka;
}


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

namespace PrintTestCases
{
    class Class1
    {
        public static void Main()
        {
            int[] x = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();
            int d = x[0] / x[1];
            int r = x[0] % x[1];
            decimal f = (decimal) x[0] / x[1];
            Console.WriteLine("{0} {1} {2}", d, r, f);
            Console.ReadLine();
        }
    }
}



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

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

int main() {
  int n;
  cin >> n;
  char c[n];
  rep(i, n) {
    cin >> c[i];
    if (c[i] == 'Y') {
      cout << "Four\n";
      return 0;
    }
  }
  cout << "Three\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int M = 0;
    int D = 0;
    cin >> M >> D;

    int d10max = D / 10;
    int d1max = D % 10;
    
    int counter = 0;

    for(int m=1; m<=M; m++)
    {
        for(int d1=2; d1<=9; d1++)
        {
            if(m % d1 == 0)
            {
                int d10 = m / d1;
                if(d10 >= 2 && d10*10 + d1 <= D)
                {
                    counter++;
                }
            }
        }
    }

    cout << counter << endl;

    return 0;
}

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

using namespace std;

int pow(int b, int p){
    int n = b;

    for(int i = 2; i <= p; i++){
        n *= b;
    }

    return n;
}

int main(){
    int x;
    scanf("%d", &x);

    vector<int> b;
    b.push_back(1);

    for(int i = 2; i <= x; i++){
        for(int j = 2; pow(i, j) <= x; j++){
            b.push_back(pow(i, j));
        }
    }

    int max = b[0];
    for(int i = 1; i < b.size(); i++){
        if(b[i] > max) max = b[i];
    }

    printf("%d\n", max);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MM=100013;
vector<int> W[MM];
int wyn[MM];
void DFS(int w)
{
    for(auto v:W[w])
    {
        if(wyn[v]==0)   DFS(v);
        wyn[w]=max(wyn[w],wyn[v]+1);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    int n,m,a,b;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a>>b;
        W[a].push_back(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(wyn[i]==0)   DFS(i);
    }
    int w=0;
    for(int i=1;i<=n;i++)   w=max(w,wyn[i]);
    cout<<w<<endl;
    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;

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

	string s;
	cin>>s;
	string q;
	cin>>q;

	vector<int>a;
	a.push_back(-1);
	for(int i=1,k=-1;i<=q.size();i++){
		for(;k>=0&&q[i-1]!=q[k];)k=a[k];
		a.push_back(++k);
	}

	vector<int>r;
	for(int i=0,k=0;i<s.size();i++){
		for(;k>=0&&(k==q.size()||q[k]!=s[i]);)k=a[k];
		if(++k==q.size())r.push_back(i+1-k);
	}
	for(int i=0;i<r.size();i++)printf("%d\n",r[i]);
}

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

const int MAXN = 55;
long long dp[MAXN][MAXN][MAXN];
int A[MAXN][MAXN];
char S[MAXN];
int n;
long long ans;

long long getAns(int l, int r, int c) {
	if (dp[l][r][c] != -1)
		return dp[l][r][c];
	if (l == r)
		return dp[l][r][c] = 1;
	if (l == c || r == c)
		return dp[l][r][c] = 0;

	long long& res = dp[l][r][c];
	res = 0;
	
	for (int limL = l;limL < c; ++limL)
		for (int limR = c + 1;limR <= r; ++limR) 
			if (A[limL][limR])
				for (int lP = limL;lP < c; ++lP)
					for (int rP = c + 1;rP <= limR; ++rP)
						res += getAns(l, lP, limL) * getAns(lP + 1, rP - 1, c) * getAns(rP, r, limR);
//	printf("(%d, %d, %d, %lld)\n", l, r, c, res);
	return res;
}

int main(void) {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n; 
	n <<= 1;
	
	for (int i = 1;i <= n && (cin >> (S + 1)); ++i)
		for (int j = 1;j <= n; ++j)
			A[i][j] = S[j] - '0';
	
	memset(dp, -1, sizeof dp);
	
	for (int i = 2;i <= n; ++i)
		if (A[1][i])
			ans += getAns(2, n, i);
	cout << ans << '\n';
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int bo = 0;
  for(int i = 0; i < n; ++i){
    cin >> a.at(i);
    bo += a.at(i);
  }
  bo = (bo + 4 * m - 1) / (4 * m);
  
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    if(bo <= a.at(i)) cnt++;
  }
  
  if(cnt < m) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

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

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5;
const int INF = 1e9;

int r;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> r;
	cout << r * r;	
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
	----------------------------------------
	We must all suffer from one of two pains: the pain of discipline or the pain of regret. 
	The difference is discipline weighs grams while regret weighs tons.
*/


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
class Main{

	public static void main(String args[]){
		FastReader sc = new FastReader();
		int n,i;
		n=sc.nextInt();
		int h[]=new int[n+1];
		for(i=1;i<=n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n+1];
		dp[1]=0;
		dp[2]=Math.abs(h[1]-h[2]);
		for(i=3;i<=n;i++)
			dp[i]=Math.min(dp[i-1]+Math.abs(h[i-1]-h[i]),dp[i-2]+Math.abs(h[i-2]-h[i]));
		out.println(dp[n]);
		out.flush();
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

	static class pair{
		int first,second;
		pair(int f,int s){
			first=f;
			second=s;
		}
	}

	public static boolean isPrime(int n) {
		if(n<2) return false;
		for(int i=2;i<=(int)Math.sqrt(n);i++) {
			if(n%i==0) return false;
		}
		return true;
	}

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;			
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(int a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        int L[]=new int[n1];
        int R[]=new int[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(int a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
}



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

int main()
{
    int n ;
    scanf("%d",&n) ;
    int a[n] , neg = 0 ;
    long long int ans = 0 ;
    for(int i = 0 ; i < n ; ++i) scanf("%d",&a[i]) ;
    for(int i = 0 ; i < n ; ++i)
    {
        if(a[i]<0) a[i]*=-1 , ++neg ;
        ans += a[i] ;
    }
    if(neg%2)
    {
        int mn = 1e9 + 1 ;
        for(int i = 0 ; i < n ; ++i) mn = min(a[i],mn) ;
        printf("%lld\n",ans-(2*mn)*1LL) ;
    }
    else printf("%lld\n",ans) ;
  
    return 0;
}


Measured memory_bytes: 640
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
a = line[0] * 1
b = line[1] * 1 
if (a <= 9 && b <= 9 ) {
    console.log(a * b)
} else {
    console.log(-1)
}


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

struct UnionFind {
  vector<int> r;
  
  UnionFind(int N){
    r = vector<int>(N, -1);
  }
  
  int root(int x){
    if(r[x] < 0) return x;
    return r[x] = root(r[x]);
  }
  
  bool unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }
  
  int size(int x){
    return -r[root(x)];
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  
  UnionFind UF(N);
  for(int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    UF.unite(A - 1, B - 1);
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    ans = max(ans, UF.size(i));
  }
  cout << ans << endl;
  
  return 0;
}

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

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

struct UF {
	vector<int> black, white, par;
	UF(int sz) : black(sz), white(sz), par(sz) {
		rep(i, sz) par[i] = i;
	}
	int parent(int i) {
		if (par[i] == i) return i;
		return par[i] = parent(par[i]);
	}
	void uni(int i, int j) {
		int pi = parent(i), pj = parent(j);
		if (pi == pj) return;
		black[pj] += black[pi];
		white[pj] += white[pi];
		par[pi] = pj;
	}
};

int main() {
	int H, W; cin >> H >> W;
	vector<vector<char>> S(H);
	UF uf = UF(H * W);
	auto idx = [W](int i, int j) {
		return i * W + j;
	};
	rep(i, H) {
		S[i].resize(W);
		rep(j, W) {
			cin >> S[i][j];
			if (S[i][j] == '#') uf.black[idx(i, j)] = 1;
			else uf.white[idx(i, j)] = 1;
		}
	}
	rep (i, H) {
		rep (j, W) {
			char c = S[i][j];
			int index = idx(i, j);
			if (0 <= i - 1 && c != S[i - 1][j]) uf.uni(index, idx(i - 1, j));
			if (0 <= j - 1 && c != S[i][j - 1]) uf.uni(index, idx(i, j - 1));
		}
	}
	uint64_t ans = 0;
	rep (i, H * W) if (uf.par[i] == i) ans += (uint64_t)uf.black[i] * uf.white[i];
	cout << ans << endl;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
    string s;
    cin>>s;
    ll a=0;
    for(ll i=0;i<s.length();i++)
    {
        ll x=(ll)(s[i]-'0');
        a+=x;
    }
    if(a%9==0)
        cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}



Measured memory_bytes: 3740
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, a, b] <- getIntList
    print $ (n `div` (a+b)) * a + min (n `mod` (a+b)) a

Measured memory_bytes: 380
# E - Knapsack 2
N,W=map(int,input().split())
w,v=[],[]
inf=10**10
for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp=[[inf]*(10**5+1) for i in range(N+1)]
dp[0][0]=0

for i in range(N):
    for j in range(10**5+1):
        # i番目の品物を選ぶ場合
        if j-v[i]>=0:
            dp[i+1][j]=min(dp[i][j-v[i]]+w[i],dp[i+1][j])
        # i番目の品物を選ばない場合
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
ans=0
for i in range(10**5+1):
    if dp[N][i]<=W:
        ans=max(ans,i)
print(ans)

Measured memory_bytes: 121324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n, m , x, y;
    cin >> n >> m >> x >> y;
    int X[100], Y[100];
    rep(i, n){
        cin >> X[i];
    }
    rep(i, m){
        cin >> Y[i];
    }

    sort(X, X+n);
    sort(Y, Y+m);

    if(X[n-1] < Y[0] && x < Y[0] && y > X[n-1]){
        cout << "No War";
    }
    else{
        cout << "War";
    }

    return 0;
}

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

using namespace std;

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

    int n, k = 2;
    cin >> n;

    vector<long long> h(n);
    vector<long long> jump(n, 1e14);
    for(int i = 0; i < n; ++i)
        cin >> h[i];

    jump[n - 1] = 0;
    for(int i = n - 2; i >= 0; i--) 
        for (int j = i + 1; j < min(n, i + k + 1); ++j)
            jump[i] = min(jump[i], jump[j] + abs(h[i] - h[j]));

    cout << jump[0] << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,X,ans=1,a=0;
cin>>N>>X;
int L[N];
for(int i=0;i<N;i++){
cin>>L[i];
}
for(int i=0;i<N;i++){
a=a+L[i];
if(a<=X){
ans++;
}
}
cout<<ans;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (long n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void printArray(int[] a) {
		for(int i=0;i<a.length-1;i++) {
		System.out.print(a[i]+" ");
		}
		System.out.println(a[a.length-1]);
	}
	public static void main(String[] args) {
		List<Integer>list=new ArrayList<Integer>();
		int a=scan.nextInt();
		for(int i=0;i<a;i++) {
			int b=scan.nextInt();
			if(b==0) {
				int c=scan.nextInt();
				list.add(c);
			}if(b==1) {
				int c=scan.nextInt();
				System.out.println(list.get(c));
			}if(b==2) {
				list.remove(list.size()-1);
			}
		}
	}
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int A = input[0];
        int B = input[1];
        int T = input[2];
        int ans = 0;
        ans = T / A * B;
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

int main() {
  string a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=stoi(a);i<=stoi(b);i++) {
    string str=to_string(i);
    if(str.at(0)==str.at(4)&&str.at(1)==str.at(3)) {
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

const int mod = 1e9 + 7;
using modint = ModInt< mod >;


int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    modint ans = 1;
    int prev = 0;
    rep (i, n) {
        int p = (s1[i] == s2[i] ? 1 : 2);
        switch (p) {
            case 1:
                if (prev == 0) {
                    ans *= 3;
                } else if (prev == 1) {
                    ans *= 2;
                } else {
                    ans *= 1;
                }
                prev = 1;
                break;
            case 2:
                if (prev == 0) {
                    ans *= 6;
                } else if (prev == 1) {
                    ans *= 2;
                } else {
                    ans *= 3;
                }
                prev = 2;
                i++;
                break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
A, B = list(map(int, input('').split()))
count = 0
for x in range(A, B + 1):
  t = str(x)
  ret = True
  for s in range(len(t) // 2):
    if t[s] != t[-(s+1)]:
      ret = False
      break
  if ret:
    count += 1

print(count)
      
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    string s;   cin >> s;
    ll n=s.size();
    vector<vector<ll>> dp(n+1, vector<ll>(13, 0));
    dp[0][0] = 1;
    rep(i, n){
        rep(j, 13){
            rep(k, 10){
                if(s[i]=='?' || s[i]-'0'==k){
                    ll md = (j*10+k)%13;
                    dp[i+1][md] += dp[i][j];
                    dp[i+1][md] %= MOD;
                }
            }
        }
    }
    
    cout << dp[n][5] << endl;
}


Measured memory_bytes: 16628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin>>a>>b;
    ll s = a-1;
    ll t = b-1;
    ll ans = t/s + bool(t%s != 0);
    
    cout << ans << endl;
    return 0;
}




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

using namespace std;

int main() {
    int N; cin >> N;
    int count_neg = 0;
    long long total = 0ll;

    int a;
    int min_a = numeric_limits<int>::max();

    for(int i=0;i<N;i++) {
        cin >> a;
        if(a < 0) count_neg++;
        total += abs(a);
        min_a = min(min_a, abs(a));
    }

    cout << total - (count_neg%2 == 1 ? 2*min_a : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
mondai = input()
s=[]
for i in range(len(mondai)):
    s.append(mondai[i])
alpha = 'abcdefghijklmnopqrstuvwxyz'
def main(s):
    now=[]
    ind=len(s)
    for i in range(len(s)):
        x=s.pop()
        k = len(now)
        if k==0:now.append(x)
        if k==1:
            if x in now:return str(ind)+' '+str(ind+1)
            now.append(x)
        if k==2:
            if x in now:return str(ind)+' '+str(ind+2)
            if x not in now:
                now = now[1:]
                now.append(x)
        ind-=1
    return '-1 -1'
print(main(s))

Measured memory_bytes: 4084
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	a, _ := nextInt(), nextInt()
	s := next()

	ok := true
	for i := range s {
		if i < a && (s[i] < '0' || '9' < s[i]) {
			ok = false
		} else if i == a && s[i] != '-' {
			ok = false
		} else if i > a && (s[i] < '0' || '9' < s[i]) {
			ok = false
		}
	}

	if ok {
		puts("Yes")
	} else {
		puts("No")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int i, j, n, q, c=0, left, right, mid;
  int S[100001], T[50001];

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0; i<q; i++){
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right)/2;
	  if(S[mid] == T[i]){
	    c++;
	    break;
	  }
	  else if(S[mid] < T[i]) left = mid+1;
	  else  right = mid;
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 876
#include<stdio.h>

int main(){

  int last[]={31,29,31,30,31,30,31,31,30,31,30,31};
  char week[][10]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday",};
  int m,d,i;
  int cnt;

  while(scanf("%d %d",&m,&d),m!=0){
    cnt=0;
    for(i=0;i<m-1;i++){
      cnt+=last[i];
    }
    cnt+=d;
    printf("%s\n",week[(cnt-1)%7]);
  }
  return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  int s=0;
  for(int i=0;i<M;i++){
    int A;
  	cin>>A;
    s+=A;
  }
  if(s<=N)
    cout<<N-s;
  else
    cout<<-1;
  return 0;
}

Measured memory_bytes: 3640
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
macro_rules! maxs {
    ($x:expr, $($y:expr), *) => {{
        let mut ret = $x;
        $(
            ret = max(ret, $y);
        )*
        ret
    }};
}

const MOD: usize = 998244353;

fn main() {
    input!(N: usize, K: usize);
    let mut lrs = vec![];
    for _ in 0..K {
        input!(t: (usize, usize));
        lrs.push(t);
    }
    let mut sum = vec![0; N + 2];
    let mut dp = vec![0; N + 1];
    // init
    dp[0] = 0;
    dp[1] = 1;

    for i in 0..N + 1 {
        for j in 0..K {
            let (l, r) = lrs[j];
            if i < l {
                continue;
            }
            let (l, r) = (l, min(i, r));
            let s = sum[i - l + 1] + MOD - sum[i - r];
            dp[i] += s;
            dp[i] %= MOD;
        }

        sum[i + 1] = sum[i] + dp[i];
        sum[i + 1] %= MOD;
    }
    println!("{}", dp[N]);
}


Measured memory_bytes: 5224
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b = na()
print('Possible' if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 else 'Impossible')

Measured memory_bytes: 3444
// #include <iostream>
#include <bits/stdc++.h>
// https://beta.atcoder.jp/contests/arc098/submissions/2567080
// https://beta.atcoder.jp/contests/arc098/submissions/2563485

using namespace std;

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

    long n;
    cin >> n;
    // char s[n];
    string s;
    // scanf("%s", &s);
    cin >> s;
    long right_e = 0;
    // for (long i = 0; i < n; i++) if (s[i] == 'E') right_e++;
    for (long i = 0; i < n; i++) right_e += (s[i] == 'E');
    // for (long i = 1; i < n; i++) if (s[i] == 'E') right_e++;
    long min_count = right_e;
    long left_w = 0;
    for (long i = 0; i < n; i++) {
    // for (long i = 1; i < n; i++) {
    //     if (!min_count) break;
        right_e -= s[i] == 'E';
        min_count = min(min_count, right_e + left_w);
        right_e += s[i] == 'W';
        //     if (s[i] == 'E') {
        //     right_e--;
        // } else {
        //     right_e++;
        // }
        // if (s[i ] == 'W') right_e++;
        // if (s[i -1] == 'W') left_w++;
        // min_count = min(min_count, right_e);
    }
    cout << min_count << '\n';
    
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int T, A;
    cin >> T >> A;

    int ans = 0;
    double min_diff = 10000000;

    for (int i = 0; i < N; ++i) {
        int H;
        cin >> H;

        double t = T - H * 0.006;

        if (min_diff > abs(A - t)) {
            ans = i + 1;
            min_diff = abs(A - t);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256