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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for(int i = 0; i < n; i++){
        if(s[i] != s[i+1]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 512
#include <cstdint>
#include <iostream>

using namespace std;

int64_t NumDivisible(int64_t a, int64_t b, int64_t x) {
  auto c = a % x == 0;
  return b / x + c - a / x;
}

int main() {
  int64_t a, b, x;

  cin >> a >> b >> x;
  cout << NumDivisible(a, b, x) << endl;
  return 0;
}

Measured memory_bytes: 256
n;s[101][26];p[101];i,t[26],m,k,o,q;G(){scanf("%s",t);for(i=0;i<n&&strcmp(s[i],t);i++);return i;}main(){for(;scanf("%d",&n),n;printf("%d\n",p[G()])){for(i=n;i--;)scanf("%s%d",s[i],p+i);for(scanf("%d",&m);m--;q<p[o]?p[o]=q:0)for(o=G(),scanf("%d",&k),q=0;k--;)q+=p[G()];}exit(0);}

Measured memory_bytes: 0
#include<iostream>
#include<vector>

using namespace std;

int main(void){
    vector<bool> b(26, true);
    string w;
    cin >> w;
    for(int i = 0; i < w.length(); i++){
        b[w[i] - 'a'] = !b[w[i] - 'a'];
    }
    for(int i = 0; i < 26; i++){
        if(!b[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include<iostream>
using namespace std;
int main(){
	vector<int> num;
	int n;
	for(int i=0;i<5;i++){
		cin>>n;
		num.push_back(n);
	}
	for(int i=0;i<5;i++){
		if(num[i]==0)cout<<i+1;
	}
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {


	int n, k;
	cin >> n >> k;

	if (k > (n - 1)*(n - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}


	int l = (n - 1)*(n - 2) / 2;

	l -= k;
	vector<pair<int, int>> v;
	REP(i, n-1) {
		v.push_back({ 1,i + 2 });
	}

	

	while (l) {

		FOR(i, 2, n) {
			FOR(j, i + 1, n + 1) {
				l--;
				v.push_back({ i,j });
				if (l == 0)break;
			}
			if (l == 0)break;
		}
		break;
	}

	cout << v.size() << endl;

	REP(i, v.size()) {
		cout << v[i].first << ' ' << v[i].second << endl;
	}
	


}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<int> AC(N), WA(N);
  int p;
  string S;
  for(int i = 0; i < M; i++){
    cin >> p >> S;
    if(S == "WA"){
      if(AC.at(p - 1) != 1)WA.at(p - 1)++;
    } else {
      if(AC.at(p - 1) != 1)AC.at(p - 1)++;
    }
  }
  int w = 0, a = 0;
  for(int i = 0; i < N; i++){
    a += AC.at(i);
    if(AC.at(i) == 1)w += WA.at(i);
  }
  cout << a << ' ' << w << endl;
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/python

import sys


def main():
  length = int(input())
  elements = list(map(int, input().split()))
  print(" ".join(str(i) for i in elements))

  sorted_list = [elements[0]]
  for i in range(1, length):
    element = elements[i]
    for j in range(0, len(sorted_list) + 1):
      if j == len(sorted_list):
        sorted_list.append(element)
      elif element < sorted_list[j]:
        sorted_list.insert(j, element)
        break
    output_list = sorted_list[0:i+1] + elements[i+1:]
    print(" ".join([str(i) for i in output_list]))

  return 0

if __name__ == '__main__':
  main()

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
int s[105];
int main(){
    int N;
    cin >> N;
    int w;
    int ans=1e9;
    int i;
    for(i=0;i<N;i++){
        cin >> w;
        s[i+1]=s[i]+w;}
    for(i=0;i<N;i++)ans=min(ans,abs(s[N]-2*s[i]));
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
array = gets.chomp.split(" ").map(&:to_i)
$count = 0
class Array
    def merge_sort
      merge = ->(a, b) {
        result = []
        while a.size > 0 and b.size > 0
          result << if a[0] < b[0]
            a.shift
          else
            $count += a.size
            b.shift
          end
        end
        result + a + b
      }
      
      l = length
      return self if l <= 1
      q = l / 2
      merge.(self[0...q].merge_sort, self[q..-1].merge_sort)
    end
end
array.merge_sort
puts $count


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

ll N, A, B, K;
ll M = 998244353;

ll p(ll x, ll y) {
    if (y == 0)
        return 1;
    return (((y & 1) ? x : 1) * p((x*x)%M, y/2))%M;
}

vector<ll> fact;
ll c_n_k(ll n, ll k) {
    return (fact[n] * p( (fact[n-k]*fact[k])%M, M - 2))%M;
}

int main(int, char**) {

    cin >> N >> A >> B >> K;
    fact.resize(N+1, 0);
    fact[0] = fact[1] = 1;
    for (int i = 2; i <= N; ++i)
        fact[i] = (i * fact[i-1])%M;

    ll res = 0;
    for (ll a = 0; a <= N; ++a) {
        if (K - A*a < 0 || (K - A*a)%B != 0)
            continue;

        ll b = (K - A*a)/B;
        if (max(a,b) > N) continue;
        res = (res + (c_n_k(N, a) * c_n_k(N, b))%M)%M;
    }

    cout << res << endl;

    return 0;
}


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

// bit使って解く方針(昨日ちょうどやったところ)
// 実装頑張る

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

    // LUMP[i]はi番目のランプの配線状況を表すbit
    int LUMP[m]={0};
    for(int i=0; i<m; i++){
        // i番目のランプはk個のswitchと繋がっている
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int s; cin >> s;
            LUMP[i] |= (1<<(s-1)); //これでok?
        }
    }

    // pの配列
    int p[m];
    for(int i=0; i<m; i++){
        cin >> p[i];
    }

    // 全状態の探索
    // 集合{0,1,...,n-1}の部分集合を全て列挙
    // 部分集合 onoff はswitchの点灯状況を表すbit
    int ans = 0;
    for(int onoff=0; onoff<(1<<n); onoff++){
        int counter=0;
        for(int i=0; i<m; i++){
            int sw = LUMP[i]&onoff;
            // swはi番目のランプに繋がっていて点灯しているswitchの集合
            // swはnbitなので一つずつ見ていく
            // on_i は 何個点灯しているか数えるint
            int on_i = 0;
            for(int j=0; j<n; j++){
                // j番目が点灯しているときon_i+=1
                if((sw>>j)&1) on_i += 1;
            }
            // on_iをpで判定してokならcounter+=1;
            if(on_i%2==p[i]) counter += 1;
        }
        if(counter==m) ans += 1;
    }
    cout << ans;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	__int128_t c;
	ll a;
	long double b;
	cin >> a >> b;
	c = a;
	cout << (ll)(a*b) << endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include<string.h>
using namespace std;

int main()
{
    string s[3]={"Sunny","Cloudy","Rainy"};
    string w;
    cin>>w;
    for(int i=0;i<3;i++)
    {
        if(strcmp(&s[i][0],&w[0])==0 && i!=2){
            cout<<s[i+1];break;}
        else if(i==2){
            cout<<s[0];break;}
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long  l;
int main()
{
    l n ;
    cin>>n;
    l arr[n][3];
    for( l i = 0 ; i<n ; i++)
    {
        for(l j = 0 ; j<3;j++)
        cin>>arr[i][j];
    }
    
    l dp[n][3];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    dp[0][0]=arr[0][0];
    
    for( l i = 1 ; i<n ; i++)
    {
    dp[i][0]=max(dp[i-1][1] , dp[i-1][2]) + arr[i][0];
    dp[i][1]=max(dp[i-1][0] , dp[i-1][2]) + arr[i][1];
    dp[i][2]=max(dp[i-1][0] , dp[i-1][1]) + arr[i][2];
    }


    
    l ans = max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2]));
    cout<<ans;
    
 /*   for( l i = 0 ; i<n ; i++)
    {
        for(l j = 0 ; j<3;j++)
        {cout<<dp[i][j]<<" ";}
        cout<<endl;
    }  */
    
    
    return 0;
}

Measured memory_bytes: 4992
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n,k;
    cin>>n>>k;
    vector<pi>vec;
    vector< vector<int> >s(2*k+1,vector<int>(2*k+1,0));
    f(i,1,n)
    {
        int x,y;
        char ch;
        cin>>x>>y>>ch;
        if(ch=='B')y-=k;
        x=(x+2*k)%(2*k);
        y=(y+2*k)%(2*k);
        vec.pb(mp(x,y));
        s[x+1][y+1]++;
    }
    auto qry = [&] (int x0,int y0,int x1,int y1)
    {
        return s[y1][x1]-s[y1][x0-1]-s[y0-1][x1]+s[y0-1][x0-1];
    };
    f(i,1,2*k)
    {
        f(j,1,2*k)
        {
            s[i][j]+=s[i-1][j];
            s[i][j]+=s[i][j-1];
            s[i][j]-=s[i-1][j-1];
        }
    }
    int ses=0;
    f(x,1,k)
    {
        f(y,1,k)
        {
            int cnt=0;
            cnt+=qry(x,y,x+k-1,y+k-1);
            cnt+=qry(1,1,x-1,y-1);
            cnt+=qry(1,y+k,x-1,2*k);
            cnt+=qry(x+k,y+k,2*k,2*k);
            cnt+=qry(x+k,1,2*k,y-1);
            ses=max(ses,max(cnt,n-cnt));
        }
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 36612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    string s; cin>>s;
    bool f=true;
    rep(i,0,s.size()){
        if((i%2==1&&s[i]=='R')||(i%2==0&&s[i]=='L'))
        f=false;
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,b,f,r,v;
    vector<int> f1(10);
    vector<int> f2(10);
    vector<int> f3(10);
    vector<int> f4(10);
    vector<int> f5(10);
    vector<int> f6(10);
    vector<int> f7(10);
    vector<int> f8(10);
    vector<int> f9(10);
    vector<int> f10(10);
    vector<int> f11(10);
    vector<int> f12(10);
    cin>>n;
    for(int i = 0;i<n;i++){
        cin>>b;
        cin>>f;
        cin>>r;
        cin>>v;
        switch(b){
            case 1:
            switch(f){
                case 1:f1.at(r -1) += v;break;
                case 2:f2.at(r -1) += v;break;
                case 3:f3.at(r -1) += v;break;
            }
            break;
            case 2:
             switch(f){
                case 1:f4.at(r -1) += v;break;
                case 2:f5.at(r -1) += v;break;
                case 3:f6.at(r -1) += v;break;
            }
            break;
            case 3:
             switch(f){
                case 1:f7.at(r -1) += v;break;
                case 2:f8.at(r -1) += v;break;
                case 3:f9.at(r -1) += v;break;
            }
            break;
            case 4:
             switch(f){
                case 1:f10.at(r -1) += v;break;
                case 2:f11.at(r -1) += v;break;
                case 3:f12.at(r -1) += v;break;
            }
            break;
        }
    }
     for(int i = 0;i<10;i++){
            cout<<" "<<f1.at(i);
        }
        cout<<endl;
         for(int i = 0;i<10;i++){
            cout<<" "<<f2.at(i);
        }
                cout<<endl;
         for(int i = 0;i<10;i++){
            cout<<" "<<f3.at(i);
        }
                cout<<endl;
            cout<<"####################"<<endl;
         for(int i = 0;i<10;i++){
            cout<<" "<<f4.at(i);
        }
        cout<<endl;

         for(int i = 0;i<10;i++){
            cout<<" "<<f5.at(i);
        }
                cout<<endl;

         for(int i = 0;i<10;i++){
            cout<<" "<<f6.at(i);
        }
                cout<<endl;
            cout<<"####################"<<endl;

         for(int i = 0;i<10;i++){
            cout<<" "<<f7.at(i);
        }
                cout<<endl;

         for(int i = 0;i<10;i++){
            cout<<" "<<f8.at(i);
        }
                cout<<endl;

         for(int i = 0;i<10;i++){
            cout<<" "<<f9.at(i);
        }
                cout<<endl;
            cout<<"####################"<<endl;

         for(int i = 0;i<10;i++){
            cout<<" "<<f10.at(i);
        }
        cout<<endl;

         for(int i = 0;i<10;i++){
            cout<<" "<<f11.at(i);
        }
                cout<<endl;

         for(int i = 0;i<10;i++){
            cout<<" "<<f12.at(i);
        }
                cout<<endl;
}



Measured memory_bytes: 3100
//vacation: dp state, day, last choice he made

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

using ll = long long;
#define pb push_back
#define f first
#define s second
ll n, w;
ll a, b;
ll dp[100002] = {0};
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll ans = 0;
    cin >> n >> w;
    for(ll cur = 0; cur < n; cur++){
        cin >> a >> b;
        for(ll i = w; i >= a; i--){
            dp[i] = max(dp[i], dp[i-a]+b);
           // cout << dp[i] << ' ' << a << ' ' << b << ' ' << i << '\n';
        }
    }
    for(ll i = 0; i <= w; i++){
        ans = max(ans, dp[i]);
    }
    cout << ans;
}

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

#define ll long long int
#define llu long long unsigned int
#define pii pair<int,int>
#define PII pair<ll,ll>

const ll MAX=1e18+100;
const ll sz=1e5+100;
const ll mod=1e9+7;

ll n,tar;

PII dp[sz];
vector<ll> ad[sz];

void DFS(ll p,ll par)
{
    dp[p].first=dp[p].second=1ll;
    ll siz=ad[p].size();
    for(ll i=0;i<siz;i++){
        ll x=ad[p][i];
        if(x != par){
            DFS(x,p);
            dp[p].first=(((dp[x].second+dp[x].first)%mod) * dp[p].first)%mod;
            dp[p].second=(dp[x].first * dp[p].second)%mod;
        }
    }
}

int main()
{
    ll m,p,q,i,j,k;
    cin>>n;

    for(i=1;i<n;i++){
        cin>>p>>q;
        ad[p].push_back(q);
        ad[q].push_back(p);
    }

    DFS(1,-1);
    ll ans=(dp[1].first+dp[1].second)%mod;
    cout<<ans<<'\n';

}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] whxy = Console.ReadLine().Split().Select(long.Parse).ToArray();
            double res = ((double)whxy[0] * (double)whxy[1]) / 2;
            bool isCenter = whxy[2] * 2 == whxy[0] && whxy[3] * 2 == whxy[1];
            Console.WriteLine("{0} {1}", res, isCenter ? 1 : 0);
        }
    }
}


Measured memory_bytes: 13396
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(self.n+1) # 1-indexed

    def init(self, init_val):
        for i, v in enumerate(init_val):
            self.add(i, v)

    def add(self, i, x):
        # i: 0-indexed
        i += 1 # to 1-indexed
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)

    def sum(self, i, j):
        # return sum of [i, j)
        # i, j: 0-indexed
        return self._sum(j) - self._sum(i)

    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & (-i)
        return res

class RangeAddBIT:
    def __init__(self, n):
        self.n = n
        self.bit1 = BIT(n)
        self.bit2 = BIT(n)

    def init(self, init_val):
        self.bit2.init(init_val)

    def add(self, l, r, x):
        # add x to [l, r)
        # l, r: 0-indexed
        self.bit1.add(l, x)
        self.bit1.add(r, -x)
        self.bit2.add(l, -x*l)
        self.bit2.add(r, x*r)

    def sum(self, l, r):
        # return sum of [l, r)
        # l, r: 0-indexed
        return self._sum(r) - self._sum(l)

    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        return self.bit1._sum(i)*i + self.bit2._sum(i)

def main():

    n, q = map(int, input().split())
    C = list(map(int, input().split()))
    LI = [[] for _ in range(n)]
    for i in range(q):
        l, r = map(int, input().split())
        l, r = l-1, r-1
        LI[r].append((l, i))

    #LR.sort(key=lambda x: x[1])

    bit = RangeAddBIT(n)
    preidx = defaultdict(lambda: -1)
    ans = [-1]*q
    for r in range(n):
        p = preidx[C[r]]
        bit.add(p+1, r+1, 1)
        preidx[C[r]] = r
        for l, i in LI[r]:
            ans[i] = bit.sum(l, l+1)
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()


Measured memory_bytes: 240968
criteria = [
  [60, 2, 600],
  [80, 5, 800],
  [100, 10, 1000],
  [120, 15, 1200],
  [140, 20, 1400],
  [160, 25, 1600]
]

while line = gets
  n = line.chomp.to_i
  break if n == 0

  fee = 0
  n.times do
    x, y, h, w = gets.chomp.split.map(&:to_i)

    criteria.each do |a|
      if x + y + h <= a[0] && w <= a[1]
        fee += a[2]
        break
      end
    end
  end

  puts fee
end

Measured memory_bytes: 9036
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);

int calc(int a, int tx){
    return (a*tx)/100;
}
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    for (int i=1; i<=10000; i++){
        int x = calc(i, 8), y = calc(i, 10);
        if (x == a and y == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3680
#include<iostream>

using namespace std;


int main() {
	int n, m;
	int**A;
	int*b;
	int*c;

	cin >> n >> m;

	A = new int*[n];
	for (int i = 0; i < n; i++) {
		A[i] = new int[m];
	}
	b = new int[m];
	c = new int[n];


	for (int i = 0; i < n; i++) {
		c[i] = 0;
		for (int j = 0; j < m; j++) {
			cin >> A[i][j];
		}
	}

	for (int j = 0; j < m; j++) {
		cin >> b[j];
		for (int i = 0; i < n; i++) {
			c[i] += A[i][j] * b[j];
		}
	}

	for (int i = 0; i < n; i++) {
		cout << c[i] << endl;
	}


	for (int i = 0; i < n; i++) {
		delete[]A[i];
		A[i] = 0;
	}
	delete[]A;
	A = 0;
	delete[]b;
	b = 0;
	delete[]c;
	c = 0;

	return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;

int main() {
	int n;
	cin >> n;
	vector<ll> t(n), a(n + 1), ans(n, -1);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ans[0] = t[0];
	for (int i = 1; i < n; i++) {
		if (t[i] > t[i - 1]) {
			ans[i] = t[i];
		}
	}
	a[n] = 0;
	for (int i = n - 1; -1 < i; i--) {
		if (a[i] > a[i + 1]) {
			if (t[i]<a[i]||(ans[i] != -1 && ans[i] != a[i])) {
				//			cout << i << " " << ans[i] << " " << a[i] << endl;
				cout << 0;
				return 0;
			}
			ans[i] = a[i];
		}
	}
	ll answ = 1;
	for (int i = 0; i < n; i++) {
		if (ans[i] == -1) {
			answ *= min(a[i], t[i]);
			answ %= 1000000007;
		}
	}
	cout << answ;
	return 0;
}



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

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

int main() {
  int N;
  cin >> N;
  map<string, int> v;
  rep(i, N) {
    string s;
    cin >> s;
    if (v.count(s)) {
      v[s] += 1;
    } else {
      v[s] = 1;
    }
  }
  int m = 0;
  vector<string> S;
  for (auto p : v) {
    auto key = p.first;
    auto value = p.second;
    if (value > m) {
      m = value;
    }
  }
  for (auto p : v) {
    auto key = p.first;
    auto value = p.second;
    if (value == m) {
      cout << key << endl;
    }
  }
}

Measured memory_bytes: 25216
#include <stdio.h>

void hyouji(int *A, int N);
void insertionSort(int *A, int N);

int main(){
  int n, i;
  scanf("%d", &n);
  int A[n];
  for(i = 0; i < n; i++){
    scanf("%d%*c", &A[i]);
  }
  hyouji(A,n);
  insertionSort(A, n);
  
  return 0;
}

void hyouji(int *A, int N){
  int i;
  for(i = 0; i < N; i ++){
    printf("%d", *(A+i));
    if(i == N - 1)
      printf("\n");
    else
      printf(" ");
  }
}

void insertionSort(int *A, int N){
  int i, j, v;
  
  for(i = 1; i < N; i++){
    v = A[i];
    j = i-1;
    while(j >= 0 && *(A+j) > v){
      *(A+j+1) = *(A+j);
      j--;
    }
    A[j+1] = v;
    hyouji(A, N);
  }
}



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

struct P {
	int x, y;
	P() : x(0), y(0) {}
	P(int x, int y)
		: x(x), y(y) {}
};

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

int main()
{
	int H, W;
	P s, g;
	vector<P> q, sol;
	char c;
	cin >> H >> W;
	vector<vector<int>> a(H, vector<int>(W, 1));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c;
			if (c == '%') {
				g.x = i, g.y = j;
			}
			else if (c == '@') {
				s.x = i, s.y = j;
				a[i][j] = 0;
				q.push_back(s);
			}
			else if (c == '$') {
				sol.push_back(P(i, j));
				a[i][j] = -1;
			}
			else if (c == '#') {
				a[i][j] = -1;
			}
		}
	}
	bool res = false;
	while (!q.empty()) {
		vector<P> tq, tsol;
		for (auto p : sol) {
			for (int i = 0; i < 4; i++) {
				int tx = p.x + dx[i], ty = p.y + dy[i];
				if (tx >= 0 && tx < H && ty >= 0 && ty < W && a[tx][ty] != -1) {
					a[tx][ty] = -1;
					tsol.push_back(P(tx, ty));
				}
			}
		}
		for (auto p : q) {
			for (int i = 0; i < 4; i++) {
				int tx = p.x + dx[i], ty = p.y + dy[i];
				if (tx >= 0 && tx < H && ty >= 0 && ty < W && a[tx][ty] == 1) {
					if (tx == g.x && ty == g.y) {
						res = true;
						tq.clear();
						break;
					}
					a[tx][ty] = 0;
					tq.push_back(P(tx, ty));
				}
			}
		}
		q = tq, sol = tsol;
	}
	cout << (res ? "Yes" : "No") << endl;
	return 0;
}

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

void dfs(unsigned long now, unsigned long prev, unsigned long& time, const vector<vector<unsigned long>>& edge, vector<unsigned long>& ord, vector<unsigned long>& low){
    low[now] = ord[now] = ++time;
    for(const auto& i : edge[now])if(i != prev){
        if(ord[i] > time)dfs(i, now, time, edge, ord, low);
        low[now] = min(low[now], low[i]);
    }
}

int main(){
    unsigned long N, M;
    cin >> N >> M;
    vector<vector<unsigned long>> edge(N);
    for(unsigned long i = 0, a, b; i < M; ++i){
        cin >> a >> b;
        edge[--a].push_back(--b);
        edge[b].push_back(a);
    }
    vector<unsigned long> ord(N, numeric_limits<unsigned long>::max()), low(N, numeric_limits<unsigned long>::max());
    unsigned long time{0};
    dfs(0, 0, time, edge, ord, low);
    unsigned long ans{0};
    for(unsigned long i = 0; i < N; ++i)for(const auto& j : edge[i])if(ord[i] < low[j])++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m, l = gets.split.map(&:to_i)

array_A = Array.new
n.times do |a|
   line_A = gets.split.map(&:to_i)
   array_A << line_A
end

array_B = Array.new
m.times do |b|
   line_B = gets.split.map(&:to_i)
   array_B << line_B
end

matrixs = Array.new
n.times do |c|
   matrix = Array.new
   l.times do |d|
      line = 0
      m.times do |e|
         element = array_A[c][e] * array_B[e][d]
         line += element
      end
      matrix << line
   end
   matrixs << matrix
end

matrixs.each do |matrix|
   matrix.each_with_index do |val, idx|
      if idx == l - 1
         print "#{val}\n"
      else
         print "#{val} "
      end
   end
end

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

int main(){

    int a,b,c,x;
    cin >> a >> b >> c >> x;
    //cout << a << b << c << x << endl;
    int ans = 0;

    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k = 0;k <= c;k++){
                if(x == (500*i+100*j+50*k)){
                    ans++;
                }
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, x;
    cin >> n >> x;
    VL a(n);
    ll s = 0;
    REP(i,n){
        a[i] = lin();
        s += a[i];
    }

    if (s == x){
        cout << n << endl;
        return 0;
    }

    sort(ALL(a));
    s = 0;
    REP(i,n){
        if (s + a[i] > x){
            cout << i << endl;
            return 0;
        }
        s += a[i];
    }
    cout << n - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int dp[n][n];
    rep(i, n)rep(j, n) dp[i][j] = 0;
    rep(i, n-1){
        if(s[i] == s[n-1]) dp[i][n-1] = 1;
        else dp[i][n-1] = 0;
    }
    int ans = 0;
    for (int j = n - 2; j >= 1; j--){
        for (int i = j - 1; i >= 0; i--){
            if(s[i] == s[j]){
                dp[i][j] = min(dp[i+1][j+1] + 1, j - i);
                ans = max(dp[i][j], ans);
            }else{
                dp[i][j] = 0;
            }
        }
    }
    // rep(i, n){
    //     rep(j, n){
    //         cout << dp[i][j] << " ";
    //     }cout << endl;
    // }

    cout << ans << endl;
}

Measured memory_bytes: 101292
import math
import itertools

K = int(input())
s = 0
l = range(K)

for i in itertools.combinations_with_replacement(l, 3):
    if i[0] == i[1] == i[2]:
        s += math.gcd(math.gcd(i[0]+1, i[1]+1), i[2]+1)
    elif i[0] != i[1] != i[2]:
        s += (math.gcd(math.gcd(i[0]+1, i[1]+1), i[2]+1)*6)
    else:
        s += (math.gcd(math.gcd(i[0]+1, i[1]+1), i[2]+1)*3)
print(s)

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

class Main{
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			String input_str;
			while((input_str = br.readLine()) != null){
				String[] input_strs = input_str.split(" ");

				// まずノードを生成
				Node node1 = new Node(input_strs[1]);
				Node node2 = new Node(input_strs[2]);
				Node result_node = new Node();

				// intersection
				if(input_strs[0].equals("i")){
					result_node.intersection(node1, node2);
				}

				// union
				if(input_strs[0].equals("u")){
					result_node.union(node1, node2);
				}

				System.out.println(result_node.toString());
			}
		}catch(Exception e){
			System.out.println("Error");
		}

		/*
		Node node1 = new Node("((,),(,))");
		System.out.println("node1: " + node1.toString());

		Node node2 = new Node("((,(,)),)");
		System.out.println("node2: " + node2.toString());

		Node inode = new Node();
		inode.intersection(node1, node2);
		System.out.println("inode: " + inode.toString());

		Node unode = new Node();
		unode.union(node1, node2);
		System.out.println("unode: " + unode.toString());
		*/
	}
}

class Node{
	Node left;
	Node right;

	Node(){
		left = null;
		right = null;
	}

	Node(String str){
		//System.out.println(str);

		int lvl = 0;
		for(int i = 0; i < str.length(); i++){
			char ch = str.charAt(i);
			if(ch == '(') lvl++;
			if(ch == ')') lvl--;
			if(ch == ',' && lvl == 1){
				// 左辺
				String left_str = str.substring(1, i);
				if(left_str.length() == 0){
					left = null;
				}else{
					left = new Node(left_str);
				}

				// 右辺
				String right_str = str.substring(i+1, str.length()-1);
				if(right_str.length() == 0){
					right = null;
				}else{
					right = new Node(right_str);
				}
			}
		}
	}

	public String toString(){
		String result = "(";
		if(left != null) result += left.toString();
		result += ",";
		if(right != null) result += right.toString();
		result += ")";
		return result;
	}

	public Node intersection(Node node1, Node node2){
		// intersection は，どちらか片方が null なら null
		// 両方 null でないなら，子の intersection
		// left
		if(node1.left != null && node2.left != null){
			left = new Node();
			left.intersection(node1.left, node2.left);
		}
		// right
		if(node1.right != null && node2.right != null){
			// どちらも null でない
			right = new Node();
			right.intersection(node1.right, node2.right);
		}
		return this;
	}

	public Node union(Node node1, Node node2){
		// left
		if(node1.left == null){
			left = node2.left;
		}else if(node2.left == null){
			left = node1.left;
		}else{
			left = new Node();
			left.union(node1.left, node2.left);
		}
		// right
		if(node1.right == null){
			right = node2.right;
		}else if(node2.right == null){
			right = node1.right;
		}else{
			right = new Node();
			right.union(node1.right, node2.right);
		}
		return this;
	}
}

Measured memory_bytes: 17892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e6 + 10;
const ll mod = 1e9 + 7;
int n, m, k;
ll a[3010][3010];
ll dp[3010][3010][4];
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= k; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		scanf("%lld", &a[x][y]);
	}
	/*for (int i = 0; i <= n; i++)for (int j = 0; j <= m; j++)for (int x = 0; x <= 3; x++)dp[i][j][k] = -inf;
	for (int i = 0; i <= n; i++)for (int j = 0; j <= m; j++)dp[i][j][0] = 0;*/
	dp[1][1][0] = 0; if (a[1][1] >= 0)dp[1][1][1] = a[1][1];
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j][0] = 0;
			if (i == 1 && j == 1)continue;
			dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0]);
			for (int x = 0; x <= 3; x++)dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][x]), dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][x] + a[i][j]);
			for (int x = 1; x <= min(j, 3); x++) {
				dp[i][j][x] = max(dp[i][j][x], max(dp[i][j - 1][x], dp[i][j - 1][x - 1] + a[i][j]));
			}
		}
	}
	for (int i = 0; i <= 3; i++)ans = max(ans, dp[n][m][i]);
	printf("%lld\n", ans);
	return 0;
}


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

