akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int inf = 2e9;

class segtree {
  vector<int> t;
  int n;
  
  void update(int to, int from) {
    to += n - 1;
    t.at(to) = from;
    while (to) {
      to = (to - 1) / 2;
      t.at(to) = max(t.at(2 * to + 1), t.at(2 * to + 2));
    }
  }
  
  int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return -inf;
    if (a <= l && r <= b) return t.at(k);
    return max(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
  }
  
  public:
  segtree(vector<int> a) {
    n = 1;
    while (n < a.size()) n *= 2;
    for (int i = 0; i < n - 1; i++) t.push_back(-inf);
    for (int i = 0; i < a.size(); i++) t.push_back(a.at(i));
    for (int i = a.size(); i < n; i++) t.push_back(-inf);
    for (int i = n - 2; i >= 0; i--) t.at(i) = max(t.at(2 * i + 1), t.at(2 * i + 2));
  }
  
  void edit(int k, int to) {
    update(k, to);
  }
  
  int find(int l, int r) {
    return query(l, r, 0, 0, n);
  }
};

int main() {
  constexpr int64_t mod = 998244353;
  int n;
  cin >> n;
  vector<pair<int, int>> xd(n);
  for (int i = 0; i < n; i++) {
    int xi, di;
    cin >> xi >> di;
    xd.at(i) = make_pair(xi, di);
  }
  sort(xd.begin(), xd.end());
  vector<int> x(n), mv(n), retro(n);
  for (int i = 0; i < n; i++) x.at(i) = xd.at(i).first;
  for (int i = 0; i < n; i++) {
    mv.at(i) = lower_bound(x.begin(), x.end(), x.at(i) + xd.at(i).second) - x.begin();
  }
  segtree s(mv);
  for (int i = n - 1; i >= 0; i--) {
    mv.at(i) = max(mv.at(i), s.find(i, mv.at(i)));
    s.edit(i, mv.at(i));
  }
  vector<int64_t> dp(n + 1);
  dp.at(n) = 1;
  for (int i = n; i > 0; i--) {
    dp.at(i - 1) = (dp.at(i) + dp.at(mv.at(i - 1))) % mod;
  }
  cout << dp.at(0) << endl;
}


Measured memory_bytes: 7904
#include <iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length()-1;i++){
        for(int j=i+1;j<s.length();j++){
            if(s[i]==s[j]){
                cout<<"no";
                return 0;
            }
        }
    }
    
    cout<<"yes";
    return 0;
}

Measured memory_bytes: 256
#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 A,B,C; cin>>A>>B>>C;
  if(A==B)
    cout<<C<<endl;
  else if(B==C)
    cout<<A<<endl;
  else
    cout<<B<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <stack>

using namespace std;

int main() {
	stack<int> st;
	int a, b;
	string c;

	while ( cin >> c ) {
		if ( ispunct( c[0] ) ) {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			if ( c[0] == '+' ) {
				st.push( a+b ); 
			} else if ( c[0] == '-' ) {
				st.push( b-a );
			} else if ( c[0] == '*' ) {
				st.push( a*b );
			}
		} else {
			st.push( atoi( c.c_str()) );
		}
	}

	cout << st.top() << endl;
	return 0;
}



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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

bool CompPii(pii a, pii b) { 
    return a.second < b.second;
}

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

    vector<pii> bridge;

    irep(i, m) {
        int s, t;
        cin >> s >> t;
        bridge.push_back(make_pair(s,t));
    }

    sort(bridge.begin(), bridge.end(), CompPii);
#if 0
    irep(i, bridge.size()) {
        printf("%d,%d\n", bridge[i].first, bridge[i].second);
    }