int main()
{
    int x, n = 0, a[10010] = {};
    while (cin>>x,x) a[n++] = x;

    for (int i = 0; i < n; i++) {
        cout << "Case " << i + 1 << ": " << a[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    vs  v = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    map<string, ll> ans;
    rep(i, 7){
        ans[v[i]] = 7-i;
    }
    string s; cin >> s;
    cout << ans[s] << endstr;
    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
a = [1,1]
ans = 100000000000000
for i in range(int(math.sqrt(n))):
    
    if(n%a[0] == 0):
        ans =min(ans,a[0] + int(n/a[0])-2)
    a[0] += 1

a[1] = int(n/a[0])

print(ans)



Measured memory_bytes: 3188
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	char s, t,u;
	string a, b, c;
	cin >> a >> b >> c;
	s = a.at(0)-32;
	t = b.at(0) - 32;
	u = c.at(0) - 32;
	cout <<s<<t<<u<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define PI 3.141592653589793238
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    	freopen("in2.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    #endif

	int T = 1;
	//cin >> T;
	FOR1(tp, T)
	{
		//cout << "Case #" << tp << ": ";
		int R; cin >> R;
		cout << 2*PI*R;

		cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 3780
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int n, w;
int as[MAX_N], dp[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  for (int cn = 1;; cn++) {
    cin >> n >> w;
    if (n == 0) break;
    
    for (int i = 0; i < n; i++) cin >> as[i];

    dp[n] = 0;
    for (int i = n - 1, s = 0; i >= 0; i--) {
      s += as[i];
      dp[i] = max(0, s - w);
    }
    
    for (int i = n - 1; i >= 0; i--) {
      for (int j = i, s = 0; j < n; j++) {
	s += as[j];

	int cj = s - w;
	if (cj < 0) cj = -cj;
	int c = cj + dp[j + 1];
	if (dp[i] > c) dp[i] = c;
      }
    }
    //for (int i = 0; i < n; i++) cout << dp[i] << ' '; cout << endl;

    printf("Case %d: %d\n", cn, dp[0]);
  }

  return 0;
}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10**6)

n = int(input())
h = list(map(int, input().split()))

ans = 0
tmp = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        tmp += 1
        ans = max(ans, tmp)
    else:
        tmp = 0
print(ans)

Measured memory_bytes: 63984
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		while(true){
			try{
				int year = sc.nextInt();
				int month = sc.nextInt();
				int day = sc.nextInt();
				int ans = 0;
				if(year > 1868){
					if(year > 1912){
						if(year > 1926){
							if(year > 1989){
								ans = 4;
							}else if (year == 1989){
								if(month > 1){
									ans = 4;
								}else if(month == 1 && day >= 8){
									ans = 4;
								}else{
									ans = 3;
								}
							}else{
								ans = 2;
							}
						}else if (year == 1926){
							if(month > 12){
								ans = 3;
							}else if(month == 12 && day >= 25){
								ans = 3;
							}else{
								ans = 2;
							}
						}else{
							ans = 2;
						}
					}else if (year == 1912){
						if(month > 7){
							ans = 2;
						}else if(month == 7 && day >= 30){
							ans = 2;
						}else{
							ans = 1;
						}
					}else{
						ans = 1;
					}
				}else if (year == 1868){
					if(month > 9){
						ans = 1;
					}else if(month == 9 && day >= 8){
						ans = 1;
					}else{
						ans = 0;
					}
				}else{
					ans = 0;
				}
				if(ans == 0){
					System.out.println("pre-meiji");
				}else if(ans == 1){
					year = year - 1867;
					System.out.println("meiji "+year+" "+month+" "+day);
				}else if(ans == 2){
					year = year - 1911;
					System.out.println("taisho "+year+" "+month+" "+day);
				}else if(ans == 3){
					year = year - 1925;
					System.out.println("showa "+year+" "+month+" "+day);
				}else if(ans == 4){
					year = year - 1988;
					System.out.println("heisei "+year+" "+month+" "+day);
				}
			}catch(Exception g){
				System.exit(0);
			}
		}
	}
    public static void main(String[] args) {
    	new Main().doIt();
    }
}

Measured memory_bytes: 17232
#include<bits/stdc++.h>
using namespace std;
int main(){
  string n;
  int l,i,m=0;
  cin>>n;
  l=n.length();
  for(i=0;i<l;i++) m=(m+(n.at(i)-'0'))%9;
  if(m==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3748
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;

int n, p;
vector <int> primes;
bool ok[1000010];
int cnt[1000010];

void sieve () {
  primes.push_back (2);
  for (int i = 3; i <= 1000000; i += 2) {
    if (ok[i]) continue;
    primes.push_back (i);
    for (int j = i * i; j <= 1000000; j += i) {
      ok[j] = 1;
    }
  }
}

signed main () {
  boost ();
  sieve ();
  cin >> n >> p;
  for (int i = 0; i < primes.size(); i++) {
    while (p % primes[i] == 0) {
      p /= primes[i];
      cnt[primes[i]] += 1;
    }
  }
  int res = 1;
  for (int i = 1; i <= 1000000; i++) {
    int x = (cnt[i] / n);
    while (x > 0) {
      res *= i;
      x -= 1;
    }
  }
  if (p > 1) {
    if (n == 1) {
      res *= p;
    }
  } 
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5748
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
my_sum = np.sum(np.abs(A))
if np.count_nonzero(A < 0) % 2 == 0:
    print(my_sum)
else:
    print(my_sum - 2 * np.min(np.abs(A)))

Measured memory_bytes: 23364
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

        public static void main (String[] args)
        {
            FastReader input = new FastReader();
            int n = input.nextInt();
            int[] arr = new int[n];
            for(int i = 0;i < n;i++){
                arr[i] = input.nextInt();
            }
            Arrays.sort(arr);
            int count = 0;
            for(int i = 0;i < n-2;i++){
                int k = i + 2;
                for(int j = i+1;j < n;j++){
                    while (k < n && arr[i] + arr[j] > arr[k]){
                        k++;
                    }
                    if(k > j){
                        count += k - j - 1;
                    }
                }
            }
            System.out.println(count);
        }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

}


Measured memory_bytes: 22356
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
struct S { mint a, b, c; };
using F = int;
S op(S l, S r) { return S{l.a * r.b + r.a, l.b * r.b, l.c * r.b + r.c}; }
S e() { return S{0, 1, 0}; }
F id() { return -1; }
S mapping(F f, S x) { return f == id() ? x : S{x.c * f, x.b, x.c}; }
F composition(F f, F g) { return f == id() ? g : f; }
main() {
    F n, q;
    cin >> n >> q;
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector(n, S{1, 10, 1}));
    while (q--) {
        F l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << seg.all_prod().a.val() << '\n';
    }
}

Measured memory_bytes: 12744
//#include<bits/stdc++.h>
#include<iostream>
//#include<vector>
//#include<algorithm>
using namespace std;
//#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n,m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i,n) for(int i = (int)(n - 1);i > -1;i--)

//#define ALL(V) (V).begin(),(V).end()
//#define SORT(V) sort(ALL(V))

typedef long long ll;

//vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

//void isR(string s);

ll pow(ll p,ll n)
{
    if(n == 0 || p == 0)
    {
        return 1;
    }
    ll sum = 1;
    rep(i,n)
    {
        sum *= p;
    }
    return sum;
}

int main()
{
    ll N,K;
    cin >> N >> K;
    ll maxi = 0;
    rep(i,10000)
    {
        ll t = pow(K,i);
        ll l = N / t;
        if(l == 0)
        {
            maxi = i;
            goto end;
        }
    }
    end:
    cout << maxi;

}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    string s;cin >> s;
    int cnt = 0;
    int n = s.size();
    for(int i = 0;i < n;i++){
        if(s[i] != s[n-1-i])s[i] = s[n-1-i],cnt++;
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256