#endif
    int ans = 0;
    int right = -1;
    irep(i, m) {
        if(right <= bridge[i].first) {
            ans++;
            right = bridge[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 1400
#include <iostream>
#include <string>
 
using namespace std;
 
int main () {
  char c;
  cin >> c;
  if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o')
    cout << "vowel";
  else
    cout << "consonant";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pii;
#define dbg(x) cout << #x << " has a value of: " << x << "\n";
#define usize(x) (int)(x.size())
#define plist(x)                       \
    for (int i = 0; i < usize(x); i++) \
        cout << "eleman " << i << " = " << x[i] << "\n";
#define foreach(x) for (auto item : x)
#define fill(s, x)              \
    for (int i = 0; i < x; i++) \
        cin >> s[i];
#define in(veriler, a) (veriler.find(a) != veriler.end())
#define btw(x, y, z) x >= y&& x <= z;
std::ostream& operator<<(std::ostream& os, pair<int,int> p) {
    os << p.first << ", " << p.second;
    return os;
}
#ifdef ONLINE_JUDGE
#define fio ios_base::sync_with_stdio(false);cin.tie(null);
#else
#define fio //a
#endif
lli f(vector<pii> ad){
	lli cv=0;
	foreach(ad)cv+=item.second/2;
	return cv;
}
int main(){
	fio
	string s;
	lli k;
	cin>>s>>k;
	lli n=s.size();
	//qqqq
	char cn=s[0];
	int hg=1;
	vector<pii> vrs;
	for (int i = 1; i < n; i++)
	{
		if(s[i]==cn)hg+=1;
		else{
			vrs.push_back(pii(cn,hg));
			cn=s[i];
			hg=1;
		}
	}
	vrs.push_back(pii(cn,hg));
	vector<pii> asl=vrs;
	if(s[0]!=s[n-1]){
		cout<<f(vrs)*k<<"\n";
		return 0;
	}
	if(k==1){
		cout<<f(vrs)<<"\n";
		return 0;
	}
	if(vrs.size()==1){cout<<(n*k)/2<<"\n";return 0;}
	lli cvb=0;
	pii ng=pii(vrs[0].first,vrs[0].second+vrs[vrs.size()-1].second);
	vrs.erase(vrs.begin());
	vrs.erase(--vrs.end());
	vrs.push_back(ng);
	cvb=f(vrs)*(k-1)+f(asl);
	cout<<cvb<<"\n";
	return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    vector<int> a(26,0),b(26,0);
    for(char x:s1){
        x-=97;
        a[x]++;
    }
    for(char x:s2){
        x-=97;
        b[x]++;
    }
    sort(a.begin(),a.end(),greater<>());
    sort(b.begin(),b.end(),greater<>());
    bool flag = true;
    for(int i=0;i<26;i++){
        if(a[i]!=b[i])flag=false;
    }
    if(flag)COUT("Yes");
    else COUT("No");
    return 0;
}

Measured memory_bytes: 904
#include <iostream>
#define ll long long
using namespace std;
ll d[100010][110];
int a[110];
int b[110];
int n,m;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i]>>b[i];
	for (int i=1;i<=m;i++)
	{
		for (int j=0;j<n;j++)
		{
			d[i][j]=d[i][j-1];
			if (i>=a[j]) d[i][j]=max(d[i][j],d[i-a[j]][j-1]+b[j]);
		}
	}
	cout <<d[m][n-1];
	return 0;
}

Measured memory_bytes: 86144
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let A = input[0].split(' ').map(Number)[0];
  let B = input[0].split(' ').map(Number)[1];

  function lcm(a, b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
  }

  console.log(lcm(A, B));

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
l = []
i = 0
j = 0
while True:
  l.append(input().split())
  if l[i][1] == '?':
    break
  i += 1

for i in l[:-1]:
  if l[j][1] == '+':
    print(int(l[j][0]) + int(l[j][2]))
  elif l[j][1] == '-':
    print(int(l[j][0]) - int(l[j][2]))
  elif l[j][1] == '*':
    print(int(l[j][0]) * int(l[j][2]))
  elif l[j][1] == '/':
    print(int(l[j][0]) // int(l[j][2]))
  j += 1


Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii; // 注意必要时改类型
typedef vector<int> vi;
template<typename T>
inline void read(T &x){
    int ch = getchar(); x = 0;
    bool f = false;
    double d = 1;
    for(;ch != '-' && (ch < '0' || ch > '9');ch = getchar());
    if(ch == '-'){f = true; ch = getchar();}
    for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
    if(ch == '.') for(ch = getchar();ch >= '0' && ch <= '9';ch = getchar()) x += (ch - '0') * (d *= 0.1);
    if(f) x = -x;
}
template<typename T>
inline bool chkmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chkmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
const int N = 200;
char str[N];
int n;
inline bool check(int l, int r){
    for(Rint i = l;i <= r;++ i)
        if(str[i] != str[l + r - i]) return false;
    return true;
}
int main(){
    scanf("%s", str + 1);
    n = strlen(str + 1);
    puts(check(1, n) && check(1, n - 1 >> 1) && check(n + 3 >> 1, n) ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main () {

    ll N; cin >> N;
    vector < ll > A(N);
    REP(i,N) cin >> A[i];

    REP(i,A.size()) A[i] -= (ll)i;
    sort(A.begin(), A.end());

    ll sum = 0;
    REP(i,A.size()) sum += A[i];
    
    ll acc = 0;
    ll ans = 1e18;
    for (ll i = 0; i < N; i++) {
        sum -= A[i];
        ll pre = A[i] * i - acc;
        ll nxt = sum - A[i] * (N - i - 1);
        ans = min(ans, pre + nxt);
        acc += A[i];
    }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

ll m = 1000000007;

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,k; cin>>n>>k;
    ll arr[n]; rep(i,0,n-1){cin>>arr[i];}
    ll dp[k+1][2];
    dp[0][0] = 1;
    // 2 -> indices
    rep(i,1,k){
        if(arr[0]>=i){dp[i][0]=(1+dp[i-1][0]%m)%m;}
        else{dp[i][0]=dp[i-1][0]%m;}
    }
    rep(j,1,n-1){
        rep(i,0,k){
            if(i==0){dp[i][1]=1; continue;}
            ll x;
            if(arr[j]>=i){
                x = dp[i][0]%m;
            }
            else{ x = (dp[i][0]%m - dp[i-arr[j]-1][0]%m + m)%m;}
            dp[i][1] = (x%m + dp[i-1][1]%m)%m;
        }
        rep(i,0,k){
            dp[i][0] = dp[i][1];
        }
    }
    if(k>=1){
    cout<<(dp[k][0]%m-dp[k-1][0]%m +m)%m;}
    else{cout<<dp[k][0];}
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

typedef unsigned long long ull;
 
mt19937_64 r(std::chrono::high_resolution_clock::now().time_since_epoch().count());

ull const MASK30 = (1<<30)-1;
ull const MASK31 = INT_MAX;
ull const MOD = (1LL<<61)-1;
ull const base = r()%MOD;
 
struct RollingHash {
private:
    vector<ull> power,hash;
public:
    ull mul(ull a,ull b) {
        ull au = a>>31;
        ull ad = (a&MASK31);
        ull bu = b>>31;
        ull bd = (b&MASK31);
        ull mid = au*bd+ad*bu;
        return calcmod(((au*bu)<<1)+ad*bd+(mid>>30)+((mid&MASK30)<<31));
    }

    ull calcmod(ull a) {
        a = (a&MOD)+(a>>61);
        if (a > MOD) a -= MOD;
        return a;
    }

    RollingHash(string& s) {
        int n = s.size();
        power.resize(n+1);
        hash.resize(n+1);
        power[0] = 1;
        hash[0] = 0;
        for (int i = 0;i < n;++i) power[i+1] = mul(power[i],base);
        for (int i = 0;i < n;++i) hash[i+1] = calcmod(mul(hash[i],base)+s[i]);
    }

    ull get(int l, int r)  {
        if (l) {
            ull ret = hash[r]+MOD-mul(hash[l],power[r-l]);
            if (ret > MOD) ret -= MOD;
            return ret;
        }
        return hash[r];
    }
 
 
    ull connect(ull h1,int l,int r) {
        ull h2 = get(l,r);
        return calcmod(mul(h1,power[r-l])+h2);
    }
 
    int LCP(int l1,int r1,RollingHash& rh,int l2,int r2) {
        int ok = 0,ng = min(r1-l1,r2-l2)+1;
        while (ng-ok > 1) {
            int mid = (ok+ng)/2;
            if (get(l1,l1+mid) == rh.get(l2,l2+mid)) ok = mid;
            else ng = mid;
        }
        return ok;
    }
};

int main() {
    string s,t,u;
    cin >> s >> t;
    int n = s.size(),m = t.size(),x,ans = 0;
    u = "";
    for (int i = 0;i < m/n+2;++i) u += s;
    x = u.size();
    RollingHash rht(t),rhu(u);
    vector<int> a(x);
    for (int i = 0;i < n;++i) a[i] = rht.LCP(0,m,rhu,i,x);
    vector<bool> b(n,false),used(n,false);

    for (int i = 0;i < n;++i) {
        if (a[i] < m) continue;
        b[i] = true;
    }
    for (int i = 0;i < n;++i) {
        if (!b[i]) used[i] = true;
        if (b[((i-m)%n+n)%n]) continue;
        int ret = 0,f = i;
        while (b[f]) {
            used[f] = true;
            (f += m) %= n;
            ret++;
        }
        ans = max(ans,ret);
    }
    for (int i = 0;i < n;++i) if (!used[i]) {
        cout << "-1" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 39880
import numpy as np
K, N = map(int,input().split())
As = list(map(int, input().split()))
As = np.array(As)
Bs = np.copy(As)
As = np.append(As, 0)
Bs = np.append(0, Bs)
Cs = As-Bs
Cs = np.delete(Cs, 0, 0)
Cs = np.delete(Cs, -1, 0)
Cs = np.append(Cs, As[0]+K-As[-2])
idx = np.argmax(Cs)
print(K-Cs[idx])

Measured memory_bytes: 34152
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))

lens = []
max_len = 0
for i in range(len(A)):
  if i == len(A) - 1:
    dist = K - A[i] + A[0]
  else:
    dist = A[i+1] - A[i]
  lens.append(dist)
print(sum(lens) - max(lens))

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

void findAndMark(int a[3][3], int x) {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (a[i][j] == x) {
                a[i][j] = 0;
            }
        }
    }
}

void checkBingo(int a[3][3]) {
    // for (int i = 0; i < 3; i++) {
    //     for (int j = 0; j < 3; j++) {
    //         cout << a[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    bool result = (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0)
               || (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0)
               || (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0)
               || (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0)
               || (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0)
               || (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0)
               || (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
               || (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0);
    if (result) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}

int main() {
    int A[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            int a;
            cin >> a;
            A[i][j] = a;
        }
    }
    int N;
    cin >> N;

    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        findAndMark(A, x);
    }
    checkBingo(A);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 00:24:34 2020

@author: Kanaru Sato
"""

N = int(input())
S,T = input().split()

target = ""

for i in range(0,N):
    target = target + S[i]
    target = target + T[i]

print(target)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    ll N, M; cin >> N >> M;
    ll res;

    if (N == 1 and M == 1) res = 1;
    else if (N == 1 or M == 1) res = max(N, M)-2;
    else res = (N-2)*(M-2);

    cout << res << endl;
}

Measured memory_bytes: 256
#C-ID
n,m=map(int,input().split())
L={}
lp=[list() for _ in range(n)]#preごとのまとめの準備
for cn in range(m):
  p,y=map(int,input().split())
  lp[p-1].append([y,cn])
for pre in range(n):
  k=len(lp[pre])
  if k>0:
    sd=lp[pre]
    asd=sorted(sd)
    for d in range(k):
      cn=asd[d][1]
      ans="0"*(6-len(str(pre+1)))+str(pre+1)+"0"*(6-len(str(d+1)))+str(d+1)
      L[cn]=ans
for h in range(m):
  print(L[h])

Measured memory_bytes: 45472
import numpy
a,b = map(int,input().split())
li = list(map(int,input().split()))
L = [(i**2+i)/(2*i) for i in li]
dp=[0]*a
res = numpy.cumsum(L)
dp[0] = res[b-1]
for i in range(1,a-b+1):
    dp[i] = res[i+b-1]-res[i-1]
print(max(dp))

Measured memory_bytes: 33992
n, a, b, c, d = map(int, input().split())
s = list(str(input()))
a, b, c, d = a-1, b-1, c-1, d-1
check = 1
if c < d:
  for i in range(a,c):
    if s[i] == s[i+1] == "#":
      check = 0
      break
  if check:
    for i in range(b,d):
      if s[i] == s[i+1] == "#":
        check = 0
        break

else:
  for i in range(a,c):
    if s[i] == s[i+1] == "#":
      check = 0
      break
  if check:
    check = 0
    for i in range(b, d+1):
      if s[i-1] == s[i] == s[i+1] == ".":
        check = 1
        break


if check:
  print("Yes")
else:
  print("No")
      
  

Measured memory_bytes: 61396
#include<cstdio>
int main(void){int w,h,x,y,r;scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);puts(((x-r>=0)&&(y-r>=0)&&(x+r<=w)&&(y+r<=h))?"Yes":"No");return(0);}


Measured memory_bytes: 2696
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;

int main(void){
    long N ;
    string S;
    cin >> N;
    cin >> S;
    vector<long> R(N+1,0);
    vector<long> G(N+1,0);
    vector<long> B(N+1,0);

    for(long i = N - 1; i >= 0; i--){
        if(S[i] == 'R'){
            R[i] = R[i+1] + 1;
            G[i] = G[i+1];
            B[i] = B[i+1];
        }else if(S[i] == 'G'){
            R[i] = R[i+1];
            G[i] = G[i+1] + 1;
            B[i] = B[i+1];
        }else if(S[i] == 'B'){
            R[i] = R[i+1];
            G[i] = G[i+1];
            B[i] = B[i+1] + 1;
        }
    }

    long sum = 0;
    for(long i =0; i < N; i++){
        for(long j = i ; j < N; j++){
               if( ( S[i] == 'R' && S[j] == 'G') || ( S[i] == 'G' && S[j] == 'R')){
                    long tmp = B[j];
                    if( S[j +(j-i)] == 'B' && j +(j-i) < N) tmp--;
                    sum += tmp;
                }else if((S[i] == 'G' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'G')){
                    long tmp = R[j];
                    if( S[j +(j-i)] == 'R'&& j +(j-i) < N) tmp--;
                    sum += tmp;
                }else if((S[i] == 'B' && S[j] == 'R') || (S[i] == 'R' && S[j] == 'B')){
                    long tmp = G[j];
                    if( S[j +(j-i)] == 'G'&& j +(j-i) < N) tmp--;
                    sum += tmp;
                }
        }
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3744
n, m = map(int,input().split())
h = list(map(int,input().split()))
c = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    c[a-1].append(h[b-1])
    c[b-1].append(h[a-1])

cnt = 0
for i, a in enumerate(c):
    if a:
        a.sort(reverse=True)
        if a[0] < h[i]:
            cnt += 1
    else:
        cnt += 1
print(cnt)

Measured memory_bytes: 23304
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in [0]*N]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        dist = 0
        for d in range(D):
            dist += (X[i][d] - X[j][d])**2
        if abs(int(dist**0.5)**2 - dist) < 1e-6:ans+=1
print(ans)

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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
const int MAX = 305; 
const int MAXN = 105 ;
long long dp[MAXN][MAXN][MAX]; 
long long val[MAX]; 
long long wt[MAX] ;
long long Cap ;
int n ;
long long solve(int cnt,int pos,int extra){
    long long &ret = dp[cnt][pos][extra] ;
    if(ret != -1){
        return ret ;
    }
    if(pos == n + 1){
        return (ret = 0) ;
    }
    ret = 0 ;
    ret = solve(cnt,pos + 1,extra) ;
    long long newwt = cnt*1ll*wt[1] + extra + wt[pos] ;
    if(newwt <= Cap){
        ret = max(ret, val[pos] + solve(cnt + 1,pos + 1, extra + wt[pos] - wt[1])) ;
    }
    return ret ;
}
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
      //  freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    cin >> n >> Cap ;
    for(int i = 1 ; i <= n ; i++){
        cin >> wt[i] >> val[i] ;
    }
    memset(dp,-1,sizeof(dp)) ;
    cout << solve(0,1,0) << endl ;
    return 0 ; 
}

Measured memory_bytes: 26496
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
typedef long long ll;
#define N_MAX 100000
using namespace std;
int main(){
    int n;
    ll h[N_MAX];
    cin >> n;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    ll count_max=0;
    ll count_start=0;
    for(int i=0;i<n;i++){
        if(i==n-1){
            count_max=max(count_max,i-count_start);
        }else{
            if(h[i]<h[i+1]){
                count_max=max(count_max,i-count_start);
                count_start=i+1;
            }
        }
    }
    cout<<count_max<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 32952
#include<bits/stdc++.h>
// #define int long long int
#define endl "\n"
#define arrinp(v) for(auto &i:v) cin>>i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        double n,x,k;
        cin>>n>>x>>k;
        double temp=ceil(n/x);
        // cout<<temp<<endl;
        cout<<int(temp*k);
    }
    return 0;
}

Measured memory_bytes: 3732
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

ans = []
for n in range(N):
    for i in range(A[n]):
        ans.append(str(n + 1))

w = 0
for h in range(H):
    if h % 2 == 0:
        print(" ".join(ans[w: w + W]))
    else:
        print(" ".join(ans[w: w + W][::-1]))
    w += W


Measured memory_bytes: 3700
def gcd(x, y):
  if y != 0:
    return gcd(y, x % y)
  else:
    return x

def lcm(x, y):
  return (x // gcd(x, y)) * y



def resolve():
  n = int(input())
  t = []
  for i in range(n):
    t.append(int(input()))
  ans = 1
  for x in t:
    ans = lcm(x, ans)

  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;
    vector<vector<char>>board(a, vector<char>(b));
    vector<vector<bool>>board2(a, vector<bool>(b));
    vector<int>row(b, 0);
    rep(i, 0, a){
        rep(j, 0, b){
            cin >> board[i][j];
            board2[i][j] = true;
            if(board[i][j]=='.'){
                row[j]++;
            }
        }
    }
    rep(i, 0, a){
        int count1 = 0;
        rep(j, 0, b){
            if(board[i][j]=='.'){
                count1++;
            }
            if(row[j] == a)board2[i][j] = false;
        }
        if(count1 == b){
            rep(j, 0, b){
                board2[i][j] = false;
            }
        }
    }
    rep(i, 0, a){
        rep(j, 0, b){
            if(board2[i][j]){
                cout << board[i][j];
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n,k; cin >> n >> k;
  vector<ll> l(n);
  REP(i, n) cin >> l[i];
  sort(ALL(l), greater<>());
  ll ans = 0;
  REP(i, k) ans += l[i];
  cout << ans << endl;
}

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

int main() {
	int N, a, counter = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a % 2 == 1)counter++;
	}
	if (counter % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  int n,k; cin >>n >>k;
  cout << fixed << setprecision(12);
  vector<int> sum1000(1001); // 0からiまでの自然数の和
  for (int i=1; i<=1000; i++) sum1000.at(i) = sum1000.at(i-1) + i;
  vector<double> p(n); // 各々のサイコロの期待値を格納
  for (int i=0; i<n; i++){
    double buf; cin >>buf;
    p.at(i) = sum1000.at(buf) / buf;
  }
  vector<double> probab(n+1); // サイコロiまでの期待値の和
  probab.at(0) = 0;
  for (int i=0; i<n; i++){
    probab.at(i+1) = p.at(i) + probab.at(i);
  }
  double ans = 0;
  for (int i=0; i<n-k+1; i++){
    ans = max(ans, probab.at(i+k) - probab.at(i));
  }
  cout <<ans <<endl;

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define pb push_back
#define all(a) a.begin(),a.end()
#define i64 long long int
const double pi = 2*acos(0) ;
const int maxn = (i64)2e5+5;

int main()
{
    string s;
    cin>>s;
    int sz = s.size(),i;
    bool fg = true;
    for(i = 0 ; i<sz ; i++)
    {
        if(i%2==0)
        {
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') continue;
            else
            {
                fg = false;
                break;
            }
        }
        else if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') continue;
        else
        {
            fg = false;
            break;
        }
    }
    if(fg) pf("Yes");
    else pf("No");

return 0;
}


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

void No() {
    cout << "NO" << endl;
    exit(0);
}

void Yes() {
    cout << "YES" << endl;
    exit(0);
}
int main(void) {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);

    string s, t;
    cin >> s;

    size_t cur = 0;

    while (cur < s.size()) {
        if (cur + 4 >= s.size()) {
            No();
        }
        if (s[cur] == 'e') {
            if (s[cur + 1] != 'r' || s[cur + 2] != 'a'
                    || s[cur + 3] != 's' || s[cur + 4] != 'e') {
                No();
            }
            if (cur + 5 == s.size()) {
                Yes();
            }
            if (s[cur + 5] == 'r') {
                cur += 6;
                continue;
            } else {
                cur += 5;
                continue;
            }
        }
        if (s[cur] == 'd') {
            if (s[cur + 1] != 'r' || s[cur + 2] != 'e'
                    || s[cur + 3] != 'a' || s[cur + 4] != 'm') {
                No();
            }
            if (cur + 5 == s.size()) {
                Yes();
            }
            if (s[cur + 5] != 'e') {
                cur += 5;
                continue;
            }
            if (cur + 6 == s.size()) {
                No();
            }
            if (s[cur + 6] != 'r') {
                No();
            }
            if (cur + 7 == s.size()) {
                Yes();
            }
            if (s[cur + 7] == 'e' || s[cur + 7] == 'd') {
                cur += 7;
                continue;
            } else {
                cur += 5;
                continue;
            }
        }
        No();
    }
    Yes();
}


Measured memory_bytes: 512
import scala.annotation.tailrec

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt

  val i1 = (1 to Math.sqrt(n).toInt).map(i => loopJ(i, i + 1, 0)).sum
  val i2 = loopI(1, 0)
  //println(i1)
  //println(i2)
  println(i1 * 2 + i2)

  @tailrec
  def loopJ(i: Int, j: Int, count: Int): Int = {
    if (i * j < n) {
      //println(i + " " + j)
      loopJ(i, j + 1, count + 1)
    } else {
      count
    }
  }

  @tailrec
  def loopI(i: Int, count: Int): Int = {
    if (i * i < n) {
      //println(i + " " + i)
      loopI(i + 1, count + 1)
    } else {
      count
    }
  }

}


Measured memory_bytes: 55512
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd



def solve(N: int, X: int):
    a, p = [1], [1]
    for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)

    def _f(N, X):
        if N == 0:
            return 0 if X <= 0 else 1
        elif X < (2 + a[N-1]):
            return _f(N-1, X-1)
        elif X == (2 + a[N-1]):
            return 1 + p[N-1]
        elif X < a[N]:
            return p[N-1] + 1 + _f(N-1, X - 2 - a[N-1])
        else:
            return p[N]

    return _f(N, X)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    result = solve(N, X)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod ll(1e9+7)
ll exp(ll a,ll b)
{
  if(b==0)
    return 1;
  if(b%2==0)
    return exp(a*a%mod,b/2);
  return a*exp(a*a%mod,(b-1)/2)%mod;
}
int main()
{
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
   string s;
   cin>>s;
   int n=s.size();
   int cnt=0;
   ll ans=0;
   for(int i=n-1; i>=0; i--){
    if(s[i]=='1'){
      if(cnt==0){
        ans=(ans+exp(3,n-i-1)+2)%mod;
        cnt++;
      }
      else{
        ans=(exp(3,n-i-1)+2*ans)%mod;
      }
    }
   }
   cout<<ans;
   return 0;
}

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

ll const mod = 1e9+7;


int main() {
  int N;
  ll a,cnt=0;
  cin >> N;
  // vector<vector<ll>> A(N,vector<ll> (2));
  vector<ll> A(N);
  vector<int> memo(N,0);
  rep(i,N) {
    cin >> a;
    A[i]=a;
    
    if (i-a-1>=0) {
      cnt += memo[i-a-1];
      // cout << i-a-1 << ' ' << memo[i-a-1] << endl;
      }
    if (a+i-1<N) {
      // cout << "###" << i << "##\n";
      memo[a+i-1]++;}
  }
  cout << cnt << endl;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    vector<long long> a(n + 1);
    long long ans = 0;
    for (long long i = 1; i <= n; i++){
        for (int j = i; j <= n; j += i)
            a[j] += 1;
        
        ans += a[i] * i;
    }
    
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 81320
def is_right_triangle(a, b, c)
  (a*a == b*b + c*c) || (b*b == a*a + c*c) || (c*c == a*a + b*b)
end

n = STDIN.gets

while line = STDIN.gets
  line.chomp!
  arr = line.split(" ")
  if is_right_triangle(arr[0].to_i, arr[1].to_i, arr[2].to_i)
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 8784
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


class Factorize(object):

    def __init__(self, maxnum):
        self.primes = self.__smallest_prime_factors(maxnum)

    # 素因数分解 O(logN)
    def factorize(self, n):
        fct = defaultdict(lambda: 0)
        while n != 1:
            fct[self.primes[n]] += 1
            n //= self.primes[n]

        ans = 1
        for k, v in fct.items():
            ans *= (v + 1)

        return ans

    # n以下の最小の素因数を列挙する O(NlogN)
    def __smallest_prime_factors(self, n):

        prime = list(range(n + 1))

        for i in range(2, int(n**0.5) + 1):
            if prime[i] != i:
                continue
            for j in range(i * 2, n + 1, i):
                prime[j] = min(prime[j], i)
        return prime


def main():

    N = in_n()

    fct = Factorize(N + 10)

    ans = 0
    for i in range(1, N):
        ans += fct.factorize(i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 76984
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=300010;
ll k, n, a, pre, mx, f;
int main()
{
   in2(k,n);
   for(int i=0;i<n;i++)
   {
       in1(a);
       if(i==0) f=a;
       ll x = a-pre;
//       cout<<"x "<<x<<endl;
        mx=max(mx, x);
        if(i==n-1)
        {
            ll y= k-a+f;
//            cout<<k<<" "<<f<<" "<<y<<endl;
            mx=max(mx, y);
        }
        pre=a;
   }
//   cout<<mx<<endl;
   cout<<k-mx<<endl;
    return 0;
}

/*

*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int t[] = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = scanner.nextInt();
        }

        for (int i = n-1; i >= 0; i--) {
            System.out.print(t[i]);
            if(i != 0){
                System.out.print(" ");
            }
        }
        System.out.println("");

    }
}



Measured memory_bytes: 26284
import java.util.*;

class Main{
  public static void main(String[] args){
  ArrayList<String> hit = new ArrayList<String>();
  ArrayList<String> out = new ArrayList<String>(); 
  ArrayList<Integer> A = new ArrayList<Integer>();
  int score = 0;
  Scanner in = new Scanner(System.in);
  int n = in.nextInt();
  while (in.hasNext()){
  String str = in.nextLine();
  //??\?????§HIT,Out,HOMERUN??????????????????
  if(str.equals("HIT")){
    if(hit.size() < 3){
      hit.add("1");
    }else{
      score += 1;
    }
  }else if(str.equals("HOMERUN")){
    score += hit.size() + 1;
    hit.clear();
  }else if(str.equals("OUT")){
    if(out.size() < 2){
      out.add("1");
    }else{
      A.add(score);
      hit.clear();
      out.clear();
      score = 0;
    }
  }
  }
  for(int s: A){
    System.out.println(s);
  }
  }
}

Measured memory_bytes: 26308
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(R):
    return R**2


def main():
    R = read_int()
    print(slv(R))


if __name__ == '__main__':
    main()


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

int main()
{
	//?????????
	int num1=0,num2=0,num3=0;
	int p1=0,p2=0,p3=0,p4=0,p5=0,p6=0;
	int u1=0,u2=0,u3=0,u4=0,u5=0,u6=0;
	
	for(int i=0;i<1000;i++){
	cin>>num1;
	if(num1==0){
		return 0;
	}
	num2=1000-num1;
	p1=num2/500;
	u1=num2%500;
	p2=u1/100;
	u2=u1%100;
	p3=u2/50;
	u3=u2%50;
	p4=u3/10;
	u4=u3%10;
	p5=u4/5;
	u5=u4%5;
	p6=u5/1;
	u6=u5%1;
	num3=p1+p2+p3+p4+p5+p6;
	cout<<num3;
	cout<<"\n";
	}
}

Measured memory_bytes: 1160
while True:
  m, f, r = list(map(int, input().split()))
  if m==f==r==-1:
    break
  if m==-1 or f==-1:
    print("F")
  elif m+f>=80:
    print("A")
  elif m+f>=65:
    print("B")
  elif m+f>=50 or (m+f>=30 and r>=50):
    print("C")
  elif m+f>=30:
    print("D")
  else:
    print("F")


Measured memory_bytes: 5592
MOD = 10**9 + 7
N = int(input())
*T, = map(int, input().split())
*A, = map(int, input().split())
ans = 1
for i in range(N):
    temp1 = -1
    temp2 = -1
    if i == 0 or T[i-1] < T[i]:
        temp1 = T[i]
    if i == N-1 or A[i] > A[i+1]:
        temp2 = A[i]

    if temp1 == -1 and temp2 == -1:
        ans = (ans * min(T[i], A[i])) % MOD
    elif temp1 == -1 and temp2 != -1:
        if temp2 > T[i]: ans = 0; break
    elif temp1 != -1 and temp2 == -1:
        if temp2 > A[i]: ans = 0; break
    else:
        if temp1 != temp2: ans = 0; break
print(ans)

Measured memory_bytes: 19136
#include <stdio.h>

int gcd(int x,int y){ 

        if(y==0){
                return x;
        }else{
                return gcd(y,x%y);
        }   
}


int main(void){

        int i,j,k,n;
        int sum = 0;

        scanf("%d",&n);

        for(i=1;i<=n;i++){
                for(j=1;j<=n;j++){
                        for(k=1;k<=n;k++){
                                int tmp = gcd(i,j);
                                sum += gcd(tmp,k);
                        }   
                }   
        }   
printf("%d\n",sum);
return 0;
}



Measured memory_bytes: 1732
// K-th Substring

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	string s;
	int K;
	cin >> s >> K;

	size_t slen = s.length();

	vector<string> subs;

	for (size_t i = 0; i < slen; ++i)
		for (size_t j = 1; j <= slen - i; ++j){
			string tmp = s.substr(i, j);
			if (tmp.length() <= K)
				subs.push_back(tmp);
		}

	sort(subs.begin(), subs.end());
	unique(subs.begin(), subs.end()); // make a sorted string unique

	cout << subs[K-1] << endl;

	return 0;
}

Measured memory_bytes: 1660
o=input()
e=input()
cnt=0
i , j = 0 , 0
a = len(o)
b = len(e)
ans = ''
while i<a or j<b:
	if cnt%2==0:
 		ans = ans+(o[i])
 		i = i+1
 		cnt = cnt+1
	else:
		ans =ans+(e[j])
		j =j+1
		cnt =cnt+1
while i<a:
	ans = ans+(o[i])
	i = i+1
print(ans)

Measured memory_bytes: 61740
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n;
    cin >> n;
    int d[n];
    rep(i,n)cin>>d[i];
    sort(d,d+n);
    int ans = d[n/2]-d[n/2-1];
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 640
<>;
$z=@L=1..(@A=glob<>);
($j=--$L[--$_])<0or$z-=!$B[$j]++for@A;
map{
	($j=$L[$A[$`-/ /]]++)<0or$z+=!--$B[$j];
	($j=--$L[$A[$`-1]=$'-1])<0or$z-=!$B[$j]++;
	print$z,$/
}<>


Measured memory_bytes: 77124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

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

	ll Q, A, B;
	cin >> Q;
	rep(i, Q){
		cin >> A >> B;
		ll tiisai = min(A, B);
		ll kaketa = A * B;
		ll r1 = pow(kaketa, 0.5);
		ll r2 = r1 + 1;
		while (r1 * r2 >= kaketa) r2--;
		ll kotae = 2 * (tiisai - 1);
		kotae += max(0ll, r1 - tiisai);
		kotae += max(0ll, r2 - tiisai);
		co(kotae);
	}
	Would you please return 0;
}

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

int main() {
  int N, sum;
  sum = 0;
  cin >> N;
  
  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      sum++;
    }
  }
  if (sum == 0) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
  
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {

    private static boolean checkP(String s, int start, int end) {
        int sum = start + end, limit = (sum % 2 == 0) ? ((sum / 2) - 1) : ((sum / 2));
        for(int i = start, j = end; i <= limit; i++, --j) {
            if(s.charAt(i) != s.charAt(j)) return false;
        }
        return true;
    }

    private static boolean checkP(String s) {
        return new StringBuilder(s).reverse().toString().equals(s);
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int N = s.length();
        String first = s.substring(0, ((N - 1)/2));
        String second = s.substring(((N + 3)/2) - 1, N);
        boolean flag = checkP(first) && checkP(second) && checkP(s);
        System.out.println(flag ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844